blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
5
146
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
7
license_type
stringclasses
2 values
repo_name
stringlengths
6
79
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
4 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
5.07k
426M
star_events_count
int64
0
27
fork_events_count
int64
0
12
gha_license_id
stringclasses
3 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
6 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
1 class
length_bytes
int64
20
6.28M
extension
stringclasses
20 values
content
stringlengths
20
6.28M
authors
sequencelengths
1
16
author_lines
sequencelengths
1
16
20c86046ba37635af5141aa1a4c232fd59f1142a
09f09cd06656848ed80f132c7073568c4ce87bd5
/ANNRecognition/WTL71/atlsplit.h
98139c310a8f5aa1e6c9f2a0e36f393b2debde7e
[]
no_license
cyb3727/annrecognition
90ecf3af572f8b629b276a06af51785f656ca2be
6e4f200e1119196eba5e7fe56efa93e3ed978bc1
refs/heads/master
2021-01-17T11:31:39.865232
2011-07-10T13:50:44
2011-07-10T13:50:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
23,803
h
// Windows Template Library - WTL version 7.1 // Copyright (C) 1997-2003 Microsoft Corporation // All rights reserved. // // This file is a part of the Windows Template Library. // The code and information is provided "as-is" without // warranty of any kind, either expressed or implied. #ifndef __ATLSPLIT_H__ #define __ATLSPLIT_H__ #pragma once #ifndef __cplusplus #error ATL requires C++ compilation (use a .cpp suffix) #endif #ifdef _WIN32_WCE #error atlsplit.h is not supported on Windows CE #endif #ifndef __ATLAPP_H__ #error atlsplit.h requires atlapp.h to be included first #endif #ifndef __ATLWIN_H__ #error atlsplit.h requires atlwin.h to be included first #endif /////////////////////////////////////////////////////////////////////////////// // Classes in this file: // // CSplitterImpl<T, t_bVertical> // CSplitterWindowImpl<T, t_bVertical, TBase, TWinTraits> // CSplitterWindowT<t_bVertical> namespace WTL { /////////////////////////////////////////////////////////////////////////////// // CSplitterImpl - Provides splitter support to any window // Splitter panes constants #define SPLIT_PANE_LEFT 0 #define SPLIT_PANE_RIGHT 1 #define SPLIT_PANE_TOP SPLIT_PANE_LEFT #define SPLIT_PANE_BOTTOM SPLIT_PANE_RIGHT #define SPLIT_PANE_NONE -1 // Splitter extended styles #define SPLIT_PROPORTIONAL 0x00000001 #define SPLIT_NONINTERACTIVE 0x00000002 #define SPLIT_RIGHTALIGNED 0x00000004 #define SPLIT_BOTTOMALIGNED SPLIT_RIGHTALIGNED // Note: SPLIT_PROPORTIONAL and SPLIT_RIGHTALIGNED/SPLIT_BOTTOMALIGNED are // mutually exclusive. If both are set, splitter defaults to SPLIT_PROPORTIONAL template <class T, bool t_bVertical = true> class CSplitterImpl { public: enum { m_nPanesCount = 2, m_nPropMax = 10000 }; HWND m_hWndPane[m_nPanesCount]; RECT m_rcSplitter; int m_xySplitterPos; int m_nDefActivePane; int m_cxySplitBar; // splitter bar width/height static HCURSOR m_hCursor; int m_cxyMin; // minimum pane size int m_cxyBarEdge; // splitter bar edge bool m_bFullDrag; int m_cxyDragOffset; int m_nProportionalPos; bool m_bUpdateProportionalPos; DWORD m_dwExtendedStyle; // splitter specific extended styles int m_nSinglePane; // single pane mode // Constructor CSplitterImpl() : m_xySplitterPos(-1), m_nDefActivePane(SPLIT_PANE_NONE), m_cxySplitBar(0), m_cxyMin(0), m_cxyBarEdge(0), m_bFullDrag(true), m_cxyDragOffset(0), m_nProportionalPos(0), m_bUpdateProportionalPos(true), m_dwExtendedStyle(SPLIT_PROPORTIONAL), m_nSinglePane(SPLIT_PANE_NONE) { m_hWndPane[SPLIT_PANE_LEFT] = NULL; m_hWndPane[SPLIT_PANE_RIGHT] = NULL; ::SetRectEmpty(&m_rcSplitter); if(m_hCursor == NULL) { CStaticDataInitCriticalSectionLock lock; if(FAILED(lock.Lock())) { ATLTRACE2(atlTraceUI, 0, _T("ERROR : Unable to lock critical section in CSplitterImpl::CSplitterImpl.\n")); ATLASSERT(FALSE); return; } if(m_hCursor == NULL) m_hCursor = ::LoadCursor(NULL, t_bVertical ? IDC_SIZEWE : IDC_SIZENS); lock.Unlock(); } } // Attributes void SetSplitterRect(LPRECT lpRect = NULL, bool bUpdate = true) { if(lpRect == NULL) { T* pT = static_cast<T*>(this); pT->GetClientRect(&m_rcSplitter); } else { m_rcSplitter = *lpRect; } if(IsProportional()) UpdateProportionalPos(); else if(IsRightAligned()) UpdateRightAlignPos(); if(bUpdate) UpdateSplitterLayout(); } void GetSplitterRect(LPRECT lpRect) const { ATLASSERT(lpRect != NULL); *lpRect = m_rcSplitter; } bool SetSplitterPos(int xyPos = -1, bool bUpdate = true) { if(xyPos == -1) // -1 == middle { if(t_bVertical) xyPos = (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) / 2; else xyPos = (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge) / 2; } // Adjust if out of valid range int cxyMax = 0; if(t_bVertical) cxyMax = m_rcSplitter.right - m_rcSplitter.left; else cxyMax = m_rcSplitter.bottom - m_rcSplitter.top; if(xyPos < m_cxyMin + m_cxyBarEdge) xyPos = m_cxyMin; else if(xyPos > (cxyMax - m_cxySplitBar - m_cxyBarEdge - m_cxyMin)) xyPos = cxyMax - m_cxySplitBar - m_cxyBarEdge - m_cxyMin; // Set new position and update if requested bool bRet = (m_xySplitterPos != xyPos); m_xySplitterPos = xyPos; if(m_bUpdateProportionalPos) { if(IsProportional()) StoreProportionalPos(); else if(IsRightAligned()) StoreRightAlignPos(); } else { m_bUpdateProportionalPos = true; } if(bUpdate && bRet) UpdateSplitterLayout(); return bRet; } int GetSplitterPos() const { return m_xySplitterPos; } bool SetSinglePaneMode(int nPane = SPLIT_PANE_NONE) { ATLASSERT(nPane == SPLIT_PANE_LEFT || nPane == SPLIT_PANE_RIGHT || nPane == SPLIT_PANE_NONE); if(!(nPane == SPLIT_PANE_LEFT || nPane == SPLIT_PANE_RIGHT || nPane == SPLIT_PANE_NONE)) return false; if(nPane != SPLIT_PANE_NONE) { if(!::IsWindowVisible(m_hWndPane[nPane])) ::ShowWindow(m_hWndPane[nPane], SW_SHOW); int nOtherPane = (nPane == SPLIT_PANE_LEFT) ? SPLIT_PANE_RIGHT : SPLIT_PANE_LEFT; ::ShowWindow(m_hWndPane[nOtherPane], SW_HIDE); if(m_nDefActivePane != nPane) m_nDefActivePane = nPane; } else if(m_nSinglePane != SPLIT_PANE_NONE) { int nOtherPane = (m_nSinglePane == SPLIT_PANE_LEFT) ? SPLIT_PANE_RIGHT : SPLIT_PANE_LEFT; ::ShowWindow(m_hWndPane[nOtherPane], SW_SHOW); } m_nSinglePane = nPane; UpdateSplitterLayout(); return true; } int GetSinglePaneMode() const { return m_nSinglePane; } DWORD GetSplitterExtendedStyle() const { return m_dwExtendedStyle; } DWORD SetSplitterExtendedStyle(DWORD dwExtendedStyle, DWORD dwMask = 0) { DWORD dwPrevStyle = m_dwExtendedStyle; if(dwMask == 0) m_dwExtendedStyle = dwExtendedStyle; else m_dwExtendedStyle = (m_dwExtendedStyle & ~dwMask) | (dwExtendedStyle & dwMask); #ifdef _DEBUG if(IsProportional() && IsRightAligned()) ATLTRACE2(atlTraceUI, 0, "CSplitterImpl::SetSplitterExtendedStyle - SPLIT_PROPORTIONAL and SPLIT_RIGHTALIGNED are mutually exclusive, defaulting to SPLIT_PROPORTIONAL.\n"); #endif //_DEBUG return dwPrevStyle; } // Splitter operations void SetSplitterPanes(HWND hWndLeftTop, HWND hWndRightBottom, bool bUpdate = true) { m_hWndPane[SPLIT_PANE_LEFT] = hWndLeftTop; m_hWndPane[SPLIT_PANE_RIGHT] = hWndRightBottom; ATLASSERT(m_hWndPane[SPLIT_PANE_LEFT] == NULL || m_hWndPane[SPLIT_PANE_RIGHT] == NULL || m_hWndPane[SPLIT_PANE_LEFT] != m_hWndPane[SPLIT_PANE_RIGHT]); if(bUpdate) UpdateSplitterLayout(); } bool SetSplitterPane(int nPane, HWND hWnd, bool bUpdate = true) { ATLASSERT(nPane == SPLIT_PANE_LEFT || nPane == SPLIT_PANE_RIGHT); if(nPane != SPLIT_PANE_LEFT && nPane != SPLIT_PANE_RIGHT) return false; m_hWndPane[nPane] = hWnd; ATLASSERT(m_hWndPane[SPLIT_PANE_LEFT] == NULL || m_hWndPane[SPLIT_PANE_RIGHT] == NULL || m_hWndPane[SPLIT_PANE_LEFT] != m_hWndPane[SPLIT_PANE_RIGHT]); if(bUpdate) UpdateSplitterLayout(); return true; } HWND GetSplitterPane(int nPane) const { ATLASSERT(nPane == SPLIT_PANE_LEFT || nPane == SPLIT_PANE_RIGHT); if(nPane != SPLIT_PANE_LEFT && nPane != SPLIT_PANE_RIGHT) return false; return m_hWndPane[nPane]; } bool SetActivePane(int nPane) { ATLASSERT(nPane == SPLIT_PANE_LEFT || nPane == SPLIT_PANE_RIGHT); if(nPane != SPLIT_PANE_LEFT && nPane != SPLIT_PANE_RIGHT) return false; if(m_nSinglePane != SPLIT_PANE_NONE && nPane != m_nSinglePane) return false; ::SetFocus(m_hWndPane[nPane]); m_nDefActivePane = nPane; return true; } int GetActivePane() const { int nRet = SPLIT_PANE_NONE; HWND hWndFocus = ::GetFocus(); if(hWndFocus != NULL) { for(int nPane = 0; nPane < m_nPanesCount; nPane++) { if(hWndFocus == m_hWndPane[nPane] || ::IsChild(m_hWndPane[nPane], hWndFocus)) { nRet = nPane; break; } } } return nRet; } bool ActivateNextPane(bool bNext = true) { int nPane = m_nSinglePane; if(nPane == SPLIT_PANE_NONE) { switch(GetActivePane()) { case SPLIT_PANE_LEFT: nPane = SPLIT_PANE_RIGHT; break; case SPLIT_PANE_RIGHT: nPane = SPLIT_PANE_LEFT; break; default: nPane = bNext ? SPLIT_PANE_LEFT : SPLIT_PANE_RIGHT; break; } } return SetActivePane(nPane); } bool SetDefaultActivePane(int nPane) { ATLASSERT(nPane == SPLIT_PANE_LEFT || nPane == SPLIT_PANE_RIGHT); if(nPane != SPLIT_PANE_LEFT && nPane != SPLIT_PANE_RIGHT) return false; m_nDefActivePane = nPane; return true; } bool SetDefaultActivePane(HWND hWnd) { for(int nPane = 0; nPane < m_nPanesCount; nPane++) { if(hWnd == m_hWndPane[nPane]) { m_nDefActivePane = nPane; return true; } } return false; // not found } int GetDefaultActivePane() const { return m_nDefActivePane; } void DrawSplitter(CDCHandle dc) { ATLASSERT(dc.m_hDC != NULL); if(m_nSinglePane == SPLIT_PANE_NONE && m_xySplitterPos == -1) return; T* pT = static_cast<T*>(this); if(m_nSinglePane == SPLIT_PANE_NONE) { pT->DrawSplitterBar(dc); for(int nPane = 0; nPane < m_nPanesCount; nPane++) { if(m_hWndPane[nPane] == NULL) pT->DrawSplitterPane(dc, nPane); } } else { if(m_hWndPane[m_nSinglePane] == NULL) pT->DrawSplitterPane(dc, m_nSinglePane); } } // Overrideables void DrawSplitterBar(CDCHandle dc) { RECT rect; if(GetSplitterBarRect(&rect)) { dc.FillRect(&rect, COLOR_3DFACE); // draw 3D edge if needed T* pT = static_cast<T*>(this); if((pT->GetExStyle() & WS_EX_CLIENTEDGE) != 0) dc.DrawEdge(&rect, EDGE_RAISED, t_bVertical ? (BF_LEFT | BF_RIGHT) : (BF_TOP | BF_BOTTOM)); } } // called only if pane is empty void DrawSplitterPane(CDCHandle dc, int nPane) { RECT rect; if(GetSplitterPaneRect(nPane, &rect)) { T* pT = static_cast<T*>(this); if((pT->GetExStyle() & WS_EX_CLIENTEDGE) == 0) dc.DrawEdge(&rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); dc.FillRect(&rect, COLOR_APPWORKSPACE); } } // Message map and handlers BEGIN_MSG_MAP(CSplitterImpl) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_PAINT, OnPaint) MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint) if(IsInteractive()) { MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor) MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove) MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp) MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDoubleClick) MESSAGE_HANDLER(WM_CAPTURECHANGED, OnCaptureChanged) } MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_MOUSEACTIVATE, OnMouseActivate) MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) END_MSG_MAP() LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { GetSystemSettings(false); bHandled = FALSE; return 1; } LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast<T*>(this); // try setting position if not set if(m_nSinglePane == SPLIT_PANE_NONE && m_xySplitterPos == -1) pT->SetSplitterPos(); // do painting CPaintDC dc(pT->m_hWnd); pT->DrawSplitter(dc.m_hDC); return 0; } LRESULT OnSetCursor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { T* pT = static_cast<T*>(this); if((HWND)wParam == pT->m_hWnd && LOWORD(lParam) == HTCLIENT) { DWORD dwPos = ::GetMessagePos(); POINT ptPos = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; pT->ScreenToClient(&ptPos); if(IsOverSplitterBar(ptPos.x, ptPos.y)) return 1; } bHandled = FALSE; return 0; } LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { T* pT = static_cast<T*>(this); int xPos = GET_X_LPARAM(lParam); int yPos = GET_Y_LPARAM(lParam); if((wParam & MK_LBUTTON) && ::GetCapture() == pT->m_hWnd) { int xyNewSplitPos = 0; if(t_bVertical) xyNewSplitPos = xPos - m_rcSplitter.left - m_cxyDragOffset; else xyNewSplitPos = yPos - m_rcSplitter.top - m_cxyDragOffset; if(xyNewSplitPos == -1) // avoid -1, that means middle xyNewSplitPos = -2; if(m_xySplitterPos != xyNewSplitPos) { if(m_bFullDrag) { if(pT->SetSplitterPos(xyNewSplitPos, true)) pT->UpdateWindow(); } else { DrawGhostBar(); pT->SetSplitterPos(xyNewSplitPos, false); DrawGhostBar(); } } } else // not dragging, just set cursor { if(IsOverSplitterBar(xPos, yPos)) ::SetCursor(m_hCursor); bHandled = FALSE; } return 0; } LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled) { int xPos = GET_X_LPARAM(lParam); int yPos = GET_Y_LPARAM(lParam); if(IsOverSplitterBar(xPos, yPos)) { T* pT = static_cast<T*>(this); pT->SetCapture(); ::SetCursor(m_hCursor); if(!m_bFullDrag) DrawGhostBar(); if(t_bVertical) m_cxyDragOffset = xPos - m_rcSplitter.left - m_xySplitterPos; else m_cxyDragOffset = yPos - m_rcSplitter.top - m_xySplitterPos; } bHandled = FALSE; return 1; } LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { ::ReleaseCapture(); bHandled = FALSE; return 1; } LRESULT OnLButtonDoubleClick(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast<T*>(this); pT->SetSplitterPos(); // middle return 0; } LRESULT OnCaptureChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { if(!m_bFullDrag) { DrawGhostBar(); UpdateSplitterLayout(); T* pT = static_cast<T*>(this); pT->UpdateWindow(); } return 0; } LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM, BOOL& bHandled) { if(m_nSinglePane == SPLIT_PANE_NONE) { if(m_nDefActivePane == SPLIT_PANE_LEFT || m_nDefActivePane == SPLIT_PANE_RIGHT) ::SetFocus(m_hWndPane[m_nDefActivePane]); } else { ::SetFocus(m_hWndPane[m_nSinglePane]); } bHandled = FALSE; return 1; } LRESULT OnMouseActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) { T* pT = static_cast<T*>(this); LRESULT lRet = pT->DefWindowProc(uMsg, wParam, lParam); if(lRet == MA_ACTIVATE || lRet == MA_ACTIVATEANDEAT) { DWORD dwPos = ::GetMessagePos(); POINT pt = { GET_X_LPARAM(dwPos), GET_Y_LPARAM(dwPos) }; pT->ScreenToClient(&pt); RECT rcPane; for(int nPane = 0; nPane < m_nPanesCount; nPane++) { if(GetSplitterPaneRect(nPane, &rcPane) && ::PtInRect(&rcPane, pt)) { m_nDefActivePane = nPane; break; } } } return lRet; } LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { GetSystemSettings(true); return 0; } // Implementation - internal helpers void UpdateSplitterLayout() { if(m_nSinglePane == SPLIT_PANE_NONE && m_xySplitterPos == -1) return; T* pT = static_cast<T*>(this); RECT rect = { 0, 0, 0, 0 }; if(m_nSinglePane == SPLIT_PANE_NONE) { if(GetSplitterBarRect(&rect)) pT->InvalidateRect(&rect); for(int nPane = 0; nPane < m_nPanesCount; nPane++) { if(GetSplitterPaneRect(nPane, &rect)) { if(m_hWndPane[nPane] != NULL) ::SetWindowPos(m_hWndPane[nPane], NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER); else pT->InvalidateRect(&rect); } } } else { if(GetSplitterPaneRect(m_nSinglePane, &rect)) { if(m_hWndPane[m_nSinglePane] != NULL) ::SetWindowPos(m_hWndPane[m_nSinglePane], NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER); else pT->InvalidateRect(&rect); } } } bool GetSplitterBarRect(LPRECT lpRect) const { ATLASSERT(lpRect != NULL); if(m_nSinglePane != SPLIT_PANE_NONE || m_xySplitterPos == -1) return false; if(t_bVertical) { lpRect->left = m_rcSplitter.left + m_xySplitterPos; lpRect->top = m_rcSplitter.top; lpRect->right = m_rcSplitter.left + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge; lpRect->bottom = m_rcSplitter.bottom; } else { lpRect->left = m_rcSplitter.left; lpRect->top = m_rcSplitter.top + m_xySplitterPos; lpRect->right = m_rcSplitter.right; lpRect->bottom = m_rcSplitter.top + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge; } return true; } bool GetSplitterPaneRect(int nPane, LPRECT lpRect) const { ATLASSERT(nPane == SPLIT_PANE_LEFT || nPane == SPLIT_PANE_RIGHT); ATLASSERT(lpRect != NULL); bool bRet = true; if(m_nSinglePane != SPLIT_PANE_NONE) { if(nPane == m_nSinglePane) *lpRect = m_rcSplitter; else bRet = false; } else if(nPane == SPLIT_PANE_LEFT) { if(t_bVertical) { lpRect->left = m_rcSplitter.left; lpRect->top = m_rcSplitter.top; lpRect->right = m_rcSplitter.left + m_xySplitterPos; lpRect->bottom = m_rcSplitter.bottom; } else { lpRect->left = m_rcSplitter.left; lpRect->top = m_rcSplitter.top; lpRect->right = m_rcSplitter.right; lpRect->bottom = m_rcSplitter.top + m_xySplitterPos; } } else if(nPane == SPLIT_PANE_RIGHT) { if(t_bVertical) { lpRect->left = m_rcSplitter.left + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge; lpRect->top = m_rcSplitter.top; lpRect->right = m_rcSplitter.right; lpRect->bottom = m_rcSplitter.bottom; } else { lpRect->left = m_rcSplitter.left; lpRect->top = m_rcSplitter.top + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge; lpRect->right = m_rcSplitter.right; lpRect->bottom = m_rcSplitter.bottom; } } else { bRet = false; } return bRet; } bool IsOverSplitterRect(int x, int y) const { // -1 == don't check return ((x == -1 || (x >= m_rcSplitter.left && x <= m_rcSplitter.right)) && (y == -1 || (y >= m_rcSplitter.top && y <= m_rcSplitter.bottom))); } bool IsOverSplitterBar(int x, int y) const { if(m_nSinglePane != SPLIT_PANE_NONE) return false; if(m_xySplitterPos == -1 || !IsOverSplitterRect(x, y)) return false; int xy = t_bVertical ? x : y; int xyOff = t_bVertical ? m_rcSplitter.left : m_rcSplitter.top; return ((xy >= (xyOff + m_xySplitterPos)) && (xy < xyOff + m_xySplitterPos + m_cxySplitBar + m_cxyBarEdge)); } void DrawGhostBar() { RECT rect = { 0, 0, 0, 0 }; if(GetSplitterBarRect(&rect)) { // invert the brush pattern (looks just like frame window sizing) T* pT = static_cast<T*>(this); CWindowDC dc(pT->m_hWnd); CBrush brush = CDCHandle::GetHalftoneBrush(); if(brush.m_hBrush != NULL) { CBrushHandle brushOld = dc.SelectBrush(brush); dc.PatBlt(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, PATINVERT); dc.SelectBrush(brushOld); } } } void GetSystemSettings(bool bUpdate) { m_cxySplitBar = ::GetSystemMetrics(t_bVertical ? SM_CXSIZEFRAME : SM_CYSIZEFRAME); T* pT = static_cast<T*>(this); if((pT->GetExStyle() & WS_EX_CLIENTEDGE)) { m_cxyBarEdge = 2 * ::GetSystemMetrics(t_bVertical ? SM_CXEDGE : SM_CYEDGE); m_cxyMin = 0; } else { m_cxyBarEdge = 0; m_cxyMin = 2 * ::GetSystemMetrics(t_bVertical ? SM_CXEDGE : SM_CYEDGE); } ::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &m_bFullDrag, 0); if(bUpdate) UpdateSplitterLayout(); } bool IsProportional() const { return ((m_dwExtendedStyle & SPLIT_PROPORTIONAL) != 0); } void StoreProportionalPos() { int cxyTotal = t_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); if(cxyTotal > 0) m_nProportionalPos = ::MulDiv(m_xySplitterPos, m_nPropMax, cxyTotal); else m_nProportionalPos = 0; ATLTRACE2(atlTraceUI, 0, "CSplitterImpl::StoreProportionalPos - %i\n", m_nProportionalPos); } void UpdateProportionalPos() { int cxyTotal = t_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); if(cxyTotal > 0) { int xyNewPos = ::MulDiv(m_nProportionalPos, cxyTotal, m_nPropMax); m_bUpdateProportionalPos = false; T* pT = static_cast<T*>(this); pT->SetSplitterPos(xyNewPos, false); } } bool IsRightAligned() const { return ((m_dwExtendedStyle & SPLIT_RIGHTALIGNED) != 0); } void StoreRightAlignPos() { int cxyTotal = t_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); if(cxyTotal > 0) m_nProportionalPos = cxyTotal - m_xySplitterPos; else m_nProportionalPos = 0; ATLTRACE2(atlTraceUI, 0, "CSplitterImpl::StoreRightAlignPos - %i\n", m_nProportionalPos); } void UpdateRightAlignPos() { int cxyTotal = t_bVertical ? (m_rcSplitter.right - m_rcSplitter.left - m_cxySplitBar - m_cxyBarEdge) : (m_rcSplitter.bottom - m_rcSplitter.top - m_cxySplitBar - m_cxyBarEdge); if(cxyTotal > 0) { m_bUpdateProportionalPos = false; T* pT = static_cast<T*>(this); pT->SetSplitterPos(cxyTotal - m_nProportionalPos, false); } } bool IsInteractive() const { return ((m_dwExtendedStyle & SPLIT_NONINTERACTIVE) == 0); } }; template <class T, bool t_bVertical> HCURSOR CSplitterImpl< T, t_bVertical>::m_hCursor = NULL; /////////////////////////////////////////////////////////////////////////////// // CSplitterWindowImpl - Implements a splitter window template <class T, bool t_bVertical = true, class TBase = ATL::CWindow, class TWinTraits = ATL::CControlWinTraits> class ATL_NO_VTABLE CSplitterWindowImpl : public ATL::CWindowImpl< T, TBase, TWinTraits >, public CSplitterImpl< T , t_bVertical > { public: DECLARE_WND_CLASS_EX(NULL, CS_DBLCLKS, COLOR_WINDOW) typedef CSplitterImpl< T , t_bVertical > _baseClass; BEGIN_MSG_MAP(CSplitterWindowImpl) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) MESSAGE_HANDLER(WM_SIZE, OnSize) CHAIN_MSG_MAP(_baseClass) FORWARD_NOTIFICATIONS() END_MSG_MAP() LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { // handled, no background painting needed return 1; } LRESULT OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { if(wParam != SIZE_MINIMIZED) SetSplitterRect(); bHandled = FALSE; return 1; } }; /////////////////////////////////////////////////////////////////////////////// // CSplitterWindow - Implements a splitter window to be used as is template <bool t_bVertical = true> class CSplitterWindowT : public CSplitterWindowImpl<CSplitterWindowT<t_bVertical>, t_bVertical> { public: DECLARE_WND_CLASS_EX(_T("WTL_SplitterWindow"), CS_DBLCLKS, COLOR_WINDOW) }; typedef CSplitterWindowT<true> CSplitterWindow; typedef CSplitterWindowT<false> CHorSplitterWindow; }; //namespace WTL #endif // __ATLSPLIT_H__
[ "damoguyan8844@2e4fddd8-cc6a-11de-b393-33af5e5426e5" ]
[ [ [ 1, 870 ] ] ]
e3f70b9007fc3f91df25787e19c387fc32b80c16
05869e5d7a32845b306353bdf45d2eab70d5eddc
/soft/application/thirdpartylibs/jwidgets/src/jddex_wndutils.cpp
a13aa8fef572bacac6ee2ea9a0401c5e6eb01a80
[]
no_license
shenfahsu/sc-fix
beb9dc8034f2a8fd9feb384155fa01d52f3a4b6a
ccc96bfaa3c18f68c38036cf68d3cb34ca5b40cd
refs/heads/master
2020-07-14T16:13:47.424654
2011-07-22T16:46:45
2011-07-22T16:46:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,641
cpp
/*************************************************************************** * * File Name : jdd_wndutils.cpp * * IMPORTANT NOTICE * * Please note that any and all title and/or intellectual property rights * in and to this Software or any part of this (including without limitation * any images, photographs, animations, video, audio, music, text and/or * "applets," incorporated into the Software), herein mentioned to as * "Software", the accompanying printed materials, and any copies of the * Software, are owned by Jataayu Software (P) Ltd., Bangalore ("Jataayu") * or Jataayu's suppliers as the case may be. The Software is protected by * copyright, including without limitation by applicable copyright laws, * international treaty provisions, other intellectual property laws and * applicable laws in the country in which the Software is being used. * You shall not modify, adapt or translate the Software, without prior * express written consent from Jataayu. You shall not reverse engineer, * decompile, disassemble or otherwise alter the Software, except and * only to the extent that such activity is expressly permitted by * applicable law notwithstanding this limitation. Unauthorized reproduction * or redistribution of this program or any portion of it may result in severe * civil and criminal penalties and will be prosecuted to the maximum extent * possible under the law. Jataayu reserves all rights not expressly granted. * * THIS SOFTWARE IS PROVIDED TO YOU "AS IS" WITHOUT WARRANTY OF ANY KIND * AND ANY AND ALL REPRESENTATION * *************************************************************************** * * * File Description * ---------------- * * Purpose : Implimentation for utility functions * * Created By : * Created Date : * * * * Current Revision : * *************************************************************************** * * * Revision Details * ---------------- * * 1. Modified By : * Modified Date : * Purpose : * * * * ***************************************************************************/ #include "ddl.h" #include "jcal.h" //#include "jddex_wndutils.h" #if 0 /** * @brief overloaded new operator * @param[in] uiSize size to be allocated * @retval pointer to memory allocated * */ void* operator jddex_memutils::new( JC_UINT32 uiSize ) { return jdd_MemAlloc (1, uiSize); } /** * @brief overloaded delete operator * @param[in] p pointer to be freed * @retval None * */ void operator jddex_memutils::delete(void *p) { if( p != NULL ) jdd_MemFree (p); } #endif
[ "windyin@2490691b-6763-96f4-2dba-14a298306784" ]
[ [ [ 1, 88 ] ] ]
fb0ccd079dbce54c21e1a76e65e982eb92c24178
d425cf21f2066a0cce2d6e804bf3efbf6dd00c00
/Laptop/BobbyRMisc.cpp
b79e4db44c9f585fff6eb1fe9b7e15ec5a3f6557
[]
no_license
infernuslord/ja2
d5ac783931044e9b9311fc61629eb671f376d064
91f88d470e48e60ebfdb584c23cc9814f620ccee
refs/heads/master
2021-01-02T23:07:58.941216
2011-10-18T09:22:53
2011-10-18T09:22:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,341
cpp
#ifdef PRECOMPILEDHEADERS #include "Laptop All.h" #else #include "laptop.h" #include "BobbyRMisc.h" #include "BobbyR.h" #include "BobbyRGuns.h" #include "Utilities.h" #include "WCheck.h" #include "WordWrap.h" #include "Cursors.h" #include "Text.h" #endif UINT32 guiMiscBackground; UINT32 guiMiscGrid; void GameInitBobbyRMisc() { } BOOLEAN EnterBobbyRMisc() { VOBJECT_DESC VObjectDesc; // load the background graphic and add it VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; FilenameForBPP("LAPTOP\\miscbackground.sti", VObjectDesc.ImageFile); CHECKF(AddVideoObject(&VObjectDesc, &guiMiscBackground)); // load the gunsgrid graphic and add it VObjectDesc.fCreateFlags=VOBJECT_CREATE_FROMFILE; FilenameForBPP("LAPTOP\\miscgrid.sti", VObjectDesc.ImageFile); CHECKF(AddVideoObject(&VObjectDesc, &guiMiscGrid)); InitBobbyBrTitle(); guiPrevMiscFilterMode = -1; guiCurrentMiscFilterMode = -1; SetFirstLastPagesForNew( IC_BOBBY_MISC, guiCurrentMiscFilterMode ); //Draw menu bar InitBobbyMenuBar( ); InitBobbyRMiscFilterBar(); // CalculateFirstAndLastIndexs(); RenderBobbyRMisc( ); return(TRUE); } void ExitBobbyRMisc() { DeleteVideoObjectFromIndex(guiMiscBackground); DeleteVideoObjectFromIndex(guiMiscGrid); DeleteBobbyBrTitle(); DeleteBobbyMenuBar(); DeleteBobbyRMiscFilter(); DeleteMouseRegionForBigImage(); guiLastBobbyRayPage = LAPTOP_MODE_BOBBY_R_MISC; } void HandleBobbyRMisc() { } void RenderBobbyRMisc() { HVOBJECT hPixHandle; WebPageTileBackground(BOBBYR_NUM_HORIZONTAL_TILES, BOBBYR_NUM_VERTICAL_TILES, BOBBYR_BACKGROUND_WIDTH, BOBBYR_BACKGROUND_HEIGHT, guiMiscBackground); //Display title at top of page //DisplayBobbyRBrTitle(); // GunForm GetVideoObject(&hPixHandle, guiMiscGrid); BltVideoObject(FRAME_BUFFER, hPixHandle, 0, BOBBYR_GRIDLOC_X, BOBBYR_GRIDLOC_Y, VO_BLT_SRCTRANSPARENCY,NULL); DisplayItemInfo(IC_BOBBY_MISC, guiCurrentMiscFilterMode); UpdateButtonText(guiCurrentLaptopMode); UpdateMiscFilterButtons(); MarkButtonsDirty( ); RenderWWWProgramTitleBar( ); InvalidateRegion(LAPTOP_SCREEN_UL_X,LAPTOP_SCREEN_WEB_UL_Y,LAPTOP_SCREEN_LR_X,LAPTOP_SCREEN_WEB_LR_Y); fReDrawScreenFlag = TRUE; fPausedReDrawScreenFlag = TRUE; }
[ "jazz_ja@b41f55df-6250-4c49-8e33-4aa727ad62a1" ]
[ [ [ 1, 111 ] ] ]
95b54d7c3fe03f9a2b3d2de40315a4b56d689630
974a20e0f85d6ac74c6d7e16be463565c637d135
/trunk/coreLibrary_300/source/newton/NewtonClass.h
c26ba620f89d094f629df1cd082c7a1561ec5491
[]
no_license
Naddiseo/Newton-Dynamics-fork
cb0b8429943b9faca9a83126280aa4f2e6944f7f
91ac59c9687258c3e653f592c32a57b61dc62fb6
refs/heads/master
2021-01-15T13:45:04.651163
2011-11-12T04:02:33
2011-11-12T04:02:33
2,759,246
0
0
null
null
null
null
UTF-8
C++
false
false
3,461
h
/* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics> * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution. */ #ifndef __NewotnClass_3HL6356GYL459020__ #define __NewotnClass_3HL6356GYL459020__ #include "NewtonStdAfx.h" #include "Newton.h" #define MAX_TIMESTEP (1.0f / 60.0f) #define MIN_TIMESTEP (1.0f / 1000.0f) class Newton; class NewtonDeadBodies: public dgTree<dgBody*, void* > { public: NewtonDeadBodies(dgMemoryAllocator* const allocator); void DestroyBodies(Newton& world); }; class NewtonDeadJoints: public dgTree<dgConstraint*, void *> { public: NewtonDeadJoints(dgMemoryAllocator* const allocator); void DestroyJoints(Newton& world); }; class Newton: public dgWorld, public NewtonDeadBodies, public NewtonDeadJoints { public: DG_CLASS_ALLOCATOR(allocator) Newton (dgFloat32 scale, dgMemoryAllocator* const allocator); ~Newton (); void DestroyBody(dgBody* body); void DestroyJoint(dgConstraint* joint); void UpdatePhysics (dgFloat32 timestep); static void* DefaultAllocMemory (dgInt32 size); static void DefaultFreeMemory (void *ptr, dgInt32 size); dgFloat32 g_maxTimeStep; bool m_updating; NewtonDestroyWorld m_destructor; }; class NewtonUserJoint: public dgUserConstraint { public: NewtonUserJoint (dgWorld* world, dgInt32 maxDof, NewtonUserBilateralCallBack callback, NewtonUserBilateralGetInfoCallBack getInfo, dgBody *dyn0, dgBody *dyn1); ~NewtonUserJoint (); dgUnsigned32 JacobianDerivative (dgContraintDescritor& params); void AddAngularRowJacobian (const dgVector& dir, dgFloat32 relAngle); void AddGeneralRowJacobian (const dgFloat32* jacobian0, const dgFloat32* jacobian1); void AddLinearRowJacobian (const dgVector& pivot0, const dgVector& pivot1, const dgVector& dir); dgFloat32 GetRowForce (dgInt32 row) const; void SetHighFriction (dgFloat32 friction); void SetLowerFriction (dgFloat32 friction); void SetRowStiffness (dgFloat32 stiffness); void SetAcceleration (dgFloat32 acceleration); void SetSpringDamperAcceleration (dgFloat32 springK, dgFloat32 springD); void GetInfo (dgConstraintInfo* const info) const; void SetUpdateFeedbackFunction (NewtonUserBilateralCallBack getFeedback); void SetMaxContactsForExactSolver (bool mode, dgInt32 MaxCount); private: NewtonUserBilateralCallBack m_jacobianFnt; NewtonUserBilateralGetInfoCallBack m_getInfoCallback; dgInt32 m_rows; dgFloat32* m_forceArray; dgContraintDescritor* m_param; dgFloat32 m_lastJointAngle; dgVector m_lastPosit0; dgVector m_lastPosit1; }; #endif
[ "[email protected]@b7a2f1d6-d59d-a8fe-1e9e-8d4888b32692" ]
[ [ [ 1, 120 ] ] ]
0a1748d60073dd363697db3df2147bd8314a0ad6
028d6009f3beceba80316daa84b628496a210f8d
/uidesigner/com.nokia.carbide.cpp.uiq.components/data/laf/common.inc
9ffd208f8097cb3fdb875dac3a2b60b371385cd8
[]
no_license
JamesLinus/oss.FCL.sftools.dev.ide.carbidecpp
fa50cafa69d3e317abf0db0f4e3e557150fd88b3
4420f338bc4e522c563f8899d81201857236a66a
refs/heads/master
2020-12-30T16:45:28.474973
2010-10-20T16:19:31
2010-10-20T16:19:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,807
inc
<!-- these definitions are common to every laf --> <color key="screen.background" r="255" g="255" b="255"/> <color key="EEikColorWindowBackground" r="255" g="255" b="255"/> <color key="EEikColorWindowText" r="0" g="0" b="0"/> <color key="EEikColorControlBackground" r="255" g="255" b="255"/> <color key="EEikColorControlText" r="0" g="0" b="0"/> <color key="EEikColorControlSurroundBackground" r="100" g="100" b="100"/> <color key="EEikColorControlSurroundText" r="0" g="0" b="0"/> <color key="EEikColorControlHighlightBackground" r="200" g="200" b="200"/> <color key="EEikColorControlHighlightText" r="0" g="0" b="0"/> <color key="EEikColorControlDimmedBackground" r="200" g="200" b="200"/> <color key="EEikColorControlDimmedText" r="100" g="100" b="100"/> <color key="EEikColorControlDimmedHighlightBackground" r="200" g="200" b="200"/> <color key="EEikColorControlDimmedHighlightText" r="100" g="100" b="100"/> <color key="EEikColorDialogBackground" r="255" g="255" b="255"/> <color key="EEikColorDialogText" r="0" g="0" b="0"/> <color key="EEikColorDialogTitle" r="200" g="200" b="200"/> <color key="EEikColorDialogTitlePressed" r="200" g="200" b="200"/> <color key="EEikColorDialogTitleText" r="0" g="0" b="0"/> <color key="EEikColorDialogTitleTextPressed" r="0" g="0" b="0"/> <color key="EEikColorMenubarBackground" r="255" g="255" b="255"/> <color key="EEikColorMenubarText" r="0" g="0" b="0"/> <color key="EEikColorMenubarTitleBackground" r="255" g="255" b="255"/> <color key="EEikColorMenubarTitleText" r="0" g="0" b="0"/> <color key="EEikColorMenuPaneBackground" r="255" g="255" b="255"/> <color key="EEikColorMenuPaneText" r="0" g="0" b="0"/> <color key="EEikColorMenuPaneHighlight" r="0" g="0" b="0"/> <color key="EEikColorMenuPaneTextHighlight" r="255" g="255" b="255"/> <color key="EEikColorMenuPaneDimmedHighlight" r="255" g="255" b="255"/> <color key="EEikColorMenuPaneDimmedText" r="0" g="0" b="0"/> <color key="EEikColorMenuPaneDimmedTextHighlight" r="0" g="0" b="0"/> <color key="EEikColorButtonFaceClear" r="255" g="255" b="255"/> <color key="EEikColorButtonFaceSet" r="255" g="255" b="255"/> <color key="EEikColorButtonFaceSetPressed" r="255" g="255" b="255"/> <color key="EEikColorButtonFaceClearPressed" r="255" g="255" b="255"/> <color key="EEikColorButtonText" r="0" g="0" b="0"/> <color key="EEikColorButtonTextPressed" r="0" g="0" b="0"/> <color key="EEikColorButtonTextDimmed" r="0" g="0" b="0"/> <color key="EEikColorMsgWinForeground" r="0" g="0" b="0"/> <color key="EEikColorMsgWinBackground" r="255" g="255" b="255"/> <color key="EEikColorScrollBarBorder" r="100" g="100" b="100"/> <color key="EEikColorScrollBarShaft" r="255" g="255" b="255"/> <color key="EEikColorScrollBarShaftDimmed" r="255" g="255" b="255"/> <color key="EEikColorScrollBarShaftPressed" r="255" g="255" b="255"/> <color key="EEikColorScrollBarNoShaftOrThumb" r="255" g="255" b="25"/> <color key="EEikColorScrollButtonIcon" r="255" g="255" b="255"/> <color key="EEikColorScrollButtonIconPressed" r="255" g="255" b="255"/> <color key="EEikColorScrollButtonIconDimmed" r="255" g="255" b="255"/> <color key="EEikColorScrollButtonThumbBackground" r="255" g="255" b="255"/> <color key="EEikColorScrollButtonThumbBackgroundPressed" r="255" g="255" b="255"/> <color key="EEikColorScrollThumbDimmed" r="255" g="255" b="25"/> <color key="EEikColorScrollThumbEdge" r="255" g="255" b="255"/> <color key="EEikColorToolbarBackground" r="255" g="255" b="255"/> <color key="EEikColorToolbarText" r="0" g="0" b="0"/> <color key="EEikColorStatusPaneText" r="0" g="0" b="0"/> <color key="EEikColorLabelText" r="0" g="0" b="0"/> <color key="EEikColorLabelTextEmphasis" r="0" g="0" b="0"/> <color key="EEikColorLabelDimmedText" r="0" g="0" b="0"/> <color key="EEikColorLabelHighlightPartialEmphasis" r="255" g="255" b="255"/> <color key="EEikColorLabelHighlightFullEmphasis" r="255" g="255" b="255"/> <color key="EEikColorProgressBar" r="252" g="215" b="129"/> <color key="EEikColorProgressBarDimmed" r="131" g="176" b="203"/> <color key="EEikColorLabelBackgroundPartialEmphasis" r="85" g="85" b="85"/> <color key="EEikColorLabelBackgroundFullEmphasis" r="0" g="0" b="0"/> <colorAlias key="EEikColorStatusPaneBackground" ref="screen.background"/> <image key="commandButton.noSet.background" imageFile="button.noSet.background.png"/> <image key="commandButton.set.background" imageFile="button.set.background.png"/> <image key="bitmapButton.noSet.background" imageFile="button.noSet.background.png"/> <image key="bitmapButton.set.background" imageFile="button.set.background.png"/> <image key="textButton.noSet.background" imageFile="button.noSet.background.png"/> <image key="textButton.set.background" imageFile="button.set.background.png"/>
[ [ [ 1, 78 ] ] ]
b927432c8cba0cd70cc7ed53ca9c74eed6aaf72e
496be1b38c9d03d478d02f4ccd54ce5c27aa689f
/7zip/CPP/Windows/FileDir.h
56f4886c58c4ea23e1fc684037bfe01270a8c1bf
[]
no_license
ehsan/nouatest-crowdsource
d63af32cb86c6b4e7afec508146a6c55b6bb5673
43ce064c526368e0827f0679a86d3d30da52f33b
refs/heads/master
2016-09-05T10:41:11.670248
2011-12-08T21:55:23
2011-12-08T21:55:23
2,894,914
0
0
null
null
null
null
UTF-8
C++
false
false
5,183
h
// Windows/FileDir.h #ifndef __WINDOWS_FILEDIR_H #define __WINDOWS_FILEDIR_H #include "../Common/MyString.h" #include "Defs.h" namespace NWindows { namespace NFile { namespace NDirectory { #ifdef WIN_LONG_PATH bool GetLongPaths(LPCWSTR s1, LPCWSTR s2, UString &d1, UString &d2); #endif bool MyGetWindowsDirectory(CSysString &path); bool MyGetSystemDirectory(CSysString &path); #ifndef _UNICODE bool MyGetWindowsDirectory(UString &path); bool MyGetSystemDirectory(UString &path); #endif bool SetDirTime(LPCWSTR fileName, const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime); bool MySetFileAttributes(LPCTSTR fileName, DWORD fileAttributes); bool MyMoveFile(LPCTSTR existFileName, LPCTSTR newFileName); bool MyRemoveDirectory(LPCTSTR pathName); bool MyCreateDirectory(LPCTSTR pathName); bool CreateComplexDirectory(LPCTSTR pathName); bool DeleteFileAlways(LPCTSTR name); bool RemoveDirectoryWithSubItems(const CSysString &path); #ifndef _UNICODE bool MySetFileAttributes(LPCWSTR fileName, DWORD fileAttributes); bool MyMoveFile(LPCWSTR existFileName, LPCWSTR newFileName); bool MyRemoveDirectory(LPCWSTR pathName); bool MyCreateDirectory(LPCWSTR pathName); bool CreateComplexDirectory(LPCWSTR pathName); bool DeleteFileAlways(LPCWSTR name); bool RemoveDirectoryWithSubItems(const UString &path); #endif #ifndef _WIN32_WCE bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath); bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, int &fileNamePartStartIndex); bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath); bool GetOnlyName(LPCTSTR fileName, CSysString &resultName); bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName); #ifndef _UNICODE bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex); bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath); bool GetOnlyName(LPCWSTR fileName, UString &resultName); bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName); #endif inline bool MySetCurrentDirectory(LPCTSTR path) { return BOOLToBool(::SetCurrentDirectory(path)); } bool MyGetCurrentDirectory(CSysString &resultPath); #ifndef _UNICODE bool MySetCurrentDirectory(LPCWSTR path); bool MyGetCurrentDirectory(UString &resultPath); #endif #endif bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, CSysString &resultPath, UINT32 &filePart); #ifndef _UNICODE bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, UString &resultPath, UINT32 &filePart); #endif inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, CSysString &resultPath) { UINT32 value; return MySearchPath(path, fileName, extension, resultPath, value); } #ifndef _UNICODE inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, UString &resultPath) { UINT32 value; return MySearchPath(path, fileName, extension, resultPath, value); } #endif bool MyGetTempPath(CSysString &resultPath); #ifndef _UNICODE bool MyGetTempPath(UString &resultPath); #endif UINT MyGetTempFileName(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath); #ifndef _UNICODE UINT MyGetTempFileName(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath); #endif class CTempFile { bool _mustBeDeleted; CSysString _fileName; public: CTempFile(): _mustBeDeleted(false) {} ~CTempFile() { Remove(); } void DisableDeleting() { _mustBeDeleted = false; } UINT Create(LPCTSTR dirPath, LPCTSTR prefix, CSysString &resultPath); bool Create(LPCTSTR prefix, CSysString &resultPath); bool Remove(); }; #ifdef _UNICODE typedef CTempFile CTempFileW; #else class CTempFileW { bool _mustBeDeleted; UString _fileName; public: CTempFileW(): _mustBeDeleted(false) {} ~CTempFileW() { Remove(); } void DisableDeleting() { _mustBeDeleted = false; } UINT Create(LPCWSTR dirPath, LPCWSTR prefix, UString &resultPath); bool Create(LPCWSTR prefix, UString &resultPath); bool Remove(); }; #endif bool CreateTempDirectory(LPCTSTR prefixChars, CSysString &dirName); class CTempDirectory { bool _mustBeDeleted; CSysString _tempDir; public: const CSysString &GetPath() const { return _tempDir; } CTempDirectory(): _mustBeDeleted(false) {} bool Create(LPCTSTR prefix) ; bool Remove() { if (!_mustBeDeleted) return true; _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir); return (!_mustBeDeleted); } void DisableDeleting() { _mustBeDeleted = false; } }; #ifdef _UNICODE typedef CTempDirectory CTempDirectoryW; #else class CTempDirectoryW { bool _mustBeDeleted; UString _tempDir; public: const UString &GetPath() const { return _tempDir; } CTempDirectoryW(): _mustBeDeleted(false) {} ~CTempDirectoryW() { Remove(); } bool Create(LPCWSTR prefix) ; bool Remove() { if (!_mustBeDeleted) return true; _mustBeDeleted = !RemoveDirectoryWithSubItems(_tempDir); return (!_mustBeDeleted); } void DisableDeleting() { _mustBeDeleted = false; } }; #endif }}} #endif
[ [ [ 1, 177 ] ] ]
0200b95e6aecb44f5ec350cc763767399dc21389
7dd19b99378bc5ca4a7c669617a475f551015d48
/opencamera_Lite/rtsp_stack/RTSPSdk.cpp
dc777077fff6331855bddcd246c5dd17c9105010
[]
no_license
Locnath/openpernet
988a822eb590f8ed75f9b4e8c2aa7b783569b9da
67dad1ac4cfe7c336f8a06b8c50540f12407b815
refs/heads/master
2020-06-14T14:32:17.351799
2011-06-23T08:51:04
2011-06-23T08:51:04
41,778,769
0
0
null
null
null
null
UTF-8
C++
false
false
7,227
cpp
#include "RTSPServer.h" #include "EncoderSource.h" #include "RTSPCommon.h" #include "GroupsockHelper.h" #include "rsa_crypto.h" #include "RTSPSdk.h" #include "Debug.h" #ifdef __WIN32__ #include <iostream.h> #else #include <iostream> #endif #if defined(__WIN32__) || defined(_WIN32) || defined(_QNX4) #else #include <signal.h> #define USE_SIGNALS 1 #endif #include <time.h> // for "strftime()" and "gmtime()" #ifndef __WIN32__ using namespace std; #endif #ifdef SDKH264 #include "Base64.h" #endif #ifndef __WIN32__ #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <dirent.h> #endif void getServerInfo(char *host, unsigned short *port, int defaultType) { if(defaultType) { } else { memcpy(host, "219.235.235.3", sizeof("219.235.235.3")); //memcpy(host, "s.starv.tv", sizeof("s.starv.tv")); *port = 554; } } void getDeviceInfo(unsigned char channel, char *ip, unsigned short *port, char *mac) { memcpy(ip, "192.168.10.131", sizeof("192.168.10.131")); *port = 554; memcpy(mac, "000102030455", sizeof("000102030455")); } void getHttpServerInfo(char *host, unsigned short *port) { memcpy(host, "219.235.235.4", sizeof("219.235.235.4")); *port = 80; } void getListenPortByChannel(unsigned short *port, unsigned char channel) { switch (channel) { case CAMERA_CHANNEL_1: *port = 8553+CAMERA_CHANNEL_1; case CAMERA_CHANNEL_2: *port = 8553+CAMERA_CHANNEL_2; } } void getUserAgent(char *ua_buf, int buf_len) { memcpy(ua_buf, "STARVALLEY-PCSIMU1 0.1", sizeof("STARVALLEY-PCSIMU1 0.1")); } #define PLAY_FILE_DIR "../../IPCamera" char temp_key[257] = {"A9D860C8F2ECB94F959C75B28620A71E0D27B42B5989DCC2DDB99EB546E6A" "7EBD0DAB90335A8B08F9E80DF6BAF38AAB363A3D4A7AA74A677F4661AF3E1" "1F169E88A8D8CE911D36B50BDD79C921C38A4B8D06FBDD44F149239044DE1" "FECB42AB22D1BFF8B1DA232430CEC62CD8208507E88E994A51BC92B6C2BC2" "C8DE6A062357"}; void readkey(unsigned char channel, char *chCode) { memcpy(chCode, temp_key, strlen(temp_key)); } void writekey(unsigned char channel, char const *chCode) { //memcpy(temp_key, chCode, strlen((char const *)chCode)); } void RTSPServer::RTSPEncoderSession ::readSerial(char *serial) { } void RTSPServer::RTSPEncoderSession ::writeSerial(char const *serial) { Debug(ckite_log_message, "serial = %s\n", serial); } void RTSPServer::RTSPEncoderSession ::writeActiveServerInfo(char const *host, unsigned short port) { } #define CIF_CONFIG "\x00\x00\x01\xb0\x08\x00\x00\x01\xb5\x09\x00\x00\x01\x00\x00\x00\x01\x20\x00\x84\x40\xfa\x28\x58\x21\x20\xA3\x1f" // fix_vop_rate = 0 #define H264CIF_SPS_CONFIG "\x67\x42\xc0\x0c\xf2\x02\xc1\x2d\x08\x00\x00\x03\x03\x20\x00\x00\x03\x00\10\x78\xa1\x52\x40" #define H264CIF_PPS_CONFIG "\x68\xcb\x83\xcb\x20" void getVideoCodecConfig(int width, int height, int *profile_level_id, unsigned char *config, unsigned int *config_length) { #ifdef SDKH264 char *spsOut = NULL; char *ppsOut = NULL; *profile_level_id = 4366366; if(width == 352 && height == 288) { spsOut = base64Encode((char *)H264CIF_SPS_CONFIG, 23); Debug(ckite_log_message, "spsOut = %s\n", spsOut); ppsOut = base64Encode((char *)H264CIF_PPS_CONFIG, 5); Debug(ckite_log_message, "ppsOut = %s\n", ppsOut); sprintf((char *)config, "%s,%s", spsOut, ppsOut); } *config_length = strlen((char const *)config); delete [] spsOut; delete [] ppsOut; #else *profile_level_id = 8; if(width == 352 && height == 288) { unsigned char *cifConfig = (unsigned char *)CIF_CONFIG; memcpy(config, cifConfig, 28); *config_length = 28; } #endif } void RTSPServer::RTSPEncoderSession ::deviceHandleArmAndDisarmScene( int actionType) { //scene switch(actionType) { case DISARM: Debug(ckite_log_message, "disarm\n"); break; case ZONEARM: Debug(ckite_log_message, "zone-arm\n"); break; case ACTIVEALARM: Debug(ckite_log_message, "active-alarm\n"); break; case STOPALARM: Debug(ckite_log_message, "stop-alarm\n"); break; default: Debug(ckite_log_message, "unknown action\n"); } } void RTSPServer::RTSPEncoderSession ::get_LanWebURL(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "LanWebURL: ","http://192.168.10.131:80"); } void RTSPServer::RTSPEncoderSession ::get_WanWebURL(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "WanWebURL: ","http://[WANIP]:80"); } void RTSPServer::RTSPEncoderSession ::get_P2PLanURL(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "P2PLanURL: ","rtsp://192.168.10.131:8554/live"); } void RTSPServer::RTSPEncoderSession ::get_P2PWanURL(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "P2PWanURL: ","rtsp://[WANIP]:8150/live_video.sdp"); } void RTSPServer::RTSPEncoderSession ::get_LanFtpURL(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "LanFtpURL: ","ftp://192.168.10.131:21"); } void RTSPServer::RTSPEncoderSession ::get_WanFtpURL(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "WanFtpURL: ","ftp://192.168.10.102:3011"); } void RTSPServer::RTSPEncoderSession ::get_LanVoiceAddr(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "LanVoiceAddr: ","192.168.10.131:8000"); } void RTSPServer::RTSPEncoderSession ::get_WanVoiceAddr(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "WanVoiceAddr: ","192.168.10.102:15400"); } void RTSPServer::RTSPEncoderSession ::get_LanDataAddr(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "LanDataAddr: ","192.168.10.131:8000"); } void RTSPServer::RTSPEncoderSession ::get_WanDataAddr(char *p, int p_len) { sprintf(p+p_len,"%s%s\r\n", "WanDataAddr: ","192.168.10.102:15401"); } void videoGetFrameInfo(unsigned char channel, void *handle, char* session_name, unsigned char *framebuf, int *framesize, int *videoType) { enum videotype {VIDEO_RAW, VIDEO_MPEG4, VIDEO_H264}; int width = 0, height = 0; FILE *fp = (FILE *)handle; int getFrameSize = *framesize; if (strcmp(session_name, "live") == 0) { width = 352; height = 288; } int n = fread(framebuf, 1, getFrameSize, fp); if (n != getFrameSize) { fseek(fp, SEEK_SET, 0); n = fread(framebuf, 1, getFrameSize, fp); if (n != getFrameSize) { Debug(ckite_log_message, "FATAL error: cannot read bytes from input file!\n"); return; } } *framesize = getFrameSize; *videoType = VIDEO_RAW; } void audioGetFrameInfo(void * handle, char* session_name, char *framebuf, int *framesize, int*audioType) { enum audiotype {AUDIO_RAW, AUDIO_AMRNB, AUDIO_AMRWB}; int getFrameSize = *framesize; FILE *fp = (FILE *)handle; int n = fread(framebuf, 1, getFrameSize, fp); if (n != getFrameSize) { fseek(fp, SEEK_SET, 0); n = fread(framebuf, 1, getFrameSize, fp); if (n != getFrameSize) { Debug(ckite_log_message, "FATAL error: cannot read bytes from input file!\n"); return; } } *framesize = getFrameSize; *audioType = AUDIO_RAW; } void getSubsessionParaConfig(char *session_name, int width, int height, unsigned int& video_bitrate, unsigned int& framerate, unsigned int& keyinterval, unsigned int& audio_bitrate, unsigned int& framelength, unsigned int& samplerate) { if ((strcmp(session_name, "live") == 0) && (width == 352) && (height == 288)) { video_bitrate = 120; framerate = 10; keyinterval = 5; } audio_bitrate = 5; framelength = 160; samplerate = 8000; }
[ [ [ 1, 286 ] ] ]
1f702b44b1d44964f4890a47162e6144c71306f3
81344a13313d27b6af140bc8c9b77c9c2e81fee2
/wjg/Services/Factory.cpp
5da69913693a0616b0d2b20663063662a0735a22
[]
no_license
radtek/aitop
169912e43a6d2bc4018219634d13dc786fa28a31
a2a89859d0d912b0844593972a2310798573219f
refs/heads/master
2021-01-01T03:57:19.378394
2008-06-17T16:03:19
2008-06-17T16:03:19
58,142,437
0
0
null
null
null
null
GB18030
C++
false
false
555
cpp
#include "stdafx.h" #include "factory.h" NumberService& CFactory::getNumberService() { return *inSer; } BlacklistService& CFactory::getBlacklistService() { return *inSer; } CFactory::CFactory() { inSer = NULL; } bool CFactory::Initial(const char* conStr) { if (inSer == NULL) { inSer = new Service; return inSer->Initial(conStr); } return true; //没必要初始化多次 } void CFactory::UnInitial() { if (inSer) { delete inSer; inSer = NULL; } } CFactory::~CFactory() { UnInitial(); }
[ [ [ 1, 42 ] ] ]
ed74d80197b6e8402042389ec9714887be9c6903
fbe2cbeb947664ba278ba30ce713810676a2c412
/iptv_root/iptv_kernel/include/iptv_kernel/PollCtcpMessage.h
a392f5890b233b926d95b12d66ca47c3fa4933a0
[]
no_license
abhipr1/multitv
0b3b863bfb61b83c30053b15688b070d4149ca0b
6a93bf9122ddbcc1971dead3ab3be8faea5e53d8
refs/heads/master
2020-12-24T15:13:44.511555
2009-06-04T17:11:02
2009-06-04T17:11:02
41,107,043
0
0
null
null
null
null
UTF-8
C++
false
false
2,461
h
#ifndef POLL_CTCP_MESSAGE_H #define POLL_CTCP_MESSAGE_H #include "VBLib/VBLib.h" #include "iptv_kernel/CtcpMessage.h" enum PollMessageCode { POLL_MESSAGE_CODE_BEGIN, POLL_MESSAGE_CODE_QUESTION, POLL_MESSAGE_CODE_OPTION, POLL_MESSAGE_CODE_END, POLL_MESSAGE_CODE_ANSWER, POLL_MESSAGE_CODE_STATS_BEGIN, POLL_MESSAGE_CODE_STATS_QUESTION, POLL_MESSAGE_CODE_STATS_OPTION, POLL_MESSAGE_CODE_STATS_END }; class PollCtcpMessage : public CtcpMessage { public: PollCtcpMessage(); PollCtcpMessage(br::com::sbVB::VBLib::VBString message); bool IsPollCtcpMessage() const; bool IsPollBegin() const; bool IsPollQuestion() const; bool IsPollOption() const; bool IsPollEnd() const; bool IsPollAnswer() const; bool IsPollStatsBegin() const; bool IsPollStatsQuestion() const; bool IsPollStatsOption() const; bool IsPollStatsEnd() const; br::com::sbVB::VBLib::VBString GetText() const; long GetOptionIndex() const; long GetAnswerCount() const; void SetText(br::com::sbVB::VBLib::VBString text); void SetOptionIndex(long optionId); void SetAnswerCount(long answerCount); void SetPollMessageCode(PollMessageCode code); br::com::sbVB::VBLib::VBString GetPollCtcpMessage() const; private: void ParseParameters(); void Reset(); br::com::sbVB::VBLib::VBString m_text; long m_optionIndex; long m_answerCount; bool m_isPollCtcp; bool m_isPollBegin; bool m_isPollQuestion; bool m_isPollOption; bool m_isPollEnd; bool m_isPollAnswer; bool m_isPollStatsBegin; bool m_isPollStatsQuestion; bool m_isPollStatsOption; bool m_isPollStatsEnd; static const int m_firstAnswerId; static const int m_noAnswerId; static const int m_noAnswerIndex; static const int m_answerCountFieldSize; static const br::com::sbVB::VBLib::VBString m_ctcpPollBegin; static const br::com::sbVB::VBLib::VBString m_ctcpPollQuestion; static const br::com::sbVB::VBLib::VBString m_ctcpPollOption; static const br::com::sbVB::VBLib::VBString m_ctcpPollEnd; static const br::com::sbVB::VBLib::VBString m_ctcpPollAnswer; static const br::com::sbVB::VBLib::VBString m_ctcpPollStatsBegin; static const br::com::sbVB::VBLib::VBString m_ctcpPollStatsQuestion; static const br::com::sbVB::VBLib::VBString m_ctcpPollStatsOption; static const br::com::sbVB::VBLib::VBString m_ctcpPollStatsOptionNoAnswer; static const br::com::sbVB::VBLib::VBString m_ctcpPollStatsEnd; }; #endif
[ "heineck@c016ff2c-3db2-11de-a81c-fde7d73ceb89" ]
[ [ [ 1, 85 ] ] ]
50514d1b0a3de75f8d74a4f8125117b15ad1281d
09c43e037d720e24e769ef9faa148f1377524c2c
/heroin/item.cpp
a2090f6ed7be3db30c6d7fded867c47cc030ece8
[]
no_license
goal/qqbot
bf63cf06e4976f16e2f0b8ec7c6cce88782bdf29
3a4b5920d5554cc55b6df962d27ebbc499c63474
refs/heads/master
2020-07-30T13:57:11.135976
2009-06-10T00:13:46
2009-06-10T00:13:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,045
cpp
#include <heroin/item.hpp> extern std::string const item_classification_strings[] = { "Helm", "Armor", "Shield", "Gloves", "Boots", "Belt", "Druid Pelt", "Barbarian Helm", "Paladin Shield", "Necromancer Shrunken Head", "Axe", "Mace", "Sword", "Dagger", "Throwing Weapon", "Javelin", "Spear", "Polearm", "Bow", "Crossbow", "Staff", "Wand", "Scepter", "Assassin Katar", "Sorceresss Orb", "Amazon Weapon", "Circlet", "Throwing Potion", "Quest Item", "Gem", "Rune", "Potion", "Charm", "Miscellaneous", "Jewel", "Amulet", "Gold", "Ring", "Ear" }; namespace item_code { extern std::string const gold = "gld"; } bool item_type::operator<(item_type const & other) const { return id < other.id; } item_property_type::item_property_type(): value(0), minimum(0), maximum(0), length(0), level(0), character_class(0), skill(0), tab(0), monster(0), charges(0), maximum_charges(0), skill_chance(0), per_level(0) { }
[ "akirarat@ba06997c-553f-11de-8ef9-cf35a3c3eb08" ]
[ [ [ 1, 78 ] ] ]
ec24e0dd94c9f9876a025c4bd4a63d37ab8420fb
335783c9e5837a1b626073d1288b492f9f6b057f
/source/fbxcmd/daolib/Model/Common/matrix33.cpp
5b4489395a0ffe71b575d4393c35a60f330f2226
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
code-google-com/fbx4eclipse
110766ee9760029d5017536847e9f3dc09e6ebd2
cc494db4261d7d636f8c4d0313db3953b781e295
refs/heads/master
2016-09-08T01:55:57.195874
2009-12-03T20:35:48
2009-12-03T20:35:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,760
cpp
/* Copyright (c) 2006, NIF File Format Library and Tools All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the NIF File Format Library and Tools project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "stdafx.h" #include "DAOFormat.h" #include "vector2f.h" #include "vector3f.h" #include "vector4f.h" #include "color4.h" #include "quaternion.h" #include "matrix33.h" const Matrix33 Matrix33::IDENTITY( 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f ); Matrix33::Matrix33() { *this = Matrix33::IDENTITY; } Matrix33::Matrix33( float m11, float m12, float m13 , float m21, float m22, float m23 , float m31, float m32, float m33 ) { m[0][0] = m11; m[0][1] = m12; m[0][2] = m13; m[1][0] = m21; m[1][1] = m22; m[1][2] = m23; m[2][0] = m31; m[2][1] = m32; m[2][2] = m33; } Quaternion Matrix33::AsQuaternion() { Quaternion quat; float tr, s, q[4]; int i, j, k; int nxt[3] = {1, 2, 0}; Matrix33 & m = *this; // compute the trace of the matrix tr = m[0][0] + m[1][1] + m[2][2]; // check if the trace is positive or negative if (tr > 0.0) { s = sqrt (tr + 1.0f); quat.w = s / 2.0f; s = 0.5f / s; quat.x = (m[1][2] - m[2][1]) * s; quat.y = (m[2][0] - m[0][2]) * s; quat.z = (m[0][1] - m[1][0]) * s; } else { // trace is negative i = 0; if ( m[1][1] > m[0][0]) i = 1; if ( m[2][2] > m[i][i] ) i = 2; j = nxt[i]; k = nxt[j]; s = sqrt( ( m[i][i] - (m[j][j] + m[k][k]) ) + 1.0f ); q[i] = s * 0.5f; if (s != 0.0f) s = 0.5f / s; q[3] = (m[j][k] - m[k][j]) * s; q[j] = (m[i][j] + m[j][i]) * s; q[k] = (m[i][k] + m[k][i]) * s; quat.x = q[0]; quat.y= q[1]; quat.z = q[2]; quat.w = q[3]; } return quat; } float Matrix33::Determinant() const { return (*this)[0][0] * ( (*this)[1][1] * (*this)[2][2] - (*this)[1][2] * (*this)[2][1] ) - (*this)[0][1] * ( (*this)[1][0] * (*this)[2][2] - (*this)[1][2] * (*this)[2][0] ) + (*this)[0][2] * ( (*this)[1][0] * (*this)[2][1] - (*this)[1][1] * (*this)[2][0] ); } Matrix33 Matrix33::operator*( const Matrix33 & m ) const { Matrix33 m3; for ( int r = 0; r < 3; r++ ){ for ( int c = 0; c < 3; c++ ){ m3[r][c] = (*this)[r][0]*m[0][c] + (*this)[r][1]*m[1][c] + (*this)[r][2]*m[2][c]; } } return m3; }
[ "tazpn314@ccf8930c-dfc1-11de-9043-17b7bd24f792" ]
[ [ [ 1, 124 ] ] ]
d3fed66bc5f87ad26c25158c2250bdb91693e059
4fdc157f7d6c5af784c3492909d848a0371e5877
/Vision/RobotVisionModule/Stereovision.hpp
0b996a1a1eaa092ec8606715baf7b002ed074cfa
[]
no_license
moumen19/robotiquecartemere
d969e50aedc53844bb7c512ff15e6812b8b469de
8333bb0b5c1b1396e1e99a870af2f60c9db149b0
refs/heads/master
2020-12-24T17:17:14.273869
2011-02-11T15:44:38
2011-02-11T15:44:38
34,446,411
0
0
null
null
null
null
UTF-8
C++
false
false
2,904
hpp
#ifndef STEREOVISION_H #define STEREOVISION_H #include <string> #include <iostream> #include <fstream> #include "Camera.hpp" #include <opencv/cv.h> // for previous functions #include <opencv2/highgui/highgui.hpp> // much of the define are in Camera.hpp #define CAMERA_MODE 0 #define VIDEO_FILE_MODE 1 using namespace std; class Stereovision { public: Stereovision(); virtual ~Stereovision(); // To implement virtual void Send(){;} // through Ethernet for instance void StereoCalibrate(); bool SaveMatrix(); bool LoadStereoMatrices(const string &filename); bool SetCameras(Camera & left, Camera & right); // Mandatory void Setup(int mode); void Run(); // empty for now, replaced by: // different video processing tools void RawDisplay(); void CannyEdgeDetection(); void FloodFilling(); // Seed has to be a parameter void BlobTracking(cv::Scalar colorToTrack); void test(); // not working private: // recurrent functions bool AcquireFrames(); bool GetUserInputs(char key); // features recording options, videos or images // different image processing tools with optional display cv::Mat Canny(cv::Mat image, bool settingsActivated); cv::Mat MorphologyEx(cv::Mat binaryImage, int operation, // mandatory const cv::Mat& element =cv::Mat(), cv::Point anchor =cv::Point(-1,-1), int iterations =1); cv::Mat ColorSegmentation(cv::Mat imageToSegment, cv::Scalar colorToFind, bool displaySettingsActivated);// better results with MorphologyEx cv::Mat FindContours(bool displaySettingsActivated){return cv::Mat();} // can be useful to implement, but works only on binary images ! // for corners detection/matching purpose (unused) void MatchCorners(); void crossCheckMatching( cv::Ptr<cv::DescriptorMatcher>& descriptorMatcher, const cv::Mat& descriptors1, const cv::Mat& descriptors2, vector<cv::DMatch>& filteredMatches12, int knn=1 ); protected: // core vision attributes Camera * m_LeftCamera; Camera * m_RightCamera; cv::Mat m_LeftFrame; cv::Mat m_RightFrame; // optional dynamic buffer vector<cv::Mat > m_LeftImageBuffer; vector<cv::Mat > m_RightImageBuffer; // stereo attributes cv::Mat m_rotationMatrix; cv::Mat m_translationMatrix; cv::Mat m_essentialMatrix; cv::Mat m_fundamentalMatrix; // recording attributes cv::VideoWriter m_LeftVideoWriter; cv::VideoWriter m_RightVideoWriter; bool m_videoBeingRecorded; int m_videoOutputCount; int m_imageOutputCount; }; #endif // STEREOVISION_H
[ "julien.delbergue@308fe9b9-b635-520e-12eb-2ef3f824b1b6", "[email protected]@308fe9b9-b635-520e-12eb-2ef3f824b1b6" ]
[ [ [ 1, 3 ], [ 5, 5 ], [ 8, 9 ], [ 11, 17 ], [ 19, 28 ], [ 30, 75 ], [ 81, 90 ] ], [ [ 4, 4 ], [ 6, 7 ], [ 10, 10 ], [ 18, 18 ], [ 29, 29 ], [ 76, 80 ] ] ]
138d5aeb1b87abc10cf20e241cb78c0c8cee78cf
5b0684d7d75207f8424bd4ece0fb29d355c8f28d
/bbDynamicTiling/src/bbDT_Manager.h
d3c7f6a8d44bab6fc5bc1c4c7918d554b4a3523c
[]
no_license
glittercutter/blackbox_plugin
e2a527788566e9afbd677baf90ed09ebeb971f0e
8351f4524be3187d54527e029c40c8c3df380d87
refs/heads/master
2021-03-19T07:13:41.903001
2011-12-19T20:39:32
2011-12-19T20:39:32
1,558,042
5
1
null
null
null
null
UTF-8
C++
false
false
3,057
h
/* bbDynamicTiling Copyright (C) 2011 Sebastien Raymond This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ #ifndef BBDT_MANAGER_H #define BBDT_MANAGER_H #include "bbDT_Common.h" class TilingManager { public: // constructor TilingManager(RCSetting* _rcSetting) : mCurrentWorkspace(0), mRCSetting(_rcSetting)//, mFullscreenWindow(0) { init(); } /// destructor ~TilingManager() { clear(); } void move(Direction dir, Target target); void focus(Direction dir, Target target); void focus(HWND hwnd); void expand(Direction dir); void resize(Direction dir); void toggleFullscreen(); void toggleFloating(); void addWindow(HWND hwnd, bool ignoreList = false); void removeWindow(HWND hwnd); void moveClient(Client* client, Direction dir = D_INVALID); void moveContainer(Container* container, Direction dir = D_INVALID); void updateWindow(HWND hwnd); void updateDesktopInfo(); Client* getClient(HWND hwnd); void updateClientWorkspace(Client* client); Client* getFocusedClient(); void setFocusedClient(Client* client); int getClientBorderSize() {return mRCSetting->clientBorderSize;} int getContainerBorderSize() {return mRCSetting->containerBorderSize;} int getColumnBorderSize() {return mRCSetting->columnBorderSize;} int getWorkspaceBorderSize() {return mRCSetting->workspaceBorderSize;} int getWorkspaceFullscreenBorderSize() {return mRCSetting->workspaceFullscreenBorderSize;} float getMinSizeFactor() {return mRCSetting->minSizeFactor;} void addMonitor(HMONITOR hM); void removeMonitor(HMONITOR hM); void updateMonitorInfo(); Monitor* getWorkspaceMonitor(int n); Monitor* getMonitor(int n); int getWorkspaceNumber(Workspace* workspace); void removeBorder(HWND hwnd); void addBorder(HWND hwnd); void clear(); void init(); void reset(); private: void readInclusionFile(); bool checkInclusionList(HWND hwnd); int getModuleName(HWND hwnd, char *buffer, int buffsize); void addWorkspace(int workspace); std::deque<Workspace*> mWorkspaces; Workspace* mCurrentWorkspace; std::unordered_map<HMONITOR, Monitor*> mMonitors; std::unordered_map<HWND, Client*> mClients; std::unordered_set<std::string> mInclusionList; RCSetting* mRCSetting; }; #endif
[ [ [ 1, 100 ] ] ]
457b1eda7205eb44f977b8914f0ae751d3565764
c2a70374051ef8f96105d65c84023d97c90f4806
/bin/src/loadBmp/common/Filter/plfiltergetalpha.cpp
ae965188643a304e25b18c2c2f6ce944896c471b
[]
no_license
haselab-net/SpringheadOne
dcf6f10cb1144b17790a782f519ae25cbe522bb2
004335b64ec7bea748ae65a85463c0e85b98edbd
refs/heads/master
2023-08-04T20:27:17.158435
2006-04-15T16:49:35
2006-04-15T16:49:35
407,701,182
1
0
null
null
null
null
UTF-8
C++
false
false
3,365
cpp
/* /-------------------------------------------------------------------- | | $Id: plfiltergetalpha.cpp,v 1.8 2004/06/15 10:26:13 uzadow Exp $ | | Copyright (c) 1996-2002 Ulrich von Zadow | \-------------------------------------------------------------------- */ #include "plstdpch.h" #include "plfiltergetalpha.h" #include "plbitmap.h" PLFilterGetAlpha::PLFilterGetAlpha() : PLFilter() { } PLFilterGetAlpha::~PLFilterGetAlpha() { } void PLFilterGetAlpha::Apply(PLBmpBase * pBmpSource, PLBmp * pBmpDest) const { // Only works for 32 bpp bitmaps. PLASSERT (pBmpSource->GetBitsPerPixel() == 32); PLASSERT (pBmpSource->HasAlpha()); pBmpDest->Create (pBmpSource->GetWidth(), pBmpSource->GetHeight(), 8, false, true, NULL, 0, pBmpSource->GetResolution()); PLPixel32 ** pSrcLines = pBmpSource->GetLineArray32(); PLBYTE ** pDstLines = pBmpDest->GetLineArray(); for (int y = 0; y<pBmpDest->GetHeight(); ++y) { // For each line PLPixel32 * pSrcPixel = pSrcLines[y]; PLBYTE * pDstPixel = pDstLines[y]; for (int x = 0; x < pBmpDest->GetWidth(); ++x) { // For each pixel *pDstPixel = pSrcPixel->GetA(); ++pSrcPixel; ++pDstPixel; } } } /* /-------------------------------------------------------------------- | | $Log: /Project/Springhead/bin/src/loadBmp/common/Filter/plfiltergetalpha.cpp $ * * 1 04/07/12 13:34 Hase | Revision 1.8 2004/06/15 10:26:13 uzadow | Initial nonfunctioning version of plbmpbase. | | Revision 1.7 2003/11/05 15:17:26 artcom | Added ability to specify initial data in PLBitmap::Create() | | Revision 1.6 2002/08/04 20:08:01 uzadow | Added PLBmpInfo class, ability to extract metainformation from images without loading the whole image and proper greyscale support. | | Revision 1.5 2002/03/31 13:36:42 uzadow | Updated copyright. | | Revision 1.4 2001/10/21 17:12:40 uzadow | Added PSD decoder beta, removed BPPWanted from all decoders, added PLFilterPixel. | | Revision 1.3 2001/10/16 17:12:26 uzadow | Added support for resolution information (Luca Piergentili) | | Revision 1.2 2001/10/06 22:37:08 uzadow | Linux compatibility. | | Revision 1.1 2001/09/16 19:03:23 uzadow | Added global name prefix PL, changed most filenames. | | Revision 1.7 2001/02/04 14:31:52 uzadow | Member initialization list cleanup (Erik Hoffmann). | | Revision 1.6 2001/01/15 15:05:31 uzadow | Added PLBmp::ApplyFilter() and PLBmp::CreateFilteredCopy() | | Revision 1.5 2000/12/18 22:42:53 uzadow | Replaced RGBAPIXEL with PLPixel32. | | Revision 1.4 2000/01/16 20:43:15 anonymous | Removed MFC dependencies | | Revision 1.3 1999/12/08 16:31:40 Ulrich von Zadow | Unix compatibility | | Revision 1.2 1999/10/21 18:48:03 Ulrich von Zadow | no message | | Revision 1.1 1999/10/21 16:05:17 Ulrich von Zadow | Moved filters to separate directory. Added Crop, Grayscale and | GetAlpha filters. | | Revision 1.1 1999/10/19 21:29:44 Ulrich von Zadow | Added filters. | | \-------------------------------------------------------------------- */
[ "jumius@05cee5c3-a2e9-0310-9523-9dfc2f93dbe1" ]
[ [ [ 1, 109 ] ] ]
5b6f644c251f977509e9fa6d738132cd6efc7d02
7f72fc855742261daf566d90e5280e10ca8033cf
/branches/full-calibration/ground/src/plugins/hitlnew/ui_hitloptionspage.h
4194fe5ad9b1abb0c58eb6d06378d71bf66010b2
[]
no_license
caichunyang2007/my_OpenPilot_mods
8e91f061dc209a38c9049bf6a1c80dfccb26cce4
0ca472f4da7da7d5f53aa688f632b1f5c6102671
refs/heads/master
2023-06-06T03:17:37.587838
2011-02-28T10:25:56
2011-02-28T10:25:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,401
h
/******************************************************************************** ** Form generated from reading UI file 'hitloptionspage.ui' ** ** Created: Wed 25. Aug 11:43:47 2010 ** by: Qt User Interface Compiler version 4.6.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_HITLOPTIONSPAGE_H #define UI_HITLOPTIONSPAGE_H #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QCheckBox> #include <QtGui/QComboBox> #include <QtGui/QFrame> #include <QtGui/QGridLayout> #include <QtGui/QHeaderView> #include <QtGui/QLabel> #include <QtGui/QLineEdit> #include <QtGui/QSpacerItem> #include <QtGui/QWidget> #include "utils/pathchooser.h" QT_BEGIN_NAMESPACE class Ui_HITLOptionsPage { public: QGridLayout *gridLayout; QLabel *label_3; QComboBox *chooseFlightSimulator; QFrame *line; QLabel *label_7; QLineEdit *latitude; QLabel *label_8; QLineEdit *longitude; QLabel *label; Utils::PathChooser *executablePath; QLabel *label_2; Utils::PathChooser *dataPath; QCheckBox *manualControl; QSpacerItem *verticalSpacer; QLabel *label_6; QLineEdit *hostAddress; QLineEdit *outputPort; QLabel *label_4; QLineEdit *inputPort; QLabel *label_5; void setupUi(QWidget *HITLOptionsPage) { if (HITLOptionsPage->objectName().isEmpty()) HITLOptionsPage->setObjectName(QString::fromUtf8("HITLOptionsPage")); HITLOptionsPage->resize(400, 320); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(HITLOptionsPage->sizePolicy().hasHeightForWidth()); HITLOptionsPage->setSizePolicy(sizePolicy); gridLayout = new QGridLayout(HITLOptionsPage); gridLayout->setContentsMargins(0, 0, 0, 0); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); label_3 = new QLabel(HITLOptionsPage); label_3->setObjectName(QString::fromUtf8("label_3")); gridLayout->addWidget(label_3, 1, 1, 1, 1); chooseFlightSimulator = new QComboBox(HITLOptionsPage); chooseFlightSimulator->setObjectName(QString::fromUtf8("chooseFlightSimulator")); gridLayout->addWidget(chooseFlightSimulator, 1, 2, 1, 3); line = new QFrame(HITLOptionsPage); line->setObjectName(QString::fromUtf8("line")); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); gridLayout->addWidget(line, 2, 1, 1, 4); label_7 = new QLabel(HITLOptionsPage); label_7->setObjectName(QString::fromUtf8("label_7")); gridLayout->addWidget(label_7, 5, 1, 1, 1); latitude = new QLineEdit(HITLOptionsPage); latitude->setObjectName(QString::fromUtf8("latitude")); gridLayout->addWidget(latitude, 5, 2, 1, 1); label_8 = new QLabel(HITLOptionsPage); label_8->setObjectName(QString::fromUtf8("label_8")); gridLayout->addWidget(label_8, 5, 3, 1, 1); longitude = new QLineEdit(HITLOptionsPage); longitude->setObjectName(QString::fromUtf8("longitude")); gridLayout->addWidget(longitude, 5, 4, 1, 1); label = new QLabel(HITLOptionsPage); label->setObjectName(QString::fromUtf8("label")); QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Fixed); sizePolicy1.setHorizontalStretch(0); sizePolicy1.setVerticalStretch(0); sizePolicy1.setHeightForWidth(label->sizePolicy().hasHeightForWidth()); label->setSizePolicy(sizePolicy1); gridLayout->addWidget(label, 6, 1, 1, 1); executablePath = new Utils::PathChooser(HITLOptionsPage); executablePath->setObjectName(QString::fromUtf8("executablePath")); QSizePolicy sizePolicy2(QSizePolicy::Preferred, QSizePolicy::Preferred); sizePolicy2.setHorizontalStretch(1); sizePolicy2.setVerticalStretch(0); sizePolicy2.setHeightForWidth(executablePath->sizePolicy().hasHeightForWidth()); executablePath->setSizePolicy(sizePolicy2); gridLayout->addWidget(executablePath, 6, 2, 1, 3); label_2 = new QLabel(HITLOptionsPage); label_2->setObjectName(QString::fromUtf8("label_2")); sizePolicy1.setHeightForWidth(label_2->sizePolicy().hasHeightForWidth()); label_2->setSizePolicy(sizePolicy1); gridLayout->addWidget(label_2, 7, 1, 1, 1); dataPath = new Utils::PathChooser(HITLOptionsPage); dataPath->setObjectName(QString::fromUtf8("dataPath")); gridLayout->addWidget(dataPath, 7, 2, 1, 3); manualControl = new QCheckBox(HITLOptionsPage); manualControl->setObjectName(QString::fromUtf8("manualControl")); sizePolicy1.setHeightForWidth(manualControl->sizePolicy().hasHeightForWidth()); manualControl->setSizePolicy(sizePolicy1); gridLayout->addWidget(manualControl, 8, 1, 1, 4); verticalSpacer = new QSpacerItem(20, 182, QSizePolicy::Minimum, QSizePolicy::Expanding); gridLayout->addItem(verticalSpacer, 11, 2, 1, 1); label_6 = new QLabel(HITLOptionsPage); label_6->setObjectName(QString::fromUtf8("label_6")); gridLayout->addWidget(label_6, 3, 1, 1, 1); hostAddress = new QLineEdit(HITLOptionsPage); hostAddress->setObjectName(QString::fromUtf8("hostAddress")); gridLayout->addWidget(hostAddress, 3, 2, 1, 1); outputPort = new QLineEdit(HITLOptionsPage); outputPort->setObjectName(QString::fromUtf8("outputPort")); gridLayout->addWidget(outputPort, 4, 4, 1, 1); label_4 = new QLabel(HITLOptionsPage); label_4->setObjectName(QString::fromUtf8("label_4")); gridLayout->addWidget(label_4, 4, 3, 1, 1); inputPort = new QLineEdit(HITLOptionsPage); inputPort->setObjectName(QString::fromUtf8("inputPort")); gridLayout->addWidget(inputPort, 4, 2, 1, 1); label_5 = new QLabel(HITLOptionsPage); label_5->setObjectName(QString::fromUtf8("label_5")); gridLayout->addWidget(label_5, 4, 1, 1, 1); retranslateUi(HITLOptionsPage); QMetaObject::connectSlotsByName(HITLOptionsPage); } // setupUi void retranslateUi(QWidget *HITLOptionsPage) { HITLOptionsPage->setWindowTitle(QApplication::translate("HITLOptionsPage", "Form", 0, QApplication::UnicodeUTF8)); label_3->setText(QApplication::translate("HITLOptionsPage", "Choose flight simulator:", 0, QApplication::UnicodeUTF8)); label_7->setText(QApplication::translate("HITLOptionsPage", "Latitude in degrees:", 0, QApplication::UnicodeUTF8)); label_8->setText(QApplication::translate("HITLOptionsPage", "Longitude in degrees:", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("HITLOptionsPage", "Path executable:", 0, QApplication::UnicodeUTF8)); label_2->setText(QApplication::translate("HITLOptionsPage", "Data directory:", 0, QApplication::UnicodeUTF8)); #ifndef QT_NO_TOOLTIP manualControl->setToolTip(QApplication::translate("HITLOptionsPage", "Manual aircraft control (can be used when hardware is not available)", 0, QApplication::UnicodeUTF8)); #endif // QT_NO_TOOLTIP manualControl->setText(QApplication::translate("HITLOptionsPage", "Manual aircraft control (can be used when hardware is not available)", 0, QApplication::UnicodeUTF8)); label_6->setText(QApplication::translate("HITLOptionsPage", "Host Address:", 0, QApplication::UnicodeUTF8)); label_4->setText(QApplication::translate("HITLOptionsPage", "Output Port:", 0, QApplication::UnicodeUTF8)); label_5->setText(QApplication::translate("HITLOptionsPage", "Input Port:", 0, QApplication::UnicodeUTF8)); } // retranslateUi }; namespace Ui { class HITLOptionsPage: public Ui_HITLOptionsPage {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_HITLOPTIONSPAGE_H
[ "jonathan@ebee16cc-31ac-478f-84a7-5cbb03baadba" ]
[ [ [ 1, 208 ] ] ]
361eb243955989341468bc174c1deb78767f408a
55196303f36aa20da255031a8f115b6af83e7d11
/include/bikini/system/video.hpp
a9ba53b67be11dd94aa12466a83ede05b88d22fe
[]
no_license
Heartbroken/bikini
3f5447647d39587ffe15a7ae5badab3300d2a2ff
fe74f51a3a5d281c671d303632ff38be84d23dd7
refs/heads/master
2021-01-10T19:48:40.851837
2010-05-25T19:58:52
2010-05-25T19:58:52
37,190,932
0
0
null
null
null
null
UTF-8
C++
false
false
14,886
hpp
/*---------------------------------------------------------------------------------------------*//* Binary Kinematics 3 - C++ Game Programming Library Copyright (C) 2008-2010 Viktor Reutskyy [email protected] *//*---------------------------------------------------------------------------------------------*/ #pragma once struct rc { }; struct video : device { /* rendering interface ----------------------------------------------------------------------*/ struct rendering { /* rendering commands -------------------------------------------------------------------*/ struct _command { uint extra; inline _command() : extra(0) {} }; struct create_schain : _command { uint ID; handle window; }; struct create_viewport : _command { uint ID; rect area; real2 depth; }; struct create_vformat : _command { uint ID; pointer data; }; struct create_vbuffer : _command { uint ID; uint size; }; struct write_vbuffer : _command { uint ID; bool reset; }; struct create_vshader : _command { uint ID; pointer data; uint size; }; struct create_pshader : _command { uint ID; pointer data; uint size; }; struct create_vbufset : _command { uint ID, vformat_ID, vbuffer_IDs[8], offsets[8], strides[8]; }; struct create_states : _command { uint ID; pointer data; }; struct create_consts : _command { uint ID; }; struct write_consts : _command { uint ID; bool reset; }; struct create_texture : _command { uint ID; sint2 size; uint format; }; struct write_texture : _command { uint ID; }; struct create_texset : _command { uint ID, texture_IDs[8]; }; struct destroy_resource : _command { uint ID; }; struct begin_scene : _command {}; struct clear_viewport : _command { uint target_ID, viewport_ID; struct { uint f; color c; real z; uint s; } clear; }; struct draw_primitive : _command { uint target_ID, viewport_ID, vbufset_ID, vshader_ID, pshader_ID, states_ID, consts_ID, texset_ID, type, start, size; }; struct end_scene : _command {}; struct present_schain : _command { uint ID; }; typedef make_typelist_< create_schain, create_viewport, create_vformat, create_vbuffer, write_vbuffer, create_vshader, create_pshader, create_vbufset, create_states, create_consts, write_consts, create_texture, write_texture, create_texset, destroy_resource, begin_scene, clear_viewport, draw_primitive, end_scene, present_schain >::type command_types; typedef variant_<command_types, false> command; typedef ring_<command> command_ring; typedef ring_<byte> data_ring; /* rendering issues ---------------------------------------------------------------------*/ struct validate_resource { uint ID; }; struct invalidate_resource { uint ID; }; typedef make_typelist_< validate_resource, invalidate_resource >::type issue_types; typedef variant_<issue_types> issue; typedef ring_<issue> issue_ring; /* rendering ----------------------------------------------------------------------------*/ video& get_video() const { return m_video; } rendering(video &_video); virtual ~rendering(); virtual bool initialize() = 0; virtual void finalize() = 0; virtual bool execute(const command &_command) = 0; protected: void set_valid(uint _ID); void set_invalid(uint _ID); bool get_data(handle _data, uint _size); void throw_data(uint _size); private: friend video; bool create(); void destroy(); video &m_video; thread::task m_task; bool m_run; void m_proc(); command_ring m_cbuffer; static const uint cbuffer_size = 1000; thread::flag m_has_command; bool add_command(const command &_command); data_ring m_dbuffer; static const uint dbuffer_size = 1024 * 1024 * 5; static const uint dbuffer_MTU = 1024; static const uint dbuffer_timeout = 1000; thread::flag m_can_read_data; thread::flag m_can_write_data; bool add_data(pointer _data, uint _size); issue_ring m_ibuffer; static const uint ibuffer_size = 1000; bool add_issue(const issue &_issue); issue get_issue(); }; /* video object -----------------------------------------------------------------------------*/ struct object : device::object { struct info : device::object::info { typedef video manager; info(uint _type); }; struct context; inline video& get_video() const { return static_cast<video&>(get_device()); } object(const info &_info, video &_video); protected: inline void add_command(const rendering::command &_command) const { get_video().add_command(_command); } inline void add_command(u64 _sort_key, const rendering::command &_command) const { get_video().add_command(_sort_key, _command); } inline void add_data(pointer _data, uint _size) const { get_video().add_data(_data, _size); } inline uint obtain_resource_ID() const { return get_video().obtain_resource_ID(); } inline void release_resource_ID(uint _ID) const { get_video().release_resource_ID(_ID); } inline bool resource_exists(uint _ID) const { return get_video().resource_exists(_ID); } inline bool resource_valid(uint _ID) const { return get_video().resource_valid(_ID); } }; struct ot { enum object_type { window, viewport, drawcall, vformat, vbuffer, memreader, vshader, pshader, vbufset, states, consts, texture, texset };}; /* video ------------------------------------------------------------------------------------*/ // texture formats struct tf { enum texture_format { a8, b8g8r8, a8b8g8r8, a8r8g8b8 };}; // vertex format struct vf { enum element_type { none, short2 }; struct element { const achar* semantic; uint index; element_type type; uint slot, offset; }; static const element last_element; }; video(); ~video(); bool create(); bool update(real _dt); void destroy(); private: rendering &m_rendering; rendering& new_rendering(video &_video); inline rendering& get_rendering() const { return m_rendering; } typedef rendering::command command; typedef std::multimap<u64, command> command_map; command_map m_cbuffer; inline void add_command(const command &_command); inline void add_command(u64 _sort_key, const command &_command); inline void add_data(pointer _data, uint _size); pool_<bool> m_resources; uint obtain_resource_ID(); void release_resource_ID(uint _ID); bool resource_exists(uint _ID); bool resource_valid(uint _ID); void set_resource_valid(uint _ID); void set_resource_invalid(uint _ID); }; namespace cf { enum clear_flags { color = 1<<0, depth = 1<<1, stencil = 1<<2, all = color|depth|stencil, };} namespace vo { /* video objects -----------------------------------------------------------------*/ /// texset struct texset : video::object { struct info : video::object::info { typedef texset object; info(); }; static const uint texture_count = 8; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } texset(const info &_info, video &_video); ~texset(); bool update(real _dt); void set_texture(uint _i, uint _ID); private: uint m_resource_ID; uint m_texture_IDs[texture_count]; }; /// texture struct texture : video::object { struct info : video::object::info { typedef texture object; uint format; sint2 size; uint levels; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } texture(const info &_info, video &_video); ~texture(); bool update(real _dt); void set_source(uint _ID); private: uint m_resource_ID; uint m_source_ID; }; /// consts struct consts : video::object { struct info : video::object::info { typedef consts object; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } consts(const info &_info, video &_video); ~consts(); bool update(real _dt); void write(uint _type, uint _offset, pointer _data, uint _size); template<typename _Type> inline void write(uint _type, uint _offset, const _Type &_v) { write(_type, _offset, &_v, sizeof(_v)); } private: uint m_resource_ID; byte_array m_data; }; /// states struct states : video::object { struct info : video::object::info { typedef states object; pointer data; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } states(const info &_info, video &_video); ~states(); bool update(real _dt); private: uint m_resource_ID; }; /// vbufset struct vbufset : video::object { struct info : video::object::info { typedef vbufset object; info(); }; static const uint vbuffer_count = 8; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } vbufset(const info &_info, video &_video); ~vbufset(); bool update(real _dt); void set_vformat(uint _ID); void set_vbuffer(uint _i, uint _ID, uint _offset, uint _stride); private: uint m_resource_ID; uint m_vformat_ID; uint m_vbuffer_IDs[vbuffer_count], m_offsets[vbuffer_count], m_strides[vbuffer_count]; }; /// pshader struct pshader : video::object { struct info : video::object::info { typedef pshader object; pointer data; uint size; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } pshader(const info &_info, video &_video); ~pshader(); bool update(real _dt); private: uint m_resource_ID; }; /// vshader struct vshader : video::object { struct info : video::object::info { typedef vshader object; pointer data; uint size; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } vshader(const info &_info, video &_video); ~vshader(); bool update(real _dt); private: uint m_resource_ID; }; /// memreader struct memreader : video::object { struct info : video::object::info { typedef memreader object; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline bool empty() const { return m_data.empty(); } inline uint size() const { return m_data.size(); } inline pointer data() const { return m_data.empty() ? 0 : &m_data[0]; } memreader(const info &_info, video &_video); ~memreader(); bool update(real _dt); void clear(); void write(pointer _data, uint _size); private: byte_array m_data; }; /// vbuffer struct vbuffer : video::object { struct info : video::object::info { typedef vbuffer object; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } vbuffer(const info &_info, video &_video); ~vbuffer(); bool update(real _dt); void set_source(uint _ID); private: uint m_resource_ID; uint m_source_ID; uint m_size; }; /// vformat struct vformat : video::object { struct info : video::object::info { typedef vformat object; pointer data; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } vformat(const info &_info, video &_video); ~vformat(); bool update(real _dt); private: uint m_resource_ID; }; /// drawcall struct drawcall : video::object { struct info : video::object::info { typedef drawcall object; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline void set_start(uint _start) { m_start = _start; } inline void set_size(uint _size) { m_size = _size; } drawcall(const info &_info, video &_video); ~drawcall(); bool update(real _dt); void set_vbufset(uint _ID); void set_shaders(uint _vshader_ID, uint _pshader_ID); void set_states(uint _ID); void write_consts(uint _type, uint _offset, pointer _data, uint _size); template<typename _Type> inline void write_consts(uint _type, uint _offset, const _Type &_v) { write_consts(_type, _offset, &_v, sizeof(_v)); } void set_texset(uint _ID); void add_commands(const context &_context) const; private: uint m_start, m_size; uint m_vbufset_ID; uint m_vshader_ID, m_pshader_ID; uint m_states_ID; consts::info m_consts; uint m_consts_ID; uint m_texset_ID; }; /// viewport struct viewport : video::object { struct info : video::object::info { typedef viewport object; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } inline const rect& area() const { return m_area; } inline void set_area(const rect &_r) { m_area = _r; } inline const real2& depth() const { return m_depth; } inline void set_depth(const real2 &_d) { m_depth = _d; } inline void set_clear_flags(uint _f) { m_clear.f = _f; } inline void set_clear_color(const color &_c) { m_clear.c = _c; } viewport(const info &_info, video &_video); ~viewport(); drawcall& add_drawcall(); void remove_drawcall(uint _i); uint drawcall_count() const; uint drawcall_ID(uint _i) const; void clear(); bool update(real _dt); void add_commands(const context &_context) const; private: uint m_resource_ID; rect m_area; real2 m_depth; struct { uint f; color c; } m_clear; drawcall::info m_drawcall; uint_array m_drawcalls; }; /// window struct window : video::object { struct info : video::object::info { typedef window object; typedef HWND a0; info(); }; inline const info& get_info() const { return get_info_<info>(); } inline uint resource_ID() const { return m_resource_ID; } window(const info &_info, video &_video, HWND _window); ~window(); bool reset(HWND _window); bool update(real _dt); uint add_viewport(); void remove_viewport(uint _i); uint viewport_count() const; uint viewport_ID(uint _i) const; void clear(); private: HWND m_window; uint m_resource_ID; static LRESULT _stdcall _wndproc(HWND _window, uint _message, uint _wparam, uint _lparam); static window *first_p; window *next_p; LRESULT m_wndproc(uint _message, uint _wparam, uint _lparam); WNDPROC m_oldwndproc; viewport::info m_viewport_info; uint_array m_viewports; enum { erase_background = (1<<0), force_redraw = (1<<1) }; uint m_flags; }; } /* video objects ------------------------------------------------------------------------------*/
[ "[email protected]", "viktor.reutskyy@68c2588f-494f-0410-aecb-65da31d84587" ]
[ [ [ 1, 3 ], [ 6, 10 ], [ 17, 23 ], [ 46, 47 ], [ 53, 54 ], [ 56, 56 ], [ 58, 58 ], [ 74, 83 ], [ 88, 96 ], [ 112, 123 ], [ 126, 130 ], [ 134, 139 ], [ 143, 146 ], [ 174, 184 ], [ 193, 208 ], [ 210, 210 ], [ 530, 530 ], [ 535, 538 ], [ 543, 544 ], [ 548, 548 ], [ 556, 557 ], [ 560, 560 ], [ 562, 562 ], [ 567, 568 ] ], [ [ 4, 5 ], [ 11, 16 ], [ 24, 45 ], [ 48, 52 ], [ 55, 55 ], [ 57, 57 ], [ 59, 73 ], [ 84, 87 ], [ 97, 111 ], [ 124, 125 ], [ 131, 133 ], [ 140, 142 ], [ 147, 173 ], [ 185, 192 ], [ 209, 209 ], [ 211, 529 ], [ 531, 534 ], [ 539, 542 ], [ 545, 547 ], [ 549, 555 ], [ 558, 559 ], [ 561, 561 ], [ 563, 566 ], [ 569, 569 ] ] ]
e1ae33b69c5dccf378eeac04b58fbe6709aee8dc
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/_Interface/WndLord.cpp
74aa7f0109f62a6df8d6a12cbecdf5d4c33713d0
[]
no_license
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UHC
C++
false
false
32,620
cpp
#include "stdafx.h" #include "resData.h" #include "WndLord.h" #include "DPClient.h" #include "defineText.h" #include "playerdata.h" #if __VER >= 12 // __LORD #include "definelordskill.h" #include "lord.h" extern CDPClient g_DPlay; /**************************************************** WndId : APP_LORD_STATE - 후보 등록 현황 CtrlId : WIDC_STATIC1 - Static CtrlId : WIDC_LISTBOX1 - Listbox CtrlId : WIDC_STATIC2 - Level CtrlId : WIDC_STATIC3 - Name CtrlId : WIDC_STATIC4 - Class CtrlId : WIDC_STATIC5 - Pledge CtrlId : WIDC_BUTTON1 - Button CtrlId : WIDC_STATIC6 - Static ****************************************************/ CWndLordState::CWndLordState() { m_tmRefresh = g_tmCurrent; m_pWndPledge = NULL; m_nSelect = 0; } CWndLordState::~CWndLordState() { SAFE_DELETE(m_pWndPledge); } void CWndLordState::OnDraw( C2DRender* p2DRender ) { CCElection* pElection = static_cast<CCElection*>( CCLord::Instance()->GetElection() ); CWndListBox* pWndListBox = (CWndListBox*)GetDlgItem( WIDC_LISTBOX1 ); //CString strClass, strName; LPWNDCTRL pCustom = NULL; DWORD dwColor; pCustom = GetWndCtrl( WIDC_LISTBOX1 ); dwColor = D3DCOLOR_ARGB( 255, 0, 0, 0 ); for(int i = 1; i < 11; ++i) { SPC pRanker = pElection->GetRanker(i); if(pRanker) { if(pRanker->GetIdPlayer() > 0) { if(!strName[i-1].IsEmpty()) p2DRender->TextOut( pCustom->rect.left + 15, pCustom->rect.top + 8 + (i-1)*16, strName[i-1], dwColor); if(!strClass[i-1].IsEmpty()) p2DRender->TextOut( pCustom->rect.left + 220, pCustom->rect.top + 8 + (i-1)*16, strClass[i-1], dwColor); p2DRender->TextOut( pCustom->rect.left + 313, pCustom->rect.top + 8 + (i-1)*16, "open", dwColor); if(pWndListBox && i == m_nSelect) { CRect rect; rect.left = pCustom->rect.left; rect.right = pCustom->rect.right - 4; rect.top = pCustom->rect.top + 6 + (i-1)*16; rect.bottom = rect.top + 16; D3DXCOLOR color = D3DCOLOR_ARGB( 60, 240, 0, 0 ); p2DRender->RenderFillRect( rect, color ); } } } } } BOOL CWndLordState::Process() { // 2초에 한번씩만 갱신한다 if(m_tmRefresh > g_tmCurrent) return FALSE; m_tmRefresh = g_tmCurrent + 1000; CCElection* pElection = static_cast<CCElection*>( CCLord::Instance()->GetElection() ); CWndListBox* pWndListBox = (CWndListBox*)GetDlgItem( WIDC_LISTBOX1 ); pWndListBox->ResetContent(); if(pElection->IsValid()) ((CWndStatic*)GetDlgItem( WIDC_LIVE ))->SetTitle(prj.GetText(TID_GAME_LORD_MINREQ_OK)); else ((CWndStatic*)GetDlgItem( WIDC_LIVE ))->SetTitle(prj.GetText(TID_GAME_LORD_MINREQ_NO)); for(int i = 1; i < 11; ++i) { SPC pRanker = pElection->GetRanker(i); if(pRanker) { if(pRanker->GetIdPlayer() > 0) { PlayerData* pPlayerData = CPlayerDataCenter::GetInstance()->GetPlayerData(pRanker->GetIdPlayer()); // 순위 if(i == 10) strName[i-1].Format(" %d %s", i, pPlayerData->szPlayer); else strName[i-1].Format(" %d %s", i, pPlayerData->szPlayer); strClass[i-1].Format("%s", prj.m_aJob[pPlayerData->data.nJob].szName); pWndListBox->AddString(" "); } } else { strName[i-1].Empty(); strClass[i-1].Empty(); } } return TRUE; } void CWndLordState::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); // 여기에 코딩하세요 // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } // 처음 이 함수를 부르면 윈도가 열린다. BOOL CWndLordState::Initialize( CWndBase* pWndParent, DWORD /*dwWndId*/ ) { // Daisy에서 설정한 리소스로 윈도를 연다. return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_STATE, 0, CPoint( 0, 0 ), pWndParent ); } /* 직접 윈도를 열때 사용 BOOL CWndLordState::Initialize( CWndBase* pWndParent, DWORD dwWndId ) { CRect rectWindow = m_pWndRoot->GetWindowRect(); CRect rect( 50 ,50, 300, 300 ); SetTitle( _T( "title" ) ); return CWndNeuz::Create( WBS_THICKFRAME | WBS_MOVE | WBS_SOUND | WBS_CAPTION, rect, pWndParent, dwWndId ); } */ BOOL CWndLordState::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordState::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } void CWndLordState::OnLButtonUp( UINT nFlags, CPoint point ) { } void CWndLordState::OnLButtonDown( UINT nFlags, CPoint point ) { } BOOL CWndLordState::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { switch(nID) { case WIDC_LISTBOX1: // view ctrl { CWndListBox* pWndListBox = (CWndListBox*)GetDlgItem( WIDC_LISTBOX1 ); SAFE_DELETE(m_pWndPledge); m_pWndPledge = new CWndLordPledge(pWndListBox->GetCurSel() + 1); m_pWndPledge->Initialize(this); m_nSelect = pWndListBox->GetCurSel() + 1; //m_pWndPledge->SetRanker(pWndListBox->GetCurSel() + 1); } break; case WIDC_BUTTON1:// ok버튼 Destroy(); break; } return CWndNeuz::OnChildNotify( message, nID, pLResult ); } // CWndLordPledge CWndLordPledge::CWndLordPledge() { m_bIsFirst = true; m_pWndConfirm = NULL; } CWndLordPledge::CWndLordPledge(int nRank) { m_bIsFirst = true; m_pWndConfirm = NULL; SetRanker(nRank); } CWndLordPledge::~CWndLordPledge() { } void CWndLordPledge::OnDraw( C2DRender* p2DRender ) { } void CWndLordPledge::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); // 여기에 코딩하세요 CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); pWndEdit->SetWndRect( pWndEdit->GetWindowRect( TRUE ), FALSE); pWndEdit->AddWndStyle( EBS_AUTOVSCROLL ); pWndEdit->AddWndStyle( EBS_WANTRETURN ); if(m_pRanker->GetPledge()) pWndText->SetString(m_pRanker->GetPledge()); // 에디터는 일단 숨긴다 pWndEdit->SetVisible(FALSE); // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } // 처음 이 함수를 부르면 윈도가 열린다. BOOL CWndLordPledge::Initialize( CWndBase* pWndParent, DWORD /*dwWndId*/ ) { // Daisy에서 설정한 리소스로 윈도를 연다. return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_PLEDGE, 0, CPoint( 0, 0 ), pWndParent ); } void CWndLordPledge::SetPledge(LPCTSTR strPledge) { CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); pWndText->SetString(strPledge); } /* 직접 윈도를 열때 사용 BOOL CWndLordState::Initialize( CWndBase* pWndParent, DWORD dwWndId ) { CRect rectWindow = m_pWndRoot->GetWindowRect(); CRect rect( 50 ,50, 300, 300 ); SetTitle( _T( "title" ) ); return CWndNeuz::Create( WBS_THICKFRAME | WBS_MOVE | WBS_SOUND | WBS_CAPTION, rect, pWndParent, dwWndId ); } */ BOOL CWndLordPledge::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { // 자기자신만 더블클릭으로 공약을 수정할 수 있다 if(dwMessage == WM_LBUTTONDBLCLK && nID == WIDC_TEXT1 && g_pPlayer->m_idPlayer == m_pRanker->GetIdPlayer()) { CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); if(pWndText->m_string.IsEmpty()) m_bIsFirst = true; else m_bIsFirst = false; pWndEdit->SetString(pWndText->m_string); pWndEdit->SetVisible(TRUE); pWndEdit->SetFocus(); pWndText->SetVisible(FALSE); } return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordPledge::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } void CWndLordPledge::OnLButtonUp( UINT nFlags, CPoint point ) { } void CWndLordPledge::OnLButtonDown( UINT nFlags, CPoint point ) { } BOOL CWndLordPledge::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { switch(nID) { // 공약을 전송한다 case WIDC_BUTTON2: CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); CString strTemp = pWndEdit->GetString(); if(strTemp.GetLength() > 255) { g_WndMng.OpenMessageBox(prj.GetText(TID_GUILD_NOTICE_ERROR)); return FALSE; } if(!m_bIsFirst) { //if(g_WndMng.OpenMessageBox( prj.GetText(TID_GAME_MOD_PLEGDE), MB_OKCANCEL, this) == MB_OK) //g_DPlay.SendElectionSetPledge(pWndEdit->GetString()); SAFE_DELETE(m_pWndConfirm); m_pWndConfirm = new CWndLordConfirm(pWndEdit->GetString()); m_pWndConfirm->Initialize(); } else { if(!((CEditString)pWndEdit->GetString()).IsEmpty()) { g_DPlay.SendElectionSetPledge(pWndEdit->GetString()); } Destroy(); } break; }; return CWndNeuz::OnChildNotify( message, nID, pLResult ); } BOOL CWndLordPledge::SetRanker(int nRank) { CCElection* pElection = static_cast<CCElection*>( CCLord::Instance()->GetElection() ); m_pRanker = pElection->GetRanker(nRank); if(m_pRanker) return TRUE; else return FALSE; } CWndLordTender::CWndLordTender() { } CWndLordTender::~CWndLordTender() { } void CWndLordTender::OnDraw( C2DRender* p2DRender ) { CCElection* pElection = static_cast<CCElection*>( CCLord::Instance()->GetElection() ); CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT2 ); CString strTemp, strResult; pWndText->ResetString(); for(int i = 1; i < (int)( pElection->GetCandidatesSize() + 1 ); ++i) { SPC pRanker = pElection->GetRanker(i); if(pRanker) { if(pRanker->GetIdPlayer() > 0) { PlayerData* pPlayerData = CPlayerDataCenter::GetInstance()->GetPlayerData(pRanker->GetIdPlayer()); if(pPlayerData->szPlayer) { if(i >= 10) strTemp.Format(" %d %s \n", i, pPlayerData->szPlayer); else strTemp.Format(" %d %s \n", i, pPlayerData->szPlayer); } else strTemp.Format(" %d %s \n", i, "...."); strResult.Insert(INT_MAX, strTemp); } } } pWndText->SetString(strResult); } void CWndLordTender::RefreshDeposit() { CCElection* pElection = static_cast<CCElection*>( CCLord::Instance()->GetElection() ); CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); for(int i = 0; i <= (int)( pElection->GetCandidatesSize() ); ++i) { SPC pRanker = pElection->GetRanker(i); if(pRanker) { if(pRanker->GetIdPlayer() == g_pPlayer->m_idPlayer) { CString strDeposit; strDeposit.Format("%I64d", pRanker->GetDeposit()); pWndEdit->SetString(strDeposit); } } } } void CWndLordTender::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); // 여기에 코딩하세요 CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); CScript scanner; if(scanner.Load( MakePath( DIR_CLIENT, _T( "lordcandidate.inc" ) ))) pWndText->SetString(scanner.m_pProg); CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); pWndEdit->SetString("0"); RefreshDeposit(); // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } // 처음 이 함수를 부르면 윈도가 열린다. BOOL CWndLordTender::Initialize( CWndBase* pWndParent, DWORD /*dwWndId*/ ) { // Daisy에서 설정한 리소스로 윈도를 연다. return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_TENDER, 0, CPoint( 0, 0 ), pWndParent ); } /* 직접 윈도를 열때 사용 BOOL CWndLordState::Initialize( CWndBase* pWndParent, DWORD dwWndId ) { CRect rectWindow = m_pWndRoot->GetWindowRect(); CRect rect( 50 ,50, 300, 300 ); SetTitle( _T( "title" ) ); return CWndNeuz::Create( WBS_THICKFRAME | WBS_MOVE | WBS_SOUND | WBS_CAPTION, rect, pWndParent, dwWndId ); } */ BOOL CWndLordTender::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordTender::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } void CWndLordTender::OnLButtonUp( UINT nFlags, CPoint point ) { } void CWndLordTender::OnLButtonDown( UINT nFlags, CPoint point ) { } BOOL CWndLordTender::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { if( nID == WIDC_BUTTON1 ) { if( g_pPlayer ) { CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); DWORD nCost; CString str = pWndEdit->GetString(); nCost = atol( str ); if( nCost >= 100000000) { g_DPlay.SendElectionAddDeposit(nCost); } else { g_WndMng.OpenMessageBox(prj.GetText(TID_UPGRADE_ERROR_NOMONEY)); } } } else if( nID == WIDC_BUTTON2 ) { Destroy(); } return CWndNeuz::OnChildNotify( message, nID, pLResult ); } CWndLordVote::CWndLordVote() { m_tmRefresh = g_tmCurrent; } CWndLordVote::~CWndLordVote() { } void CWndLordVote::OnDraw( C2DRender* p2DRender ) { CCElection* pElection = static_cast<CCElection*>( CCLord::Instance()->GetElection() ); CWndListBox* pWndListBox = (CWndListBox*)GetDlgItem( WIDC_LISTBOX1 ); CString strLevel, strName, strClass; LPWNDCTRL pCustom = NULL; DWORD dwColor; pCustom = GetWndCtrl( WIDC_LISTBOX1 ); dwColor = D3DCOLOR_ARGB( 255, 0, 0, 0 ); for(int i = 1; i < 11; ++i) { SPC pRanker = pElection->GetRanker(i); if(pRanker) { if(pRanker->GetIdPlayer() > 0) { PlayerData* pPlayerData = CPlayerDataCenter::GetInstance()->GetPlayerData(pRanker->GetIdPlayer()); // 레벨 strLevel.Format("%d", pPlayerData->data.nLevel); // 이름 strName.Format("%s", pPlayerData->szPlayer); // 클래스 strClass.Format("%s", prj.m_aJob[pPlayerData->data.nJob].szName); p2DRender->TextOut( pCustom->rect.left + 15, pCustom->rect.top + 8 + (i-1)*16, strLevel, dwColor); p2DRender->TextOut( pCustom->rect.left + 60, pCustom->rect.top + 8 + (i-1)*16, strName, dwColor); p2DRender->TextOut( pCustom->rect.left + 220, pCustom->rect.top + 8 + (i-1)*16, strClass, dwColor); } } } } BOOL CWndLordVote::Process() {/* // 2초에 한번씩만 갱신한다 if(m_tmRefresh > g_tmCurrent) return FALSE; m_tmRefresh = g_tmCurrent + 1000; */ return TRUE; } void CWndLordVote::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); // 여기에 코딩하세요 // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } // 처음 이 함수를 부르면 윈도가 열린다. BOOL CWndLordVote::Initialize( CWndBase* pWndParent, DWORD /*dwWndId*/ ) { // Daisy에서 설정한 리소스로 윈도를 연다. return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_VOTE, 0, CPoint( 0, 0 ), pWndParent ); } /* 직접 윈도를 열때 사용 BOOL CWndLordState::Initialize( CWndBase* pWndParent, DWORD dwWndId ) { CRect rectWindow = m_pWndRoot->GetWindowRect(); CRect rect( 50 ,50, 300, 300 ); SetTitle( _T( "title" ) ); return CWndNeuz::Create( WBS_THICKFRAME | WBS_MOVE | WBS_SOUND | WBS_CAPTION, rect, pWndParent, dwWndId ); } */ BOOL CWndLordVote::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordVote::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } void CWndLordVote::OnLButtonUp( UINT nFlags, CPoint point ) { } void CWndLordVote::OnLButtonDown( UINT nFlags, CPoint point ) { } BOOL CWndLordVote::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { CCElection* pElection = static_cast<CCElection*>( CCLord::Instance()->GetElection() ); CWndListBox* pWndListBox = (CWndListBox*)GetDlgItem( WIDC_LISTBOX1 ); CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); SPC pRanker = pElection->GetRanker(pWndListBox->GetCurSel() + 1); switch(nID) { case WIDC_LISTBOX1: /*// 리스트를 클릭하면 에디트박스에 이름이 올라간다 if(pRanker) { if(pRanker->GetIdPlayer() > 0) { PlayerData* pPlayerData = CPlayerDataCenter::GetInstance()->GetPlayerData(pRanker->GetIdPlayer()); CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); pWndEdit->SetString(pPlayerData->szPlayer); } }*/ break; case WIDC_BUTTON1: // 투표를 함 if(((CEditString)pWndEdit->GetString()).IsEmpty()) return FALSE; for(int i = 1; i < 11; ++i) { SPC pRanker = pElection->GetRanker(i); if(pRanker) { if(pRanker->GetIdPlayer() > 0) { PlayerData* pPlayerData = CPlayerDataCenter::GetInstance()->GetPlayerData(pRanker->GetIdPlayer()); CString strRanker(pPlayerData->szPlayer); if(((CEditString)pWndEdit->GetString()).Compare(strRanker) == 0) g_DPlay.SendElectionIncVote(pRanker->GetIdPlayer()); } } } // 이름이 일치하는 후보가 없음 // g_WndMng.OpenMessageBox(prj.GetText(TID_GAME_NO_CANDIDATE)); break; }; return CWndNeuz::OnChildNotify( message, nID, pLResult ); } // 이벤트 창 CWndLordEvent::CWndLordEvent() { m_nEEvent = 0; m_nDEvent = 0; } CWndLordEvent::~CWndLordEvent() { } BOOL CWndLordEvent::Initialize( CWndBase* pWndParent, DWORD nType) { if(!CCLord::Instance()->IsLord(g_pPlayer->m_idPlayer)) { g_WndMng.OpenMessageBox(prj.GetText(TID_GAME_L_EVENT_CREATE_E001)); Destroy(); return FALSE; } return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_EVENT, 0, CPoint( 0, 0 ), pWndParent ); } BOOL CWndLordEvent::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { switch(nID) { case WIDC_BUTTON1: if( --m_nEEvent < 0) m_nEEvent += CCLord::Instance()->GetEvent()->GetEFactorSize(); break; case WIDC_BUTTON2: m_nEEvent = ( m_nEEvent + 1 ) % CCLord::Instance()->GetEvent()->GetEFactorSize(); break; case WIDC_BUTTON3: if( --m_nDEvent < 0) m_nDEvent += CCLord::Instance()->GetEvent()->GetIFactorSize(); break; case WIDC_BUTTON4: m_nDEvent = ( m_nDEvent + 1 ) % CCLord::Instance()->GetEvent()->GetEFactorSize(); break; case WIDC_BUTTON5: if( !CCLord::Instance()->GetEvent()->GetComponent( g_pPlayer->m_idPlayer ) ) g_DPlay.SendLEventCreate(m_nEEvent, m_nDEvent); break; }; return CWndNeuz::OnChildNotify( message, nID, pLResult ); } void CWndLordEvent::OnDraw( C2DRender* p2DRender ) { CString strTemp; int nTemp = (int)(100 * CCLord::Instance()->GetEvent()->GetEFactor( m_nEEvent )); if((nTemp % 5) != 0) nTemp += 1; strTemp.Format(" %d %c", nTemp, '%'); CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); pWndText->SetString(strTemp); nTemp = (int)(100 * CCLord::Instance()->GetEvent()->GetIFactor( m_nDEvent )); if((nTemp % 5) != 0) nTemp += 1; strTemp.Format(" %d %c", nTemp, '%'); pWndText = (CWndText*)GetDlgItem( WIDC_TEXT2 ); pWndText->SetString(strTemp); __int64 iCost = CCLord::Instance()->GetEvent()->GetCost( m_nEEvent, m_nDEvent ); strTemp.Format("%I64d", iCost); pWndText = (CWndText*)GetDlgItem( WIDC_TEXT3 ); int nLength = strTemp.GetLength(); while(nLength - 3 > 0) { nLength -= 3; strTemp.Insert(nLength, ','); } pWndText->SetString(strTemp); } void CWndLordEvent::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); // 여기에 코딩하세요 // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } BOOL CWndLordEvent::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordEvent::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } void CWndLordEvent::OnLButtonUp( UINT nFlags, CPoint point ) { } void CWndLordEvent::OnLButtonDown( UINT nFlags, CPoint point ) { } // CWndLordSkill CWndLordSkill::CWndLordSkill() { m_bDrag = FALSE; m_nCurSelect = 0; for(int i = 0; i < 8; ++i) { m_aTexSkill[i] = NULL; m_aWndCtrl[i] = NULL; } } CWndLordSkill::~CWndLordSkill() { } BOOL CWndLordSkill::Initialize( CWndBase* pWndParent, DWORD nType) { if(!CCLord::Instance()->IsLord(g_pPlayer->m_idPlayer)) { g_WndMng.OpenMessageBox(prj.GetText(TID_GAME_L_EVENT_CREATE_E001)); Destroy(); return FALSE; } return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_SKILL, 0, CPoint( 0, 0 ), pWndParent ); } BOOL CWndLordSkill::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { return CWndNeuz::OnChildNotify( message, nID, pLResult ); } void CWndLordSkill::OnDraw( C2DRender* p2DRender ) { // 아이콘 렌더링 해야함 for(int i = 0; i < 8; ++i) { m_aTexSkill[ i ]->Render( p2DRender, m_aWndCtrl[i]->rect.TopLeft(), CPoint( 32, 32 ) ); } } void CWndLordSkill::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); // 여기에 코딩하세요 CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); pWndText->SetString(prj.GetText(TID_GAME_LORD_SKILL_INFO)); // 아이콘 텍스쳐 로딩 CCLord* pLord = CCLord::Instance(); for(int i = 0; i < 8; ++i) { CLordSkillComponentExecutable* pComponent = pLord->GetSkills()->GetSkill(i); m_aTexSkill[i] = pComponent->GetTexture(); } m_aWndCtrl[0] = GetWndCtrl( WIDC_CUSTOM1 ); m_aWndCtrl[1] = GetWndCtrl( WIDC_CUSTOM2 ); m_aWndCtrl[2] = GetWndCtrl( WIDC_CUSTOM3 ); m_aWndCtrl[3] = GetWndCtrl( WIDC_CUSTOM4 ); m_aWndCtrl[4] = GetWndCtrl( WIDC_CUSTOM5 ); m_aWndCtrl[5] = GetWndCtrl( WIDC_CUSTOM6 ); m_aWndCtrl[6] = GetWndCtrl( WIDC_CUSTOM7 ); m_aWndCtrl[7] = GetWndCtrl( WIDC_CUSTOM8 ); m_aWndCtrl[8] = GetWndCtrl( WIDC_CUSTOM9 ); // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } BOOL CWndLordSkill::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordSkill::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } void CWndLordSkill::OnLButtonUp( UINT nFlags, CPoint point ) { m_bDrag = FALSE; m_nCurSelect = 0; } void CWndLordSkill::OnLButtonDown( UINT nFlags, CPoint point ) { for(int i = 0; i < 8; ++i) { if(m_aWndCtrl[i]->rect.PtInRect( point ) ) { m_nCurSelect = i + 1; m_bDrag = TRUE; } } } void CWndLordSkill::OnMouseMove(UINT nFlags, CPoint point) { if( m_bDrag == FALSE ) return; if(m_nCurSelect) { CCLord* pLord = CCLord::Instance(); CLordSkillComponentExecutable* pComponent = pLord->GetSkills()->GetSkill(m_nCurSelect - 1); m_bDrag = FALSE; m_GlobalShortcut.m_pFromWnd = this; m_GlobalShortcut.m_dwShortcut = SHORTCUT_LORDSKILL; m_GlobalShortcut.m_dwType = 0; m_GlobalShortcut.m_dwIndex = 0;//dwSkill; m_GlobalShortcut.m_dwData = 0; m_GlobalShortcut.m_dwId = m_nCurSelect; // 컬런트 셀렉트가 곧 ID나 마찬가지임. m_GlobalShortcut.m_pTexture = pComponent->GetTexture(); _tcscpy( m_GlobalShortcut.m_szString, pComponent->GetName()); } } void CWndLordSkill::OnMouseWndSurface( CPoint point ) { for(int i = 0; i < 8; ++i) { if(m_aWndCtrl[i]->rect.PtInRect( point ) ) { CCLord* pLord = CCLord::Instance(); CLordSkillComponentExecutable* pComponent = pLord->GetSkills()->GetSkill(i); CRect rect = m_aWndCtrl[i]->rect; CPoint point2 = point; ClientToScreen( &point2 ); ClientToScreen( &rect ); CString string; CEditString strEdit; string.Format( "#b#cff2fbe6d%s#nb#nc \n%s", pComponent->GetName(), pComponent->GetDesc()); strEdit.SetParsingString( string ); g_toolTip.PutToolTip(i, strEdit, &rect, point2, 0 ); } } } // CWndLordConfirm BOOL CWndLordConfirm::Initialize( CWndBase* pWndParent, DWORD nType) { return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_CONFIRM, 0, CPoint( 0, 0 ), pWndParent ); } BOOL CWndLordConfirm::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { switch(nID) { case WIDC_BUTTON1: if(!m_pPledge.IsEmpty()) { g_DPlay.SendElectionSetPledge(m_pPledge); SetVisible(FALSE); if(g_WndMng.m_pWndLordState) { if(g_WndMng.m_pWndLordState->m_pWndPledge) g_WndMng.m_pWndLordState->m_pWndPledge->Destroy(); } } break; case WIDC_BUTTON2: SetVisible(FALSE); break; } return CWndNeuz::OnChildNotify( message, nID, pLResult ); } void CWndLordConfirm::OnDraw( C2DRender* p2DRender ) { } void CWndLordConfirm::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); pWndText->SetString(prj.GetText(TID_GAME_MOD_PLEGDE)); // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } BOOL CWndLordConfirm::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordConfirm::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } void CWndLordConfirm::OnLButtonUp( UINT nFlags, CPoint point ) { } void CWndLordConfirm::OnLButtonDown( UINT nFlags, CPoint point ) { } // CWndLordSkillConfirm BOOL CWndLordSkillConfirm::Initialize( CWndBase* pWndParent, DWORD nType) { return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_SKILL_CONFIRM, 0, CPoint( 0, 0 ), pWndParent ); } BOOL CWndLordSkillConfirm::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); switch(nID) { case WIDC_BUTTON1: if(pWndEdit->GetString() && m_nType != 0) { g_DPlay.SendLordSkillUse(m_nType, pWndEdit->GetString()); Destroy(); } break; }; return CWndNeuz::OnChildNotify( message, nID, pLResult ); } void CWndLordSkillConfirm::OnDraw( C2DRender* p2DRender ) { } void CWndLordSkillConfirm::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); CWndEdit* pWndEdit = (CWndEdit*)GetDlgItem( WIDC_EDIT1 ); switch(m_nType) { case LI_SUMMON: pWndText->SetString(prj.GetText(TID_GAME_LORD_SKILL_CONFIRM1)); pWndEdit->SetToolTip(prj.GetText(TID_TIP_LORD_SKILL_CONFIRM1)); break; case LI_TELEPORT: pWndText->SetString(prj.GetText(TID_GAME_LORD_SKILL_CONFIRM2)); pWndEdit->SetToolTip(prj.GetText(TID_TIP_LORD_SKILL_CONFIRM2)); break; }; // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } BOOL CWndLordSkillConfirm::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordSkillConfirm::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } // CWndLordInfo BOOL CWndLordInfo::Initialize( CWndBase* pWndParent, DWORD nType) { return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_INFO, 0, CPoint( 0, 0 ), pWndParent ); } BOOL CWndLordInfo::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { switch(nID) { case WIDC_BUTTON1: Destroy(); break; }; return CWndNeuz::OnChildNotify( message, nID, pLResult ); } void CWndLordInfo::OnDraw( C2DRender* p2DRender ) { CCElection* pElection = static_cast<CCElection*>( CCLord::Instance()->GetElection() ); CCLord* pLord = CCLord::Instance(); int nLordId = pLord->Get(); CWndStatic* pWndStatus = (CWndStatic*)GetDlgItem( WIDC_STATIC4 ); CWndStatic* pWndName = (CWndStatic*)GetDlgItem( WIDC_STATIC5 ); CWndStatic* pWndremainTime = (CWndStatic*)GetDlgItem( WIDC_STATIC6 ); if(nLordId != NULL_ID) { // 군주가 있을때 PlayerData* pPlayerData = CPlayerDataCenter::GetInstance()->GetPlayerData(nLordId); pWndName->SetTitle(pPlayerData->szPlayer); if(pElection->GetRestTimeEndVote() >= 0) { CTimeSpan ts(pElection->GetRestTimeEndVote()); CString strTime; strTime.Format( prj.GetText( TID_TOOLTIP_DATE ), static_cast<int>(ts.GetDays()), ts.GetHours(), ts.GetMinutes(), ts.GetSeconds()); pWndremainTime->SetTitle(strTime); } } else { pWndName->SetTitle(""); pWndremainTime->SetTitle(""); } // 현 상태를 표시해준다. if(pElection->GetState() == CCElection::eReady) { if(nLordId != NULL_ID) { // 군주가 있을때 pWndStatus->SetTitle(prj.GetText(TID_GAME_LORD_STATUS_IS)); } else { pWndStatus->SetTitle(prj.GetText(TID_GAME_LORD_STATUS_VA)); } } else if(pElection->GetState() == CCElection::eCandidacy) { // 입후보 기간 pWndStatus->SetTitle(prj.GetText(TID_GAME_LORD_STATUS_L1)); } else if(pElection->GetState() == CCElection::eVote) { // 투표 기간 pWndStatus->SetTitle(prj.GetText(TID_GAME_LORD_STATUS_L2)); } else if(pElection->GetState() == CCElection::eExpired) { // 군주가 없을때 pWndStatus->SetTitle(prj.GetText(TID_GAME_LORD_STATUS_VA)); } // TID_GAME_LORD_STATUS_L1 - 입후보 기간 // TID_GAME_LORD_STATUS_L2 // TID_GAME_LORD_STATUS_IS // TID_GAME_LORD_STATUS_VA } void CWndLordInfo::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); CScript scanner; if(scanner.Load( MakePath( DIR_CLIENT, _T( "lordInfo.inc" ) ))) pWndText->SetString(scanner.m_pProg); // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } BOOL CWndLordInfo::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordInfo::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } // CWndLordRPInfo BOOL CWndLordRPInfo::Initialize( CWndBase* pWndParent, DWORD nType) { return CWndNeuz::InitDialog( g_Neuz.GetSafeHwnd(), APP_LORD_INFO2, 0, CPoint( 0, 0 ), pWndParent ); } BOOL CWndLordRPInfo::OnChildNotify( UINT message, UINT nID, LRESULT* pLResult ) { switch(nID) { case WIDC_BUTTON1: Destroy(); break; }; return CWndNeuz::OnChildNotify( message, nID, pLResult ); } void CWndLordRPInfo::OnDraw( C2DRender* p2DRender ) { } void CWndLordRPInfo::OnInitialUpdate() { CWndNeuz::OnInitialUpdate(); CWndText* pWndText = (CWndText*)GetDlgItem( WIDC_TEXT1 ); CScript scanner; if(scanner.Load( MakePath( DIR_CLIENT, _T( "lordrpInfo.inc" ) ))) pWndText->SetString(scanner.m_pProg); // 윈도를 중앙으로 옮기는 부분. CRect rectRoot = m_pWndRoot->GetLayoutRect(); CRect rectWindow = GetWindowRect(); CPoint point( rectRoot.right - rectWindow.Width(), 110 ); Move( point ); MoveParentCenter(); } BOOL CWndLordRPInfo::OnCommand( UINT nID, DWORD dwMessage, CWndBase* pWndBase ) { return CWndNeuz::OnCommand( nID, dwMessage, pWndBase ); } void CWndLordRPInfo::OnSize( UINT nType, int cx, int cy ) { CWndNeuz::OnSize( nType, cx, cy ); } #endif
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 1168 ] ] ]
26a0c818babf6b0bc6516e051616be8057ba8a95
e1d62199b5ea4b73cacdcca510e2a14b8819dee8
/engUpdater/复件 engUpdater.cpp
e90ce66a4bde0ca8a1d8825af5f3d152a812390c
[]
no_license
fengzhang2011/fogaway
87bc6b0b94e73d049a8d03587bf3ddeccf804da3
721967de35c6b939816c93f383eb5b6a98f7d927
refs/heads/master
2021-01-10T12:12:29.742867
2009-02-16T05:55:03
2009-02-16T05:55:03
36,029,304
0
0
null
null
null
null
UTF-8
C++
false
false
12,502
cpp
#ifndef _WIN32_WINNT #define _WIN32_WINNT (0x0501) #endif #include <winsock2.h> #include <ws2tcpip.h> #include <fstream> #include <iostream> #include <cstdlib> #include <cstring> #include <windows.h> #include "pthread.h" #include "udt.h" #include "ZFUDTWrapper.h" using namespace std; using namespace UDT; void* recvdata(void* usocket) { UDTSOCKET recver = *(UDTSOCKET*)usocket; delete (UDTSOCKET*)usocket; char* data; int size = 100000; data = new char[size]; while (true) { int rsize = 0; int rs; while (rsize < size) { if (UDTERROR == (rs = UDTrecv(recver, data + rsize, size - rsize, 0))) { cout << "recv:" << getUDTLastErrorMessage() << endl; break; } rsize += rs; } if (rsize < size) break; } delete [] data; UDTclose(recver); return NULL; } int testServer() { // use this function to initialize the UDT library UDT::startup(); addrinfo hints; addrinfo* res; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; // hints.ai_socktype = SOCK_DGRAM; string service("9000"); if (0 != getaddrinfo(NULL, service.c_str(), &hints, &res)) { cout << "illegal port number or port is busy.\n" << endl; return 0; } UDTSOCKET serv = UDTsocket(res->ai_family, res->ai_socktype, res->ai_protocol); // UDT Options //UDT::setsockopt(serv, 0, UDT_CC, new CCCFactory<CUDPBlast>, sizeof(CCCFactory<CUDPBlast>)); //UDT::setsockopt(serv, 0, UDT_MSS, new int(9000), sizeof(int)); //UDT::setsockopt(serv, 0, UDT_RCVBUF, new int(10000000), sizeof(int)); //UDT::setsockopt(serv, 0, UDP_RCVBUF, new int(10000000), sizeof(int)); if(UDTERROR == UDTbind3(serv, res->ai_addr, res->ai_addrlen)) { cout << "bind: " << getUDTLastErrorMessage(); return 0; } freeaddrinfo(res); cout << "server is ready at port: " << service << endl; if (UDTERROR == UDTlisten(serv, 10)) { cout << "listen: " << getUDTLastErrorMessage() << endl; return 0; } sockaddr_storage clientaddr; int addrlen = sizeof(clientaddr); UDTSOCKET recver; while (true) { if (UDTINVALID_SOCK == (recver = UDTaccept(serv, (sockaddr*)&clientaddr, &addrlen))) { cout << "accept: " << getUDTLastErrorMessage() << endl; return 0; } char clienthost[NI_MAXHOST]; char clientservice[NI_MAXSERV]; getnameinfo((sockaddr *)&clientaddr, addrlen, clienthost, sizeof(clienthost), clientservice, sizeof(clientservice), NI_NUMERICHOST|NI_NUMERICSERV); cout << "new connection: " << clienthost << ":" << clientservice << endl; pthread_t rcvthread; pthread_create(&rcvthread, NULL, recvdata, new UDTSOCKET(recver)); pthread_detach(rcvthread); } UDTclose(serv); // use this function to release the UDT library UDTcleanup(); return 1; } void* monitor(void* s) { UDTSOCKET u = *(UDTSOCKET*)s; UDT::TRACEINFO perf; cout << "SendRate(Mb/s)\tRTT(ms)\tCWnd\tPktSndPeriod(us)\tRecvACK\tRecvNAK" << endl; while (true) { Sleep(1); if(UDTERROR == UDTperfmon(u, &perf, true)) { cout << "perfmon: " << getUDTLastErrorMessage() << endl; break; } cout << perf.mbpsSendRate << "\t\t" << perf.msRTT << "\t" << perf.pktCongestionWindow << "\t" << perf.usPktSndPeriod << "\t\t\t" << perf.pktRecvACK << "\t" << perf.pktRecvNAK << endl; } return NULL; } int testClient() { // use this function to initialize the UDT library UDTstartup(); struct addrinfo hints, *local, *peer; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; // hints.ai_socktype = SOCK_DGRAM; string serverIp("127.0.0.1"); string serverPort("9000"); if (0 != getaddrinfo(NULL, serverPort.c_str(), &hints, &local)) { cout << "incorrect network address.\n" << endl; return 0; } UDTSOCKET client = UDTsocket(local->ai_family, local->ai_socktype, local->ai_protocol); // UDT Options //UDT::setsockopt(client, 0, UDT_CC, new CCCFactory<CUDPBlast>, sizeof(CCCFactory<CUDPBlast>)); //UDT::setsockopt(client, 0, UDT_MSS, new int(9000), sizeof(int)); //UDT::setsockopt(client, 0, UDT_SNDBUF, new int(10000000), sizeof(int)); //UDT::setsockopt(client, 0, UDT_SNDBUF, new int(10000000), sizeof(int)); UDTsetsockopt(client, 0, UDT_MSS, new int(1052), sizeof(int)); // for rendezvous connection, enable the code below /* UDT::setsockopt(client, 0, UDT_RENDEZVOUS, new bool(true), sizeof(bool)); if (UDT::ERROR == UDT::bind(client, local->ai_addr, local->ai_addrlen)) { cout << "bind: " << getUDTLastErrorMessage() << endl; return 0; } */ freeaddrinfo(local); if (0 != getaddrinfo(serverIp.c_str(), serverPort.c_str(), &hints, &peer)) { cout << "incorrect server/peer address. " << serverIp.c_str() << ":" << serverPort.c_str() << endl; return 0; } // connect to the server, implict bind if (UDTERROR == UDTconnect(client, peer->ai_addr, peer->ai_addrlen)) { cout << "connect: " << getUDTLastErrorMessage() << endl; return 0; } freeaddrinfo(peer); // using CC method //CUDPBlast* cchandle = NULL; //int temp; //UDT::getsockopt(client, 0, UDT_CC, &cchandle, &temp); //if (NULL != cchandle) // cchandle->setRate(500); int size = 100000; char* data = new char[size]; pthread_create(new pthread_t, NULL, monitor, &client); for (int i = 0; i < 1000000; i ++) { int ssize = 0; int ss; while (ssize < size) { if (UDTERROR == (ss = UDTsend(client, data + ssize, size - ssize, 0))) { cout << "send:" << getUDTLastErrorMessage() << endl; break; } ssize += ss; } if (ssize < size) break; } UDTclose(client); delete [] data; // use this function to release the UDT library UDTcleanup(); return 1; } int startZFServer(string servicePort) { UDTSOCKET server; // use this function to initialize the UDT library UDTstartup(); addrinfo hints; addrinfo* res; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; // hints.ai_socktype = SOCK_DGRAM; if (0 != getaddrinfo(NULL, servicePort.c_str(), &hints, &res)) { cout << "illegal port number or port is busy.\n" << endl; return 0; } server = UDTsocket(res->ai_family, res->ai_socktype, res->ai_protocol); // UDT Options //UDT::setsockopt(server, 0, UDT_CC, new CCCFactory<CUDPBlast>, sizeof(CCCFactory<CUDPBlast>)); //UDT::setsockopt(server, 0, UDT_MSS, new int(9000), sizeof(int)); //UDT::setsockopt(server, 0, UDT_RCVBUF, new int(10000000), sizeof(int)); //UDT::setsockopt(server, 0, UDP_RCVBUF, new int(10000000), sizeof(int)); if(UDTERROR == UDTbind3(server, res->ai_addr, res->ai_addrlen)) { cout << "bind: " << getUDTLastErrorMessage(); return 0; } freeaddrinfo(res); cout << "server is ready at port: " << servicePort << endl; if (UDTERROR == UDTlisten(server, 10)) { cout << "listen: " << getUDTLastErrorMessage() << endl; return 0; } return server; } void stopZFServer(UDTSOCKET server) { UDTclose(server); // use this function to release the UDT library UDTcleanup(); } int startZFClient(string serverIp, string serverPort) { UDTSOCKET client; // use this function to initialize the UDT library UDTstartup(); struct addrinfo hints, *local, *peer; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_flags = AI_PASSIVE; hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; // hints.ai_socktype = SOCK_DGRAM; if (0 != getaddrinfo(NULL, serverPort.c_str(), &hints, &local)) { cout << "incorrect network address.\n" << endl; return 0; } client = UDTsocket(local->ai_family, local->ai_socktype, local->ai_protocol); // UDT Options //UDT::setsockopt(client, 0, UDT_CC, new CCCFactory<CUDPBlast>, sizeof(CCCFactory<CUDPBlast>)); //UDT::setsockopt(client, 0, UDT_MSS, new int(9000), sizeof(int)); //UDT::setsockopt(client, 0, UDT_SNDBUF, new int(10000000), sizeof(int)); //UDT::setsockopt(client, 0, UDT_SNDBUF, new int(10000000), sizeof(int)); UDTsetsockopt(client, 0, UDT_MSS, new int(1052), sizeof(int)); // for rendezvous connection, enable the code below /* UDT::setsockopt(client, 0, UDT_RENDEZVOUS, new bool(true), sizeof(bool)); if (UDT::ERROR == UDT::bind(client, local->ai_addr, local->ai_addrlen)) { cout << "bind: " << getUDTLastErrorMessage() << endl; return 0; } */ freeaddrinfo(local); if (0 != getaddrinfo(serverIp.c_str(), serverPort.c_str(), &hints, &peer)) { cout << "incorrect server/peer address. " << serverIp.c_str() << ":" << serverPort.c_str() << endl; return 0; } // connect to the server, implict bind if (UDTERROR == UDTconnect(client, peer->ai_addr, peer->ai_addrlen)) { cout << "connect: " << getUDTLastErrorMessage() << endl; return 0; } freeaddrinfo(peer); return client; } void stopZFClient(UDTSOCKET client) { UDTclose(client); // use this function to release the UDT library UDTcleanup(); } void fengTestServer() { UDTSOCKET server = startZFServer("9000"); sockaddr_in their_addr; int namelen = sizeof(their_addr); UDTSOCKET fhandle; if(UDTINVALID_SOCK == (fhandle = UDTaccept(server, (sockaddr*)&their_addr, &namelen))) { cout << "accept: " << getUDTLastErrorMessage() << endl; return; } // aquiring file name information from client char file[1024]; int len; if (UDTERROR == UDTrecv(fhandle, (char*)&len, sizeof(int), 0)) { cout << "recv: " << getUDTLastErrorMessage() << endl; return; } if (UDTERROR == UDTrecv(fhandle, file, len, 0)) { cout << "recv: " << getUDTLastErrorMessage() << endl; return; } file[len] = '\0'; // open the file ifstream ifs(file, ios::in | ios::binary); printf("%d:%s\n", len, file); ifs.seekg(0, ios::end); streampos size = ifs.tellg(); ifs.seekg(0, ios::beg); // printf("1size=%d\n", size); // send file size information if (UDTERROR == UDTsend(fhandle, (char*)&size, sizeof(int64_t), 0)) { cout << "send: " << getUDTLastErrorMessage() << endl; return; } UDT::TRACEINFO trace; UDTperfmon(fhandle, &trace, true); int64_t offset = 0; // send the file if (UDTERROR == UDTsendfile(fhandle, ifs, offset, size, 1024)) { cout << "sendfile: " << getUDTLastErrorMessage() << endl; ifs.seekg(0, ios::beg); // printf("2size=%d\n", size); return; } UDTperfmon(fhandle, &trace, true); cout << "speed = " << trace.mbpsSendRate << "Mbits/sec" << endl; ifs.close(); UDTclose(fhandle); stopZFServer(server); } void fengTestClient() { UDTSOCKET client = startZFClient("127.0.0.1", "9000"); const char* filename = "fengTest.cpp"; // send name information of the requested file int len = strlen(filename); if (UDTERROR == UDTsend(client, (char*)&len, sizeof(int), 0)) { cout << "send: " << getUDTLastErrorMessage() << endl; return; } if (UDTERROR == UDTsend(client, filename, len, 0)) { cout << "send: " << getUDTLastErrorMessage() << endl; return; } // get size information int64_t size; if (UDTERROR == UDTrecv(client, (char*)&size, sizeof(int64_t), 0)) { cout << "send: " << getUDTLastErrorMessage() << endl; return; } printf("file size=%d\n", size); // receive the file ofstream ofs("recvFengTest.cpp", ios::out | ios::binary | ios::trunc); int64_t recvsize; int64_t offset = 0; if (UDTERROR == (recvsize = UDTrecvfile(client, ofs, offset, size, 7280000))) { cout << "recvfile: " << getUDTLastErrorMessage() << endl; return; } ofs.close(); stopZFClient(client); } int main(int argc, char* argv[]) { initializeUDTFunctions(); if(argc!=2) { printf("Usage: engUpdater.exe option\nwhere option should be 's' or 'c'\n"); return 0; } // printf("argv0: %s\n", argv[0]); // printf("argv1: %s\n", argv[1]); if(argv[1][0]=='s') { // testServer(); fengTestServer(); } else if(argv[1][0]=='c') { // testClient(); fengTestClient(); } else { printf("Usage: engUpdater.exe option\nwhere option should be 's' or 'c'\n"); return 0; } uninitializeUDTFunctions(); return 1; }
[ "zhjinf@c860eead-fd34-0410-a5c5-473c129ab7d6" ]
[ [ [ 1, 535 ] ] ]
1afcae140b26449d29cc90174750858de4795e6c
f9774f8f3c727a0e03c170089096d0118198145e
/传奇mod/Mir2ExCode/Mir2/GameProcess/Actor.cpp
f7d9446c828168b66be40017861d11be2756246e
[]
no_license
sdfwds4/fjljfatchina
62a3bcf8085f41d632fdf83ab1fc485abd98c445
0503d4aa1907cb9cf47d5d0b5c606df07217c8f6
refs/heads/master
2021-01-10T04:10:34.432964
2010-03-07T09:43:28
2010-03-07T09:43:28
48,106,882
1
1
null
null
null
null
UHC
C++
false
false
181,391
cpp
/****************************************************************************************************************** 모듈명: 작성자: 작성일: [일자][수정자] : 수정 내용 *******************************************************************************************************************/ #include "StdAfx.h" /****************************************************************************************************************** CActor Class *******************************************************************************************************************/ /****************************************************************************************************************** 함수명 : CActor::CActor() 작성자 : 작성일 : 목적 : 출력 : [일자][수정자] : 수정내용 *******************************************************************************************************************/ CActor::CActor() { InitActor(); } /****************************************************************************************************************** 함수명 : CActor::~CActor() 작성자 : 작성일 : 목적 : 출력 : [일자][수정자] : 수정내용 *******************************************************************************************************************/ CActor::~CActor() { DestroyActor(); } VOID CActor::InitActor() { m_wOldPosX = 0; m_wOldPosY = 0; m_bOldDir = 0; m_bOpenHealth = FALSE; m_bWarMode = FALSE; m_bCurrMtn = _MT_MON_STAND; m_bCurrDir = _DIRECTION_LIST_1; m_bMoveDir = _DIRECTION_LIST_1; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; m_bHPPercent = 100; m_bMoveNextFrmCnt = 5; m_bIsMoved = FALSE; m_dwWarModeTime = 0; m_wMAXHP = 0; m_wHP = 0; m_wMP = 0; m_wPosX = 0; m_wPosY = 0; m_bLightSize = 2; m_shShiftPixelX = 0; m_shShiftPixelY = 0; m_shShiftTileX = 0; m_shShiftTileY = 0; m_bMoveSpeed = 0; m_shScrnPosX = 0; m_shScrnPosY = 0; m_wCurrDelay = 0; m_dwFstFrame = 0; m_dwEndFrame = 1; m_dwCurrFrame = 0; m_wDelay = 0; m_pxActorImage = NULL; m_bMsgHurryCheck = FALSE; m_bUseEffect = FALSE; m_bUseSwordEffect = FALSE; m_bReverse = FALSE; m_bIsDead = FALSE; m_bABlendRev = FALSE; m_dwCurrEffectFrame = 0; m_dwFstEffectFrame = 0; m_dwEndEffectFrame = 0; m_bEffectFrame = 0; m_bBackStepFrame = 0; m_bBackStepFrameCnt = 0; m_nState = 0; m_nDividedChatLine = 0; m_dwIdentity = 0; m_wCurrChatDelay = 0; m_wABlendCurrDelay = 0; m_wABlendCurrDelay = 0; m_bFstSoundPlayed = FALSE; m_bAppearState = _DIG_NORMAL; m_wStateClr = _STATE_NOTUSED; m_dwNameClr = RGB(255, 255, 255); m_bActorImgIdx = _IMAGE_M_HUMAN; m_bEffectImgIdx = _IMAGE_MAGIC; ZeroMemory(m_szName, 64); ZeroMemory(&m_stFeature, sizeof(FEATURE)); ZeroMemory(&m_stHitter, sizeof(FEATURE)); ZeroMemory(m_bLightRadius, sizeof(BYTE)*2); ZeroMemory(m_bLightColor , sizeof(BYTE)*2*3); ZeroMemory(m_szChatMsg, MAX_PATH); ZeroMemory(m_szChatMsgArg, MAX_PATH*5); ZeroMemory(&m_rcActor, sizeof(RECT)); ZeroMemory(&m_rcTargetRgn, sizeof(RECT)); D3DVECTOR vNorm(0, 0, -1); m_avBoard[0] = D3DVERTEX(D3DVECTOR(-0.5f, 0.5f, 0), vNorm, 0, 0); m_avBoard[1] = D3DVERTEX(D3DVECTOR(-0.5f,-0.5f, 0), vNorm, 0, 1); m_avBoard[2] = D3DVERTEX(D3DVECTOR( 0.5f, 0.5f, 0), vNorm, 1, 0); m_avBoard[3] = D3DVERTEX(D3DVECTOR( 0.5f,-0.5f, 0), vNorm, 1, 1); } VOID CActor::DestroyActor() { INT nCnt; SHORT shLeftMsgCnt; LPPACKETMSG lpPacketMsg; lpPacketMsg = NULL; shLeftMsgCnt = m_xPacketQueue.GetCount(); // 쌓여있는 패킷을 지운다. if ( shLeftMsgCnt > 0 ) { for ( nCnt = 0; nCnt < shLeftMsgCnt; nCnt++ ) { lpPacketMsg = (LPPACKETMSG)m_xPacketQueue.PopQ(); if ( lpPacketMsg ) { SAFE_DELETE(lpPacketMsg); } } } // 모든변수를 초기화 시켜둔다. InitActor(); } WORD CActor::GetCharState() { WORD wCharState = 0XFFFF; // if( m_nState & 0X100000 ) wCharState = _STATE_SHIELDUSE; if( m_nState & 0X800000 ) wCharState = _STATE_ABLEND; if( m_nState & 0X4000000 ) wCharState = _STATE_GRAY; if( m_nState & 0X8000000 ) wCharState = _STATE_FUCHSIA; if( m_nState & 0X10000000 ) wCharState = _STATE_YELLOW; if( m_nState & 0X20000000 ) wCharState = _STATE_BLUE; if( m_nState & 0X40000000 ) wCharState = _STATE_RED; if( m_nState & 0X80000000 ) wCharState = _STATE_GREEN; m_wStateClr = _STATE_NOTUSED; if ( m_wStateClr == _STATE_ABLEND || m_wStateClr == _STATE_SHIELDUSE ) m_wStateClr = _STATE_NOTUSED; return wCharState; } VOID CActor::DrawWithEffected(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wChooseColor1, WORD wChooseColor2, BOOL bFocused, BYTE bOpa, WORD wState) { switch ( wState ) { case _STATE_RED: case _STATE_GREEN: case _STATE_BLUE: case _STATE_YELLOW: case _STATE_FUCHSIA: case _STATE_GRAY: if ( m_wABlendDelay ) g_xMainWnd.DrawWithImageForCompClipRgnColor(nX, nY, nXSize, nYSize, pwSrc, _CLIP_WIDTH, _CLIP_HEIGHT, wState, bFocused, TRUE); else g_xMainWnd.DrawWithImageForCompClipRgnColor(nX, nY, nXSize, nYSize, pwSrc, _CLIP_WIDTH, _CLIP_HEIGHT, wState, bFocused, FALSE); break; case _STATE_ABLEND: { if ( bFocused ) bOpa -= 20; if ( bOpa < 0 && bOpa > 100 ) bOpa = 0; g_xMainWnd.DrawWithABlendCompDataWithBackBuffer(nX, nY, nXSize, nYSize, pwSrc, _CLIP_WIDTH, _CLIP_HEIGHT, wChooseColor1, wChooseColor2, bOpa); } break; case _STATE_SHIELDUSE: case _STATE_NOTUSED: default: { if ( !m_wABlendDelay ) g_xMainWnd.DrawWithImageForCompClipRgn(nX, nY, nXSize, nYSize, pwSrc, _CLIP_WIDTH, _CLIP_HEIGHT, wChooseColor1, wChooseColor2, bFocused); else g_xMainWnd.DrawWithABlendCompDataWithBackBuffer(nX, nY, nXSize, nYSize, pwSrc, _CLIP_WIDTH, _CLIP_HEIGHT, wChooseColor1, wChooseColor2, bOpa); } break; } } /****************************************************************************************************************** 함수명 : CActor::Create() 작성자 : 작성일 : 목적 : 입력 : CImageHandler* pxImgHandler FEATURE stFeature BYTE bMtn WORD bDir WORD wPosX WORD wPosY 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CActor::Create(CImageHandler* pxImgHandler, FEATURE* pstFeature, BYTE bMtn, WORD bDir, WORD wPosX, WORD wPosY) { // 전달인자 적용 및 확인.///////////////////////////////////////////////////////////////////////////////// if ( /*(pstFeature->bGender >= 0 && pstFeature->bGender < _MAX_GENDER) && */(bDir >= 0 && bDir < _MAX_DIRECTION) ) { switch ( pstFeature->bGender ) { case _GENDER_MAN: { if ( (pstFeature->bDress < 0 && pstFeature->bDress >= _MAX_HERO_KIND) || (bMtn < 0 && bMtn >= _MAX_HERO_MTN) ) return FALSE; else { m_bActorImgIdx = _IMAGE_M_HUMAN; m_dwFstFrame = g_xSpriteInfo.m_stHeroSpr[bMtn].wFstFrm + pstFeature->bDress*_MAX_HERO_FRAME + bDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stHeroSpr[bMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stHeroSpr[bMtn].wDelay; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! pstFeature->bHair = 2; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } } break; case _GENDER_WOMAN: { if ( (pstFeature->bDress < 0 && pstFeature->bDress >= _MAX_HERO_KIND) || (bMtn < 0 && bMtn >= _MAX_HERO_MTN) ) return FALSE; else { m_bActorImgIdx = _IMAGE_WM_HUMAN; m_dwFstFrame = g_xSpriteInfo.m_stHeroSpr[bMtn].wFstFrm + pstFeature->bDress*_MAX_HERO_FRAME + bDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stHeroSpr[bMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stHeroSpr[bMtn].wDelay; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! pstFeature->bHair = 2; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } } break; case _GENDER_MON: { if ( (pstFeature->bDress < 0 && pstFeature->bDress >= _MAX_MON_KIND) || (bMtn < 0 && bMtn >= _MAX_MON_MTN) ) return FALSE; else { switch ( m_stFeature.bDress ) { case 31: // 식인초. case 67: // 촉룡신. case 73: // 비막원충. case 104: // 적월마. bDir = 0; case 106: // 폭안거미. bDir = 1; break; default: break; } g_xSpriteInfo.SetMonFrameInfo(pstFeature->bDress); m_bActorImgIdx = _IMAGE_MONSTER1 + (pstFeature->bDress / 10); m_dwFstFrame = g_xSpriteInfo.m_stMonSpr[bMtn].wFstFrm + (pstFeature->bDress%10)*_MAX_MON_FRAME + bDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stMonSpr[bMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stMonSpr[bMtn].wDelay; } } break; case _GENDER_NPC: { if ( (pstFeature->bDress < 0 && pstFeature->bDress >= _MAX_NPC_KIND) || (bMtn < 0 && bMtn >= _MAX_NPC_MTN) ) return FALSE; else { m_bActorImgIdx = _IMAGE_NPC; bDir++; // bDir은 0이 될수도 있기때문이다. bDir = bDir/3; m_dwFstFrame = g_xSpriteInfo.m_stNPCSpr[bMtn].wFstFrm + pstFeature->bDress*_MAX_NPC_FRAME + bDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stNPCSpr[bMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stNPCSpr[bMtn].wDelay; } } break; default: return FALSE; } m_bCurrMtn = bMtn; m_bCurrDir = bDir; m_bMoveDir = bDir; m_wPosX = wPosX; m_wPosY = wPosY; memcpy(&m_stFeature, pstFeature, sizeof(FEATURE)); m_pxActorImage = &(pxImgHandler->m_xImageList[m_bActorImgIdx]); m_dwCurrFrame = m_dwFstFrame; m_bMoveDir = m_bCurrDir; D3DVECTOR vNorm(0, 0, -1); m_avBoard[0] = D3DVERTEX(D3DVECTOR(-0.5f, 0.5f, 0), vNorm, 0, 0); m_avBoard[1] = D3DVERTEX(D3DVECTOR(-0.5f,-0.5f, 0), vNorm, 0, 1); m_avBoard[2] = D3DVERTEX(D3DVECTOR( 0.5f, 0.5f, 0), vNorm, 1, 0); m_avBoard[3] = D3DVERTEX(D3DVECTOR( 0.5f,-0.5f, 0), vNorm, 1, 1); return TRUE; } return FALSE; } /****************************************************************************************************************** 함수명 : CActor::CheckFeatureValidate() 작성자 : 작성일 : 목적 : 입력 : FEATURE stFeature 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CActor::CheckFeatureValidate(FEATURE stFeature) { // if ( (stFeature.bGender >= 0 && stFeature.bGender < _MAX_GENDER) ) { switch ( stFeature.bGender ) { case _GENDER_MAN: case _GENDER_WOMAN: if ( stFeature.bDress < 0 && stFeature.bDress >= _MAX_HERO_KIND ) return FALSE; break; case _GENDER_MON: { if ( stFeature.bDress < 0 && stFeature.bDress >= _MAX_MON_KIND ) return FALSE; } break; case _GENDER_NPC: default: return FALSE; } } return TRUE; } /****************************************************************************************************************** 함수명 : CActor::ChangeFeature() 작성자 : 작성일 : 목적 : 입력 : CImageHandler* pxImgHandler FEATURE stFeature 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CActor::ChangeFeature(FEATURE stFeature) { CImageHandler* pxImgHandler = &g_xGameProc.m_xImage; if ( /*stFeature.bGender >= 0 && stFeature.bGender < _MAX_GENDER && */CheckFeatureValidate(stFeature) ) { switch ( stFeature.bGender ) { case _GENDER_MAN: { if ( stFeature.bDress < 0 && stFeature.bDress >= _MAX_HERO_KIND ) return FALSE; else { m_bActorImgIdx = _IMAGE_M_HUMAN; m_dwFstFrame = g_xSpriteInfo.m_stHeroSpr[m_bCurrMtn].wFstFrm + stFeature.bDress*_MAX_HERO_FRAME + m_bCurrDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stHeroSpr[m_bCurrMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stHeroSpr[m_bCurrMtn].wDelay; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stFeature.bHair = 2; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } } break; case _GENDER_WOMAN: { if ( stFeature.bDress < 0 && stFeature.bDress >= _MAX_HERO_KIND ) return FALSE; else { m_bActorImgIdx = _IMAGE_WM_HUMAN; m_dwFstFrame = g_xSpriteInfo.m_stHeroSpr[m_bCurrMtn].wFstFrm + stFeature.bDress*_MAX_HERO_FRAME + m_bCurrDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stHeroSpr[m_bCurrMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stHeroSpr[m_bCurrMtn].wDelay; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stFeature.bHair = 2; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } } break; case _GENDER_MON: { if ( stFeature.bDress < 0 && stFeature.bDress >= _MAX_MON_KIND ) return FALSE; else { g_xSpriteInfo.SetMonFrameInfo(stFeature.bDress); m_bActorImgIdx = _IMAGE_MONSTER1 + (stFeature.bDress/10); m_dwFstFrame = g_xSpriteInfo.m_stMonSpr[m_bCurrMtn].wFstFrm + (stFeature.bDress%10)*_MAX_MON_FRAME + m_bCurrDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stMonSpr[m_bCurrMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stMonSpr[m_bCurrMtn].wDelay; } } break; // NPC는 프레임이 일정하지 않으므로 따로 적용시킨다. case _GENDER_NPC: default: return FALSE; } m_stFeature = stFeature; m_pxActorImage = &(pxImgHandler->m_xImageList[m_bActorImgIdx]); m_dwCurrFrame = m_dwFstFrame; return TRUE; } return FALSE; } /****************************************************************************************************************** 함수명 : CActor::SetMotionFrame() 작성자 : 작성일 : 목적 : 입력 : BYTE bMtn BYTE bDir 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CActor::SetMotionFrame(BYTE bMtn, BYTE bDir) { if ( /*(bMtn < 0 && bMtn >= _MAX_HERO_MTN) || */(bDir < 0 && bDir >= _MAX_DIRECTION) ) return FALSE; switch ( m_stFeature.bGender ) { case _GENDER_MAN: { m_dwFstFrame = g_xSpriteInfo.m_stHeroSpr[bMtn].wFstFrm + m_stFeature.bDress*_MAX_HERO_FRAME + bDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stHeroSpr[bMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stHeroSpr[bMtn].wDelay; } break; case _GENDER_WOMAN: { m_dwFstFrame = g_xSpriteInfo.m_stHeroSpr[bMtn].wFstFrm + m_stFeature.bDress*_MAX_HERO_FRAME + bDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stHeroSpr[bMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stHeroSpr[bMtn].wDelay; } break; case _GENDER_MON: { if ( m_stFeature.bDress == 31 && bMtn == _MT_MON_STAND ) bDir = 0; switch ( m_stFeature.bDress ) { case 31: // 식인초. case 67: // 촉룡신. case 73: // 비막원충. case 104: // 적월마. bDir = 0; case 106: // 폭안거미. bDir = 1; break; default: break; } g_xSpriteInfo.SetMonFrameInfo(m_stFeature.bDress); m_dwFstFrame = g_xSpriteInfo.m_stMonSpr[bMtn].wFstFrm + (m_stFeature.bDress%10)*_MAX_MON_FRAME + bDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stMonSpr[bMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stMonSpr[bMtn].wDelay; } break; case _GENDER_NPC: { bDir++; // bDir은 0이 될수도 있기때문이다. bDir = bDir/3; m_dwFstFrame = g_xSpriteInfo.m_stNPCSpr[bMtn].wFstFrm + m_stFeature.bDress*_MAX_NPC_FRAME + bDir*10; m_dwEndFrame = m_dwFstFrame + g_xSpriteInfo.m_stNPCSpr[bMtn].wFrmCnt; m_wDelay = g_xSpriteInfo.m_stNPCSpr[bMtn].wDelay; } break; default: return FALSE; } m_bCurrMtn = bMtn; m_bCurrDir = bDir; m_bMoveDir = bDir; m_dwCurrFrame = m_dwFstFrame; m_wCurrDelay = 0; if ( m_bCurrDir == _DIRECTION_LIST_8 ) m_bMoveNextFrmCnt = 2; else m_bMoveNextFrmCnt = 5; return TRUE; } VOID CActor::PlayActSound() { INT nWaveNum = -1; const INT nActorSndTbl[100] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0 - 9 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10 - 19 160, 161, 100, 101, 102, 163, 0, 162, 83, 80, // 20 - 29 1, 10, 20, 21, 22, 23, 150, 24, 25, 26, // 30 - 39 27, 30, 32, 31, 151, 34, 28, 18, 40, 50, // 40 - 49 51, 52, 53, 152, 36, 72, 37, 38, 43, 44, // 50 - 59 45, 48, 49, 90, 91, 70, 73, 140, 74, 120, // 60 - 69 121, 81, 82, 41, 42, 39, 110, 111, 112, 130, // 70 - 79 164, 46, 47, 61, 62, 63, 71, -1, -1, 170, // 80 - 89 171, 33, -1, -1, -1, -1, -1, -1, -1, -1, // 90 - 99 }; if ( m_dwCurrFrame == m_dwFstFrame+1 && m_bCurrMtn == _MT_MON_APPEAR ) // 나타나기. { nWaveNum = 200 + nActorSndTbl[m_stFeature.bDress]*10; } else if ( (m_dwCurrFrame == m_dwFstFrame+1) && (m_bCurrMtn == _MT_MON_STAND || _MT_MON_WALK) ) // 멈춰있기. { INT nRand = rand(); if ( m_bFstSoundPlayed && !m_bIsDead ) { if ( !(nRand%25) ) nWaveNum = 200 + nActorSndTbl[m_stFeature.bDress]*10 + 1; else nWaveNum = -1; } else { if ( !(nRand%3) && !m_bIsDead ) { nWaveNum = 200 + nActorSndTbl[m_stFeature.bDress]*10 + 1; m_bFstSoundPlayed = TRUE; } else nWaveNum = -1; } } else if ( m_dwCurrFrame == m_dwFstFrame+1 && m_bCurrMtn == _MT_MON_ATTACK_A ) // 일반공격1. { nWaveNum = 200 + nActorSndTbl[m_stFeature.bDress]*10 + 2; } else if ( m_dwCurrFrame == m_dwFstFrame+2 && m_bCurrMtn == _MT_MON_ATTACK_A ) // 일반공격1. { nWaveNum = 200 + nActorSndTbl[m_stFeature.bDress]*10 + 3; } else if ( m_dwCurrFrame == m_dwFstFrame+1 && m_bCurrMtn == _MT_MON_HITTED ) { if ( m_stFeature.bGender < 2 ) { switch ( m_stHitter.bWeapon ) { case 21: case 24: // 단검, 비단검. case 8: case 9: // 목검, 아리수목검. case 18: case 22: case 23: case 26: case 27: case 28: case 30: // 사모검. 청동검. 철검. 청음검. 벽사검. 천령. 곡성검. case 1: case 4: case 11: case 13: case 14: case 20: case 25: case 29: case 31: // 유월도. 묵청대도. 육합도. 군도. 도룡보도. 사각도. 세첨도. 예도. 초혼도. nWaveNum = 70; break; case 5: case 10: case 12: // 삼적대부. 청동도끼. 연자부. case 15: // 파뇌진당. nWaveNum = 71; break; case 2: case 3: case 6: case 7: case 16: case 17: case 19: // 삼지창. 천형목. 홍아창. 곡괭이. 청마창, 용아장. 제마봉 nWaveNum = 72; break; default: nWaveNum = 73; // 맨손. break; } } } else if ( m_dwCurrFrame == m_dwFstFrame+2 && m_bCurrMtn == _MT_MON_HITTED ) // 맞기. { nWaveNum = 200 + nActorSndTbl[m_stFeature.bDress]*10 + 4; } else if ( m_dwCurrFrame == m_dwFstFrame+2 && m_bCurrMtn == _MT_MON_DIE ) // 죽기1. { nWaveNum = 200 + nActorSndTbl[m_stFeature.bDress]*10 + 5; } else if ( m_dwCurrFrame == m_dwFstFrame+3 && m_bCurrMtn == _MT_MON_DIE ) // 죽기2. { nWaveNum = 200 + nActorSndTbl[m_stFeature.bDress]*10 + 6; } /* if ( nWaveNum != -1 ) g_xSound.PlayActorWav(m_wPosX, m_wPosY, g_xGameProc.m_xMyHero.m_wPosX, g_xGameProc.m_xMyHero.m_wPosY, nWaveNum); */ } /****************************************************************************************************************** 함수명 : CActor::SetMoving() 작성자 : 작성일 : 목적 : 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CActor::SetMoving() { WORD wFrmCnt = m_dwEndFrame - m_dwFstFrame; WORD wCurrFrm = m_dwCurrFrame - m_dwFstFrame; switch ( m_bMoveDir ) { case _DIRECTION_LIST_1: m_shShiftPixelX = 0; if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = -(_CELL_HEIGHT/wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelY = (_CELL_HEIGHT/wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_2: if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = (_CELL_WIDTH /wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelX = -(_CELL_WIDTH /wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = -(_CELL_HEIGHT/wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelY = (_CELL_HEIGHT/wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_3: if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = (_CELL_WIDTH /wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelX = -(_CELL_WIDTH /wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; m_shShiftPixelY = 0; break; case _DIRECTION_LIST_4: if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = (_CELL_WIDTH /wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelX = -(_CELL_WIDTH /wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = (_CELL_HEIGHT/wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelY = -(_CELL_HEIGHT/wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_5: m_shShiftPixelX = 0; if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = (_CELL_HEIGHT/wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelY = -(_CELL_HEIGHT/wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_6: if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = -(_CELL_WIDTH /wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelX = (_CELL_WIDTH /wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = (_CELL_HEIGHT/wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelY = -(_CELL_HEIGHT/wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_7: if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = -(_CELL_WIDTH /wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelX = (_CELL_WIDTH /wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; m_shShiftPixelY = 0; break; case _DIRECTION_LIST_8: if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = -(_CELL_WIDTH /wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelX = (_CELL_WIDTH /wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; if ( wCurrFrm < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = -(_CELL_HEIGHT/wFrmCnt * (wCurrFrm+1))*m_bMoveSpeed; else m_shShiftPixelY = (_CELL_HEIGHT/wFrmCnt * (wFrmCnt - wCurrFrm -1))*m_bMoveSpeed; break; } } /****************************************************************************************************************** 함수명 : CActor::SetBackStepMoving() 작성자 : 작성일 : 목적 : 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CActor::SetBackStepMoving() { switch ( m_bMoveDir ) { case _DIRECTION_LIST_1: m_shShiftPixelX = 0; if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = -(_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelY = (_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_2: if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = (_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelX = -(_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = -(_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelY = (_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_3: if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = (_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelX = -(_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; m_shShiftPixelY = 0; break; case _DIRECTION_LIST_4: if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = (_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelX = -(_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = (_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelY = -(_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_5: m_shShiftPixelX = 0; if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = (_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelY = -(_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_6: if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = -(_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelX = (_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = (_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelY = -(_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; break; case _DIRECTION_LIST_7: if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = -(_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelX = (_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; m_shShiftPixelY = 0; break; case _DIRECTION_LIST_8: if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelX = -(_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelX = (_CELL_WIDTH /m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; if ( m_bBackStepFrame < (6-m_bMoveNextFrmCnt) ) m_shShiftPixelY = -(_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrame+1))*m_bMoveSpeed; else m_shShiftPixelY = (_CELL_HEIGHT/m_bBackStepFrameCnt * (m_bBackStepFrameCnt - m_bBackStepFrame -1))*m_bMoveSpeed; break; } } /****************************************************************************************************************** 함수명 : CActor::SetMoved() 작성자 : 작성일 : 목적 : 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CActor::SetMoved() { switch ( m_bMoveDir ) { case _DIRECTION_LIST_1: m_shShiftTileX = 0; m_shShiftTileY = -m_bMoveSpeed; break; case _DIRECTION_LIST_2: m_shShiftTileX = m_bMoveSpeed; m_shShiftTileY = -m_bMoveSpeed; break; case _DIRECTION_LIST_3: m_shShiftTileX = m_bMoveSpeed; m_shShiftTileY = 0; break; case _DIRECTION_LIST_4: m_shShiftTileX = m_bMoveSpeed; m_shShiftTileY = m_bMoveSpeed; break; case _DIRECTION_LIST_5: m_shShiftTileX = 0; m_shShiftTileY = m_bMoveSpeed; break; case _DIRECTION_LIST_6: m_shShiftTileX = -m_bMoveSpeed; m_shShiftTileY = m_bMoveSpeed; break; case _DIRECTION_LIST_7: m_shShiftTileX = -m_bMoveSpeed; m_shShiftTileY = 0; break; case _DIRECTION_LIST_8: m_shShiftTileX = -m_bMoveSpeed; m_shShiftTileY = -m_bMoveSpeed; break; } m_wPosX += m_shShiftTileX; m_wPosY += m_shShiftTileY; m_shShiftPixelX = 0; m_shShiftPixelY = 0; } /****************************************************************************************************************** 함수명 : CActor::OnCharDescPacket() 작성자 : 작성일 : 목적 : SM_WALK, SM_DEATH, SM_TURN, SM_RUN, SM_DIGUP 메시지에 사용한다. 입력 : LPPACKETMSG lpPacketMsg 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CActor::OnCharDescPacket(LPPACKETMSG lpPacketMsg) { CHARDESC stCharDesc; FEATURE stFeature; fnDecode6BitBuf(lpPacketMsg->szEncodeData, (char*)&stCharDesc, sizeof(CHARDESC)); memcpy(&stFeature, &stCharDesc.nFeature, sizeof(FEATURE)); m_nState = stCharDesc.nStatus; if( m_nState & 0X2 ) m_bOpenHealth = TRUE; else m_bOpenHealth = FALSE; ChangeFeature(stFeature); } VOID CActor::OnUserName(LPPACKETMSG lpPacketMsg) { INT nPos = fnDecode6BitBuf(lpPacketMsg->szEncodeData, m_szName, sizeof(m_szName)); m_szName[nPos] = '\0'; m_dwNameClr = GetUserNameColor(lpPacketMsg->stDefMsg.wParam); } VOID CActor::OnChangeNameClr(LPPACKETMSG lpPacketMsg) { m_dwNameClr = GetUserNameColor(lpPacketMsg->stDefMsg.wParam); } VOID CActor::OnChangeLight(LPPACKETMSG lpPacketMsg) { m_bLightSize = lpPacketMsg->stDefMsg.wParam; } VOID CActor::OnOpenHealth(LPPACKETMSG lpPacketMsg) { m_bOpenHealth = TRUE; } VOID CActor::OnCloseHealth(LPPACKETMSG lpPacketMsg) { m_bOpenHealth = FALSE; } VOID CActor::OnFeatureChanged(LPPACKETMSG lpPacketMsg) { FEATURE stFeature; LONG nFeature = MAKELONG(lpPacketMsg->stDefMsg.wParam, lpPacketMsg->stDefMsg.wTag); memcpy(&stFeature, &nFeature, sizeof(LONG)); ChangeFeature(stFeature); } VOID CActor::OnHealthSpellChanged(LPPACKETMSG lpPacketMsg) { m_wHP = lpPacketMsg->stDefMsg.wParam; m_wMP = lpPacketMsg->stDefMsg.wTag; m_wMAXHP = lpPacketMsg->stDefMsg.wSeries; FLOAT wHPRate = (FLOAT)((FLOAT)m_wHP/(FLOAT)m_wMAXHP); m_bHPPercent = wHPRate*100; } VOID CActor::OnWalk(LPPACKETMSG lpPacketMsg) { BYTE bDir; // m_wPosX = lpPacketMsg->stDefMsg.wParam; // m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = LOBYTE(lpPacketMsg->stDefMsg.wSeries); m_bLightSize = HIBYTE(lpPacketMsg->stDefMsg.wSeries); OnCharDescPacket(lpPacketMsg); SetMotionFrame(_MT_MON_WALK, bDir); m_bMoveSpeed = _SPEED_WALK; SetMoving(); } VOID CActor::OnTurn(LPPACKETMSG lpPacketMsg) { BYTE bDir; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = LOBYTE(lpPacketMsg->stDefMsg.wSeries); m_bLightSize = HIBYTE(lpPacketMsg->stDefMsg.wSeries); // 식인초. if ( m_stFeature.bDress == 31 ) bDir = 0; OnCharDescPacket(lpPacketMsg); SetMotionFrame(_MT_MON_STAND, bDir); if( m_nState & 0X1 ) // 석화상태. { switch ( m_stFeature.bDress ) { case 83: //주마신장. case 84: //주마호법. case 85: //주마왕. SetMotionFrame(_MT_MON_APPEAR, 0); m_dwEndFrame = m_dwFstFrame + 1; m_bCurrMtn = _MT_MON_STAND; } } } VOID CActor::OnDigup(LPPACKETMSG lpPacketMsg) { //MESSAGEBODYWL ???????? BYTE bDir; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = LOBYTE(lpPacketMsg->stDefMsg.wSeries); m_bLightSize = HIBYTE(lpPacketMsg->stDefMsg.wSeries); OnCharDescPacket(lpPacketMsg); m_bReverse = FALSE; switch ( m_stFeature.bDress ) { case 3: m_bReverse = TRUE; break; case 85: //주마왕. bDir = 0; break; case 31: //식인초. bDir = 0; m_bReverse = TRUE; break; case 56: { CMagic* pxMagic; pxMagic = new CMagic; pxMagic->CreateMagic(_SKILL_SKELLETON, m_wPosX, m_wPosY, m_wPosX, m_wPosY, NULL, 0); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; } /* case 89: { CMagic* pxMagic; pxMagic = new CMagic; pxMagic->CreateMagic(_SKILL_SINSU, m_wPosX, m_wPosY, m_wPosX, m_wPosY, NULL, 0); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; } */ } m_bAppearState = _DIG_UP; SetMotionFrame(_MT_MON_APPEAR, bDir); } VOID CActor::OnDigDown(LPPACKETMSG lpPacketMsg) { BYTE bDir; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = m_bCurrDir; m_bReverse = TRUE; switch ( m_stFeature.bDress ) { case 3: m_bReverse = FALSE; break; case 31: //식인초. bDir = 0; m_bReverse = FALSE; break; } m_bAppearState = _DIG_DOWN; SetMotionFrame(_MT_MON_APPEAR, bDir); } VOID CActor::OnDeath(LPPACKETMSG lpPacketMsg) { BYTE bDir; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = lpPacketMsg->stDefMsg.wSeries; OnCharDescPacket(lpPacketMsg); SetMotionFrame(_MT_MON_DIE, bDir); if ( lpPacketMsg->stDefMsg.wIdent == SM_DEATH ) { m_dwCurrFrame = m_dwEndFrame - 1; m_bIsDead = TRUE; } else { // 몬스터일때. if ( m_stFeature.bGender == _GENDER_MON ) { CMagic* pxMagic; switch ( m_stFeature.bDress ) { case 4: // 석장인. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_EXPLODE1, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 5: // 바쿠가르나. case 6: // 바자울. case 11: // 모디젼. case 19: // 레디가르나. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_SINGI_DIE, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); /* LoadEffect(&g_xGameProc.m_xImage, _MONMAGIC_DIE); m_bUseSwordEffect = TRUE; */ break; case 40: // 허수아비. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_HUSU_DIE, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); /* LoadEffect(&g_xGameProc.m_xImage, _MONMAGIC_HUSU_DIE); m_bUseSwordEffect = TRUE; */ break; case 48: // 좀비. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_ZOMBIE_DIE, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); /* LoadEffect(&g_xGameProc.m_xImage, _MONMAGIC_ZOMBIE_DIE); m_bUseSwordEffect = TRUE; */ break; case 99: // 바오달드. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_BAODIE, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; default : break; } } } } VOID CActor::OnBackStep(LPPACKETMSG lpPacketMsg) { BYTE bDir; bDir = lpPacketMsg->stDefMsg.wSeries; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; SetMotionFrame(_MT_MON_WALK, bDir); if ( m_bCurrDir < 4 ) m_bMoveDir = m_bCurrDir + 4; else m_bMoveDir = m_bCurrDir - 4; m_bMoveSpeed = _SPEED_WALK; m_bBackStepFrame = 0; m_bBackStepFrameCnt = 6; SetBackStepMoving(); } VOID CActor::OnStruck(LPPACKETMSG lpPacketMsg) { MESSAGEBODYWL stMsgBodyWl; FEATURE stFeature; FLOAT wHPRate = (FLOAT)((FLOAT)lpPacketMsg->stDefMsg.wParam/(FLOAT)lpPacketMsg->stDefMsg.wTag); WORD wDamage = lpPacketMsg->stDefMsg.wSeries; m_wHP = lpPacketMsg->stDefMsg.wParam; m_wMAXHP = lpPacketMsg->stDefMsg.wTag; m_bHPPercent = wHPRate*100; fnDecode6BitBuf(lpPacketMsg->szEncodeData, (char*)&stMsgBodyWl, sizeof(MESSAGEBODYWL)); memcpy(&stFeature, &stMsgBodyWl.lParam1, sizeof(LONG)); ChangeFeature(stFeature); SetMotionFrame(_MT_MON_HITTED, m_bCurrDir); // 몬스터일때. if ( m_stHitter.bGender == _GENDER_MON ) { CMagic* pxMagic; switch ( m_stHitter.bDress ) { case 2: // 케팔로프. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_KEPAL, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 8: // 갑주개미. case 14: // 병용개미. case 16: // 드난개미. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_GREATANT, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 67: // 촉룡신. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_BIGGINE_CHAR, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; default : break; } } ZeroMemory(&m_stHitter, sizeof(FEATURE)); } VOID CActor::OnLighting(LPPACKETMSG lpPacketMsg) { WORD wTargetX, wTargetY; INT nTargetID; CMagic* pxMagic; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; m_bCurrDir = lpPacketMsg->stDefMsg.wSeries; MESSAGEBODYWL stMsgBodyWl; fnDecode6BitBuf(lpPacketMsg->szEncodeData, (char*)&stMsgBodyWl, sizeof(MESSAGEBODYWL)); wTargetX = stMsgBodyWl.lParam1; wTargetY = stMsgBodyWl.lParam2; nTargetID = MAKELONG(stMsgBodyWl.nTag1, stMsgBodyWl.nTag2); switch ( m_stFeature.bDress ) { case 48: // 좀비. 8방향. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_ZOMBIE, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this, nTargetID); g_xGameProc.m_xMagicList.AddNode(pxMagic); SetMotionFrame(_MT_MON_ATTACK_A, m_bCurrDir); break; } } VOID CActor::OnFlyAxe(LPPACKETMSG lpPacketMsg) { WORD wTargetX, wTargetY; INT nTargetID; CMagic* pxMagic; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; m_bCurrDir = lpPacketMsg->stDefMsg.wSeries; MESSAGEBODYW stMsgBodyW; fnDecode6BitBuf(lpPacketMsg->szEncodeData, (char*)&stMsgBodyW, sizeof(MESSAGEBODYW)); wTargetX = stMsgBodyW.wParam1; wTargetY = stMsgBodyW.wParam2; nTargetID = MAKELONG(stMsgBodyW.wTag1, stMsgBodyW.wTag2); switch ( m_stFeature.bDress ) { case 33: // 쌍도끼해골. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_DUALAXE, m_wPosX, m_wPosY, wTargetX, wTargetY, this, nTargetID); g_xGameProc.m_xMagicList.AddNode(pxMagic); SetMotionFrame(_MT_MON_ATTACK_A, m_bCurrDir); break; case 46: // 다크. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_CHIM, m_wPosX, m_wPosY, wTargetX, wTargetY, this, nTargetID); g_xGameProc.m_xMagicList.AddNode(pxMagic); SetMotionFrame(_MT_MON_ATTACK_A, m_bCurrDir); break; case 82: // 마궁사. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_MAARROW, m_wPosX, m_wPosY, wTargetX, wTargetY, this, nTargetID); g_xGameProc.m_xMagicList.AddNode(pxMagic); SetMotionFrame(_MT_MON_ATTACK_A, m_bCurrDir); break; } } VOID CActor::OnHit(LPPACKETMSG lpPacketMsg) { BYTE bDir; bDir = lpPacketMsg->stDefMsg.wSeries; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; SetMotionFrame(_MT_MON_ATTACK_A, bDir); // 몬스터일때. if ( m_stFeature.bGender == _GENDER_MON ) { CMagic* pxMagic; switch ( m_stFeature.bDress ) { case 9: // 론. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_EXPLODE, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 5: // 바쿠가르나. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_BLACK1, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 19: // 레디가르나. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_RED1, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 45: // 우면귀왕. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_COWGHOST, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 90: // 신수. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_SINSU, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 43: // 화염우면귀. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_COWFLAME, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 85: // 주마왕. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_JUMAWANG, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 67: // 촉룡신. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_BIGGINE_ATT, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 75: // 쐐기나방. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_SSEGI, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 94: // 사어. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_SANDFISH, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 98: // 상급괴물. m_dwCurrEffectFrame = 50; m_dwFstEffectFrame = 50; m_dwEndEffectFrame = 60; m_bEffectFrame = 0; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; LoadEffect(&g_xGameProc.m_xImage, _MONMAGIC_NUMAGUMGI, bDir); m_bUseSwordEffect = TRUE; break; default : break; } } } VOID CActor::StruckMsgReassign() { INT nCnt; SHORT shLeftMsgCnt; LPPACKETMSG lpPacketMsg; lpPacketMsg = NULL; shLeftMsgCnt = m_xPacketQueue.GetCount(); if ( shLeftMsgCnt > 1 ) { for ( nCnt = 0; nCnt < shLeftMsgCnt; nCnt++ ) { lpPacketMsg = (LPPACKETMSG)m_xPacketQueue.PopQ(); if ( lpPacketMsg ) { if ( lpPacketMsg->stDefMsg.wIdent == SM_STRUCK ) { SAFE_DELETE(lpPacketMsg); } else { m_xPacketQueue.PushQ((BYTE*)lpPacketMsg); } } } } } /****************************************************************************************************************** 함수명 : CActor::UpdatePacketState() 작성자 : 작성일 : 목적 : 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CActor::UpdatePacketState() { LPPACKETMSG lpPacketMsg = NULL; if ( m_bCurrMtn == _MT_MON_STAND ) { SHORT shLeftMsgCnt = m_xPacketQueue.GetCount(); if ( shLeftMsgCnt > 0 ) { lpPacketMsg = (LPPACKETMSG)m_xPacketQueue.PopQ(); if ( shLeftMsgCnt >= 3 ) m_bMsgHurryCheck = TRUE; else m_bMsgHurryCheck = FALSE; if ( lpPacketMsg ) { switch ( lpPacketMsg->stDefMsg.wIdent ) { case SM_NOWDEATH: case SM_DEATH: { OnDeath(lpPacketMsg); break; } case SM_WALK: { OnWalk(lpPacketMsg); break; } case SM_TURN: { OnTurn(lpPacketMsg); break; } case SM_DIGUP: { OnDigup(lpPacketMsg); break; } case SM_DIGDOWN: { OnDigDown(lpPacketMsg); break; } case SM_FEATURECHANGED: { OnFeatureChanged(lpPacketMsg); break; } case SM_OPENHEALTH: { OnOpenHealth(lpPacketMsg); break; } case SM_CLOSEHEALTH: { OnCloseHealth(lpPacketMsg); break; } case SM_CHANGELIGHT: { OnChangeLight(lpPacketMsg); break; } case SM_CHANGENAMECOLOR: { OnChangeNameClr(lpPacketMsg); break; } case SM_USERNAME: { OnUserName(lpPacketMsg); break; } case SM_HEALTHSPELLCHANGED: { OnHealthSpellChanged(lpPacketMsg); break; } case SM_BACKSTEP: { OnBackStep(lpPacketMsg); break; } case SM_STRUCK: { OnStruck(lpPacketMsg); break; } case SM_HIT: { OnHit(lpPacketMsg); break; } case SM_FLYAXE: { OnFlyAxe(lpPacketMsg); break; } case SM_LIGHTING: { OnLighting(lpPacketMsg); break; } case SM_SKELETON: OnWalk(lpPacketMsg); break; default: { break; } } } SAFE_DELETE(lpPacketMsg); return TRUE; } } return FALSE; } /****************************************************************************************************************** 함수명 : CActor::LoadEffect() 작성자 : 작성일 : 목적 : 입력 : CImageHandler* pxImgHandler WORD wEffectNum BYTE bDir 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CActor::LoadEffect(CImageHandler* pxImgHandler, WORD wEffectNum, BYTE bDir) { WORD wFileType; LPEFFECTSPRINFO pstEffect = g_xSpriteInfo.GetEffectInfo(wEffectNum); if ( pstEffect ) { m_bEffectImgIdx = pstEffect->wImgIdx; m_dwFstEffectFrame = pstEffect->dwFstFrm; m_dwEndEffectFrame = pstEffect->dwEndFrm; if ( bDir ) { m_dwFstEffectFrame = m_dwFstEffectFrame + bDir*10; m_dwEndEffectFrame = m_dwEndEffectFrame + bDir*10; } m_dwCurrEffectFrame = m_dwFstEffectFrame; m_bEffectFrame = 0; m_bLightRadius[0] = pstEffect->bLightRadius[0]; m_bLightRadius[1] = pstEffect->bLightRadius[1]; m_bLightColor[0][0] = pstEffect->bLightColor[0][0]; m_bLightColor[0][1] = pstEffect->bLightColor[0][1]; m_bLightColor[0][2] = pstEffect->bLightColor[0][2]; m_bLightColor[1][0] = pstEffect->bLightColor[1][0]; m_bLightColor[1][1] = pstEffect->bLightColor[1][1]; m_bLightColor[1][2] = pstEffect->bLightColor[1][2]; for ( INT nCnt = m_dwFstEffectFrame; nCnt < m_dwEndEffectFrame; nCnt++ ) { if ( m_bEffectImgIdx == _IMAGE_MAGIC ) { wFileType = _TEXTR_FILE_MAGIC; } else if ( m_bEffectImgIdx == _IMAGE_MONMAGIC ) { wFileType = _TEXTR_FILE_MONMAGIC; } pxImgHandler->AddTextr(wFileType, m_bEffectImgIdx, nCnt); } return TRUE; } return FALSE; } /****************************************************************************************************************** 함수명 : CActor::DrawEffect() 작성자 : 작성일 : 목적 : 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CActor::DrawEffect() { if ( g_xMainWnd.Get3DDevice() ) { if( SUCCEEDED(g_xMainWnd.Get3DDevice()->BeginScene()) ) { WORD wFileType; D3DVECTOR vTrans; D3DMATRIX matTrans; D3DMATRIX matScale; D3DMATRIX matRot; D3DMATRIX matWorld; D3DMATRIX matWorldOriginal; g_xMainWnd.Get3DDevice()->GetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal); D3DMATERIAL7 mtrl; CWHWilImageData* pxWilImg; if ( m_bUseEffect || m_bUseSwordEffect ) { BOOL bIndexSetted = FALSE; if ( m_bUseEffect ) { pxWilImg = &g_xGameProc.m_xImage.m_xImageList[m_bEffectImgIdx]; bIndexSetted = pxWilImg->NewSetIndex(m_dwCurrEffectFrame); } else { pxWilImg = &g_xGameProc.m_xImage.m_xImageList[m_bEffectImgIdx]; m_dwCurrEffectFrame = m_dwFstEffectFrame + m_dwCurrFrame - m_dwFstFrame; bIndexSetted = pxWilImg->NewSetIndex(m_dwCurrEffectFrame); } if ( bIndexSetted ) { vTrans.x = (FLOAT)m_shScrnPosX+(FLOAT)pxWilImg->m_lpstNewCurrWilImageInfo->shWidth/2+pxWilImg->m_lpstNewCurrWilImageInfo->shPX-400; vTrans.y = (FLOAT)-m_shScrnPosY-(FLOAT)pxWilImg->m_lpstNewCurrWilImageInfo->shHeight/2-pxWilImg->m_lpstNewCurrWilImageInfo->shPY+300; vTrans.z = 0; D3DUtil_SetTranslateMatrix(matTrans, vTrans); D3DUtil_SetScaleMatrix(matScale, (FLOAT)pxWilImg->m_lpstNewCurrWilImageInfo->shWidth, (FLOAT)pxWilImg->m_lpstNewCurrWilImageInfo->shHeight, 0.0f); D3DMath_MatrixMultiply(matWorld, matScale, matTrans); g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld); if ( m_bEffectImgIdx == _IMAGE_MAGIC ) { wFileType = _TEXTR_FILE_MAGIC; } else if ( m_bEffectImgIdx == _IMAGE_MONMAGIC ) { wFileType = _TEXTR_FILE_MONMAGIC; } LPDIRECTDRAWSURFACE7 lpddsTextr = g_xGameProc.m_xImage.GetTextrImg(wFileType, m_bEffectImgIdx, m_dwCurrEffectFrame); g_xMainWnd.Get3DDevice()->SetTexture(0, lpddsTextr); // g_xMainWnd.Get3DDevice()->SetTexture(0, D3DWILTextr_GetSurface(pxWilImg->m_szWilFileName, m_dwCurrEffectFrame)); D3DUtil_InitMaterial(mtrl, (FLOAT)255/255.0f, (FLOAT)255/255.0f, (FLOAT)255/255.0f); mtrl.diffuse.a = 0/255.0f; g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl); SetBlendRenderState(g_xMainWnd.Get3DDevice(), _BLEND_LIGHTINV, mtrl); g_xMainWnd.Get3DDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX, m_avBoard, 4, NULL); // 원상복귀. ZeroMemory(&mtrl, sizeof(mtrl)); mtrl.diffuse.r = mtrl.diffuse.g = mtrl.diffuse.b = 0.1f; mtrl.ambient.r = mtrl.ambient.g = mtrl.ambient.b = 1.0f; g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl); ResetBlendenderState(g_xMainWnd.Get3DDevice()); g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal); } if ( m_bUseEffect ) { if ( m_bEffectFrame < m_bEffectFrameCnt / 2 ) { m_bLightRadius[0] = m_bEffectFrame; m_bLightRadius[1] = m_bEffectFrame+1; } else { m_bLightRadius[0] = m_bEffectFrameCnt - m_bEffectFrame -1; m_bLightRadius[1] = m_bEffectFrameCnt - m_bEffectFrame; } g_xGameProc.m_xLightFog.SetLightRadiusWithRing( m_shScrnPosX + _CELL_WIDTH/2, m_shScrnPosY + _CELL_HEIGHT/2, m_bLightRadius[0], m_bLightColor[0][0], m_bLightColor[0][1], m_bLightColor[0][2], m_bLightRadius[1], m_bLightColor[1][0], m_bLightColor[1][1], m_bLightColor[1][2]); } else if ( m_bUseSwordEffect ) { if ( m_dwEndEffectFrame - m_dwFstEffectFrame > 8 ) { m_bLightRadius[0] = (m_dwCurrEffectFrame - m_dwFstEffectFrame)/2 + 2; m_bLightRadius[1] = (m_dwCurrEffectFrame - m_dwFstEffectFrame)/2 + 3; } else { m_bLightRadius[0] = m_dwCurrEffectFrame - m_dwFstEffectFrame + 2; m_bLightRadius[1] = m_dwCurrEffectFrame - m_dwFstEffectFrame + 3; } g_xGameProc.m_xLightFog.SetLightRadiusWithRing( m_shScrnPosX + _CELL_WIDTH/2, m_shScrnPosY + _CELL_HEIGHT/2, m_bLightRadius[0], m_bLightColor[0][0], m_bLightColor[0][1], m_bLightColor[0][2], m_bLightRadius[1], m_bLightColor[1][0], m_bLightColor[1][1], m_bLightColor[1][2]); } } g_xMainWnd.Get3DDevice()->EndScene(); return S_OK; } } return E_FAIL; } /****************************************************************************************************************** 함수명 : CActor::UpdateMotionState() 작성자 : 작성일 : 목적 : 입력 : INT nLoopTime SHORT shStartViewTileX SHORT shStartViewTileY SHORT shViewOffsetX SHORT shViewOffsetY 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CActor::UpdateMotionState(INT nLoopTime, BOOL bIsMoveTime) { m_wABlendCurrDelay += nLoopTime; if ( m_wABlendCurrDelay >= m_wABlendDelay ) { m_wABlendCurrDelay = 0; m_wABlendDelay = 0; m_bABlendRev = FALSE; } if ( m_bCurrMtn == _MT_MON_DIE && m_dwCurrFrame >= m_dwEndFrame-1 ) { m_bIsDead = TRUE; } if ( m_bIsDead ) { SetMotionFrame(_MT_MON_DIE, m_bCurrDir); m_dwCurrFrame = m_dwEndFrame - 1; return; } if ( UpdateMove(bIsMoveTime) ) { UpdatePacketState(); return; } else { m_wCurrDelay += nLoopTime; if ( m_wCurrDelay > m_wDelay ) { m_wCurrDelay = 0; if ( m_dwCurrFrame < m_dwEndFrame ) { m_dwCurrFrame++; PlayActSound(); if ( m_bMsgHurryCheck ) { m_wDelay = m_wDelay/2; m_bMsgHurryCheck = FALSE; } } } UpdatePacketState(); if ( m_dwCurrFrame >= m_dwEndFrame ) { m_shShiftTileX = 0; m_shShiftTileY = 0; m_shShiftPixelX = 0; m_shShiftPixelY = 0; m_bReverse = FALSE; m_dwCurrEffectFrame = 0; m_dwFstEffectFrame = 0; m_dwEndEffectFrame = 0; m_bEffectFrame = 0; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; m_bUseEffect = FALSE; m_bUseSwordEffect = FALSE; m_dwCurrFrame = m_dwFstFrame; SetMotionFrame(_MT_MON_STAND, m_bCurrDir); if( m_nState & 0X1 ) // 석화상태. { switch ( m_stFeature.bDress ) { case 83: //주마신장. case 84: //주마호법. case 85: //주마왕. SetMotionFrame(_MT_MON_APPEAR, 0); m_dwEndFrame = m_dwFstFrame + 1; m_bCurrMtn = _MT_MON_STAND; } } if ( m_bAppearState == _DIG_DOWN ) m_bAppearState = _DIG_DOWNDEL; } } } /****************************************************************************************************************** 함수명 : CActor::UpdateMove(BOOL bIsMoveTime) 작성자 : 작성일 : 목적 : 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CActor::UpdateMove(BOOL bIsMoveTime) { if ( m_bCurrMtn == _MT_MON_WALK || m_bCurrMtn == _MT_PUSHBACK ) { m_wCurrDelay = 0; if ( bIsMoveTime ) { if ( m_bBackStepFrameCnt ) { m_dwCurrFrame += 2; } else { m_dwCurrFrame++; if ( m_bMsgHurryCheck ) { m_dwCurrFrame++; } } if ( m_dwCurrFrame >= m_dwEndFrame-m_bMoveNextFrmCnt && !m_bIsMoved ) { SetMoved(); m_bIsMoved = TRUE; } } // 연속적인 프레임 중에서 해야할일. if ( m_dwCurrFrame >= m_dwEndFrame ) { m_dwCurrFrame = m_dwEndFrame - 1; m_shShiftTileX = 0; m_shShiftTileY = 0; m_shShiftPixelX = 0; m_shShiftPixelY = 0; m_dwCurrEffectFrame = 0; m_dwFstEffectFrame = 0; m_dwEndEffectFrame = 0; m_bEffectFrame = 0; m_bUseEffect = FALSE; m_bUseSwordEffect = FALSE; m_dwCurrFrame = m_dwFstFrame; m_bBackStepFrame = 0; m_bBackStepFrameCnt = 0; m_bIsMoved = FALSE; SetMotionFrame(_MT_MON_STAND, m_bCurrDir); } else if ( m_dwCurrFrame < m_dwEndFrame ) { if ( m_bCurrMtn != _MT_PUSHBACK ) SetMoving(); else SetBackStepMoving(); } return TRUE; } return FALSE; } /****************************************************************************************************************** 함수명 : CActor::DrawActor() 작성자 : 작성일 : 목적 : 입력 : BOOL bFocused BOOL bShadowAblended 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CActor::DrawActor(CMapHandler* pxMap, BOOL bFocused, BOOL bShadowAblended, BOOL bUseScrnPos, BOOL bDrawShadow) { // 좌표처리. if ( bUseScrnPos ) { m_shScrnPosX = (m_wPosX - pxMap->m_shStartViewTileX) * _CELL_WIDTH + _VIEW_CELL_X_START - pxMap->m_shViewOffsetX + m_shShiftPixelX; m_shScrnPosY = (m_wPosY - pxMap->m_shStartViewTileY) * _CELL_HEIGHT+ _VIEW_CELL_Y_START - pxMap->m_shViewOffsetY + m_shShiftPixelY; } BYTE bShadowType; SHORT shShadowPX; SHORT shShadowPY; if ( m_pxActorImage ) { SHORT shPX, shPY; DWORD dwCurrFrm; if ( !m_bReverse ) { if ( m_bBackStepFrameCnt ) dwCurrFrm = m_dwEndFrame - (m_dwCurrFrame - m_dwFstFrame) -1; else dwCurrFrm = m_dwCurrFrame; } else { if ( m_bBackStepFrameCnt ) dwCurrFrm = m_dwCurrFrame; else dwCurrFrm = m_dwEndFrame - (m_dwCurrFrame - m_dwFstFrame) -1; } if ( m_pxActorImage->NewSetIndex(dwCurrFrm) ) { shPX = m_pxActorImage->m_lpstNewCurrWilImageInfo->shPX; shPY = m_pxActorImage->m_lpstNewCurrWilImageInfo->shPY; bShadowType = m_pxActorImage->m_lpstNewCurrWilImageInfo->bShadow; shShadowPX = m_pxActorImage->m_lpstNewCurrWilImageInfo->shShadowPX; shShadowPY = m_pxActorImage->m_lpstNewCurrWilImageInfo->shShadowPY; SetRect(&m_rcActor, m_shScrnPosX + shPX, m_shScrnPosY + shPY, m_shScrnPosX + shPX + m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_shScrnPosY + shPY + m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight); if ( ( m_rcActor.right - m_rcActor.left ) > _CELL_WIDTH + _TARGETRGN_GAPX ) { m_rcTargetRgn.left = m_rcActor.left + ( (m_rcActor.right - m_rcActor.left) - (_CELL_WIDTH + _TARGETRGN_GAPX) )/2; m_rcTargetRgn.right = m_rcActor.left + ( (m_rcActor.right - m_rcActor.left) + (_CELL_WIDTH + _TARGETRGN_GAPX) )/2; } else { m_rcTargetRgn.left = m_rcActor.left; m_rcTargetRgn.right = m_rcActor.right; } if ( ( m_rcActor.bottom - m_rcActor.top ) > _CELL_HEIGHT + _TARGETRGN_GAPY ) { m_rcTargetRgn.top = m_rcActor.top + ( (m_rcActor.bottom - m_rcActor.top) - (_CELL_HEIGHT + _TARGETRGN_GAPY) )/2; m_rcTargetRgn.bottom = m_rcActor.top + ( (m_rcActor.bottom - m_rcActor.top) + (_CELL_HEIGHT + _TARGETRGN_GAPY) )/2; } else { m_rcTargetRgn.top = m_rcActor.top; m_rcTargetRgn.bottom = m_rcActor.bottom; } INT nStartX1 = m_shScrnPosX + shShadowPX; INT nStartY1 = m_shScrnPosY + shShadowPY; BYTE bOpaRate = 70; WORD wState = GetCharState(); // 몬스터 그림자 파일 적용. if ( bDrawShadow ) { CWHWilImageData* pxSahdowImage; pxSahdowImage = &g_xGameProc.m_xImage.m_xImageList[m_bActorImgIdx+_MAX_MONSTER_IMAGE]; if ( pxSahdowImage->NewSetIndex(dwCurrFrm) ) { SHORT shShadowPX, shShadowPY; if ( m_wABlendDelay || wState==_STATE_ABLEND || bShadowAblended ) { shShadowPX = pxSahdowImage->m_lpstNewCurrWilImageInfo->shPX; shShadowPY = pxSahdowImage->m_lpstNewCurrWilImageInfo->shPY; g_xMainWnd.DrawWithABlendCompDataWithBackBuffer(m_shScrnPosX+shShadowPX, m_shScrnPosY+shShadowPY, pxSahdowImage->m_lpstNewCurrWilImageInfo->shWidth, pxSahdowImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)pxSahdowImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, 0XFFFF, 0XFFFF, bOpaRate); } else { shShadowPX = pxSahdowImage->m_lpstNewCurrWilImageInfo->shPX; shShadowPY = pxSahdowImage->m_lpstNewCurrWilImageInfo->shPY; if ( !m_bIsDead ) g_xMainWnd.DrawWithImageForCompClipRgn(m_shScrnPosX+shShadowPX, m_shScrnPosY+shShadowPY, pxSahdowImage->m_lpstNewCurrWilImageInfo->shWidth, pxSahdowImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)pxSahdowImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, 0XFFFF, 0XFFFF, bFocused); } } // 계산해서 그리기. else { // 그림자를 그린다. if ( m_wABlendDelay || wState==_STATE_ABLEND || bShadowAblended ) { if ( bOpaRate < 0 && bOpaRate > 100 ) bOpaRate = 0; bShadowAblended = TRUE; } if ( !m_bIsDead ) { g_xMainWnd.DrawWithShadowABlend( nStartX1, nStartY1, m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxActorImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, g_xGameProc.m_wShadowClr, bShadowAblended, bShadowType, bOpaRate); } else { g_xMainWnd.DrawWithShadowABlend( m_rcActor.left+3, m_rcActor.top+2, m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxActorImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, g_xGameProc.m_wShadowClr, bShadowAblended, 50, bOpaRate); } } } if ( m_wABlendDelay ) { if ( !m_bABlendRev ) bOpaRate = 100 - ( (m_wABlendCurrDelay * 100) / m_wABlendDelay ); else bOpaRate = ( (m_wABlendCurrDelay * 100) / m_wABlendDelay ); } if ( bOpaRate < 0 && bOpaRate > 100 ) bOpaRate = 0; if ( bFocused ) { if ( !m_bABlendRev ) bOpaRate -= 20; else bOpaRate += 20; } DrawWithEffected(m_rcActor.left, m_rcActor.top, m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxActorImage->m_pbCurrImage, 0XFFFF, 0XFFFF, bFocused, bOpaRate, wState); DrawEffect(); return TRUE; } } return FALSE; } /****************************************************************************************************************** 함수명 : CActor::DrawHPBar() 작성자 : 작성일 : 목적 : 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CActor::DrawHPBar() { if ( m_bOpenHealth ) { FLOAT fHPPercent = (FLOAT)((FLOAT)m_bHPPercent/100); RECT rcHP = {0, 0, (36*fHPPercent), 4}; g_xGameProc.m_xImage.m_xImageList[_IMAGE_PROGUSE].NewSetIndex(2); g_xMainWnd.DrawWithImageForComp( m_shScrnPosX+7, m_shScrnPosY-53, g_xGameProc.m_xImage.m_xImageList[_IMAGE_PROGUSE].m_lpstNewCurrWilImageInfo->shWidth, g_xGameProc.m_xImage.m_xImageList[_IMAGE_PROGUSE].m_lpstNewCurrWilImageInfo->shHeight, (WORD*)g_xGameProc.m_xImage.m_xImageList[_IMAGE_PROGUSE].m_pbCurrImage); g_xGameProc.m_xImage.m_xImageList[_IMAGE_PROGUSE].NewSetIndex(3); g_xMainWnd.DrawWithImageForComp( m_shScrnPosX+7, m_shScrnPosY-53, rcHP, (WORD*)g_xGameProc.m_xImage.m_xImageList[_IMAGE_PROGUSE].m_pbCurrImage); } } /****************************************************************************************************************** 함수명 : CActor::DrawName() 작성자 : 작성일 : 목적 : 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CActor::DrawName() { SIZE sizeLen; sizeLen = g_xMainWnd.GetStrLength(NULL, NULL, m_szName); // RECT rc = {m_shScrnPosX+(_CELL_WIDTH-sizeLen.cx)/2, m_shScrnPosY-25, m_shScrnPosX+(_CELL_WIDTH+sizeLen.cx)/2, m_shScrnPosY-25+20}; RECT rc = {m_rcActor.left + (m_rcActor.right-m_rcActor.left-sizeLen.cx)/2, m_rcActor.top + (m_rcActor.bottom-m_rcActor.top-sizeLen.cy)/2, m_rcActor.left + (m_rcActor.right-m_rcActor.left+sizeLen.cx)/2, m_rcActor.top + (m_rcActor.bottom-m_rcActor.top+sizeLen.cy)/2}; RECT rcLeft = {rc.left+1, rc.top-1, rc.right+1, rc.bottom-1}; g_xMainWnd.PutsHan(NULL, rc, RGB(10, 10, 10), RGB(0, 0, 0), m_szName); g_xMainWnd.PutsHan(NULL, rcLeft, m_dwNameClr, RGB(0, 0, 0), m_szName); } VOID CActor::ChatMsgAdd() { CHAR szDivied[MAX_PATH*2]; ZeroMemory(szDivied, MAX_PATH*2); g_xMainWnd.StringDivide(_CHAT_WIDTH, m_nDividedChatLine, m_szChatMsg, szDivied); sscanf(szDivied, "%[^`]%*c %[^`]%*c %[^`]%*c %[^`]%*c %[^`]%*c", m_szChatMsgArg[0], m_szChatMsgArg[1], m_szChatMsgArg[2], m_szChatMsgArg[3], m_szChatMsgArg[4]); m_wCurrChatDelay = 0; } VOID CActor::ShowMessage(INT nLoopTime) { if ( m_szChatMsg[0] != NULL ) { m_wCurrChatDelay += nLoopTime; } if ( m_wCurrChatDelay > 3000 ) { m_wCurrChatDelay = 0; ZeroMemory(m_szChatMsg, MAX_PATH); ZeroMemory(m_szChatMsgArg, MAX_PATH*5); } if ( m_szChatMsg[0] != NULL ) { INT nStartX = m_shScrnPosX + 28 - _CHAT_WIDTH/2; INT nStartY; /* if ( m_stFeatureEx.bHorse == _HORSE_NONE ) nStartY = m_shScrnPosY - 55; else */ nStartY = m_shScrnPosY - 55; RECT rcBack; if ( m_nDividedChatLine == 1 ) { SIZE sizeLen; sizeLen = g_xMainWnd.GetStrLength(NULL, NULL, m_szChatMsgArg[0]); nStartX = m_shScrnPosX + 28 - sizeLen.cx/2; SetRect(&rcBack, nStartX, nStartY-14-4, nStartX+sizeLen.cx, nStartY); } else SetRect(&rcBack, nStartX, nStartY-m_nDividedChatLine*14-4, nStartX+_CHAT_WIDTH, nStartY); if ( g_xMainWnd.Get3DDevice() ) { if( SUCCEEDED(g_xMainWnd.Get3DDevice()->BeginScene()) ) { D3DVECTOR vTrans; D3DMATRIX matTrans; D3DMATRIX matScale; D3DMATRIX matWorld; D3DMATRIX matWorldOriginal; g_xMainWnd.Get3DDevice()->GetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal); D3DMATERIAL7 mtrl; vTrans.x = (FLOAT)nStartX-400+(rcBack.right-rcBack.left)/2; vTrans.y = (FLOAT)-nStartY+300+(rcBack.bottom-rcBack.top)/2; vTrans.z = 0; D3DUtil_SetTranslateMatrix(matTrans, vTrans); D3DUtil_SetScaleMatrix(matScale, (FLOAT)rcBack.right-rcBack.left, (FLOAT)rcBack.bottom-rcBack.top, 0.0f); D3DMath_MatrixMultiply(matWorld, matScale, matTrans); g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld); D3DUtil_InitMaterial(mtrl, (FLOAT)80/255.0f, (FLOAT)60/255.0f, (FLOAT)40/255.0f); mtrl.diffuse.a = 120/255.0f; g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl); g_xMainWnd.Get3DDevice()->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE ); g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, TRUE); g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA); g_xMainWnd.Get3DDevice()->SetTexture(0, NULL); g_xMainWnd.Get3DDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX, m_avBoard, 4, NULL); // 원상복귀. ZeroMemory(&mtrl, sizeof(mtrl)); mtrl.diffuse.r = mtrl.diffuse.g = mtrl.diffuse.b = 0.1f; mtrl.ambient.r = mtrl.ambient.g = mtrl.ambient.b = 1.0f; g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl); g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); g_xMainWnd.Get3DDevice()->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE); g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, FALSE); g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_SRCBLEND , D3DBLEND_ONE); g_xMainWnd.Get3DDevice()->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal); g_xMainWnd.Get3DDevice()->EndScene(); } } for ( INT nCnt = 0; nCnt < m_nDividedChatLine; nCnt++ ) { SIZE sizeLen; sizeLen = g_xMainWnd.GetStrLength(NULL, NULL, m_szChatMsgArg[nCnt]); if ( m_nDividedChatLine != 1 ) { if ( nCnt == m_nDividedChatLine-1 ) { nStartX += (_CHAT_WIDTH-sizeLen.cx)/2; } } g_xMainWnd.PutsHan(g_xMainWnd.GetBackBuffer(), nStartX, nStartY-(m_nDividedChatLine-nCnt)*14, RGB(255,255,255), RGB(0,0,0), m_szChatMsgArg[nCnt]); } } } /****************************************************************************************************************** CNPC Class *******************************************************************************************************************/ /****************************************************************************************************************** 함수명 : CNPC::DrawActor() 작성자 : 작성일 : 목적 : 입력 : CMapHandler* pxMap BOOL bFocused BOOL bShadowAblended 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CNPC::DrawActor(CMapHandler* pxMap, BOOL bFocused, BOOL bShadowAblended, BOOL bUseScrnPos, BOOL bDrawShadow) { // 좌표처리. m_shScrnPosX = (m_wPosX - pxMap->m_shStartViewTileX) * _CELL_WIDTH + _VIEW_CELL_X_START - pxMap->m_shViewOffsetX + m_shShiftPixelX; m_shScrnPosY = (m_wPosY - pxMap->m_shStartViewTileY) * _CELL_HEIGHT+ _VIEW_CELL_Y_START - pxMap->m_shViewOffsetY + m_shShiftPixelY; BYTE bShadowType; SHORT shShadowPX; SHORT shShadowPY; if ( m_pxActorImage ) { SHORT shPX, shPY; m_pxActorImage->NewSetIndex(m_dwCurrFrame); shPX = m_pxActorImage->m_lpstNewCurrWilImageInfo->shPX; shPY = m_pxActorImage->m_lpstNewCurrWilImageInfo->shPY; bShadowType = m_pxActorImage->m_lpstNewCurrWilImageInfo->bShadow; shShadowPX = m_pxActorImage->m_lpstNewCurrWilImageInfo->shShadowPX; shShadowPY = m_pxActorImage->m_lpstNewCurrWilImageInfo->shShadowPY; SetRect(&m_rcActor, m_shScrnPosX + shPX, m_shScrnPosY + shPY, m_shScrnPosX + shPX + m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_shScrnPosY + shPY + m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight); if ( ( m_rcActor.right - m_rcActor.left ) > _CELL_WIDTH + _TARGETRGN_GAPX ) { m_rcTargetRgn.left = m_rcActor.left + ( (m_rcActor.right - m_rcActor.left) - (_CELL_WIDTH + _TARGETRGN_GAPX) )/2; m_rcTargetRgn.right = m_rcActor.left + ( (m_rcActor.right - m_rcActor.left) + (_CELL_WIDTH + _TARGETRGN_GAPX) )/2; } else { m_rcTargetRgn.left = m_rcActor.left; m_rcTargetRgn.right = m_rcActor.right; } if ( ( m_rcActor.bottom - m_rcActor.top ) > _CELL_HEIGHT + _TARGETRGN_GAPY ) { m_rcTargetRgn.top = m_rcActor.top + ( (m_rcActor.bottom - m_rcActor.top) - (_CELL_HEIGHT + _TARGETRGN_GAPY) )/2; m_rcTargetRgn.bottom = m_rcActor.top + ( (m_rcActor.bottom - m_rcActor.top) + (_CELL_HEIGHT + _TARGETRGN_GAPY) )/2; } else { m_rcTargetRgn.top = m_rcActor.top; m_rcTargetRgn.bottom = m_rcActor.bottom; } // 캐릭터 그림자. INT nStartX1 = m_shScrnPosX + shShadowPX; INT nStartY1 = m_shScrnPosY + shShadowPY; BYTE bOpaRate = 70; WORD wState = GetCharState(); // 그림자를 그린다. if ( m_wABlendDelay || wState==_STATE_ABLEND ) { bShadowAblended = TRUE; } if ( bDrawShadow ) g_xMainWnd.DrawWithShadowABlend( nStartX1, nStartY1, m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxActorImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, g_xGameProc.m_wShadowClr, bShadowAblended, bShadowType, bOpaRate); if ( m_wABlendDelay ) { if ( !m_bABlendRev ) bOpaRate = 100 - ( (m_wABlendCurrDelay * 100) / m_wABlendDelay ); else bOpaRate = ( (m_wABlendCurrDelay * 100) / m_wABlendDelay ); } if ( bOpaRate < 0 && bOpaRate > 100 ) bOpaRate = 0; if ( bFocused ) { if ( !m_bABlendRev ) bOpaRate -= 20; else bOpaRate += 20; } DrawWithEffected(m_rcActor.left, m_rcActor.top, m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxActorImage->m_pbCurrImage, 0XFFFF, 0XFFFF, bFocused, bOpaRate, wState); return TRUE; } return FALSE; } VOID CNPC::OnTurn(LPPACKETMSG lpPacketMsg) { BYTE bDir; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = LOBYTE(lpPacketMsg->stDefMsg.wSeries); m_bLightSize = HIBYTE(lpPacketMsg->stDefMsg.wSeries); OnCharDescPacket(lpPacketMsg); SetMotionFrame(_MT_NPC_STAND, bDir); } VOID CNPC::OnHit(LPPACKETMSG lpPacketMsg) { BYTE bDir; bDir = lpPacketMsg->stDefMsg.wSeries; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; SetMotionFrame(_MT_NPC_ACT01, bDir); } /****************************************************************************************************************** 함수명 : CNPC::UpdatePacketState() 작성자 : 작성일 : 목적 : 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CNPC::UpdatePacketState() { // if ( m_bCurrMtn == _MT_NPC_STAND ) { LPPACKETMSG lpPacketMsg; SHORT shLeftMsgCnt = m_xPacketQueue.GetCount(); if ( shLeftMsgCnt > 0 ) { lpPacketMsg = (LPPACKETMSG)m_xPacketQueue.PopQ(); if ( shLeftMsgCnt >= 3 ) m_bMsgHurryCheck = TRUE; else m_bMsgHurryCheck = FALSE; if ( lpPacketMsg ) { switch ( lpPacketMsg->stDefMsg.wIdent ) { case SM_OPENHEALTH: { OnOpenHealth(lpPacketMsg); break; } case SM_CLOSEHEALTH: { OnCloseHealth(lpPacketMsg); break; } case SM_CHANGELIGHT: { OnChangeLight(lpPacketMsg); break; } case SM_USERNAME: { OnUserName(lpPacketMsg); break; } case SM_CHANGENAMECOLOR: { OnChangeNameClr(lpPacketMsg); break; } case SM_HEALTHSPELLCHANGED: { OnHealthSpellChanged(lpPacketMsg); break; } case SM_TURN: { OnTurn(lpPacketMsg); break; } case SM_HIT: { OnHit(lpPacketMsg); break; } default: { break; } } } SAFE_DELETE(lpPacketMsg); return TRUE; } } return FALSE; } /****************************************************************************************************************** 함수명 : CNPC::UpdateMotionState() 작성자 : 작성일 : 목적 : 입력 : INT nLoopTime BOOL bIsMoveTime 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CNPC::UpdateMotionState(INT nLoopTime, BOOL bIsMoveTime) { m_wCurrDelay += nLoopTime; if ( m_wCurrDelay > m_wDelay ) { m_wCurrDelay = 0; if ( m_dwCurrFrame < m_dwEndFrame ) m_dwCurrFrame++; } UpdatePacketState(); if ( m_dwCurrFrame >= m_dwEndFrame ) m_dwCurrFrame = m_dwFstFrame; } /****************************************************************************************************************** CHero Class *******************************************************************************************************************/ /****************************************************************************************************************** 함수명 : CHero::CHero() 작성자 : 작성일 : 목적 : 출력 : [일자][수정자] : 수정내용 *******************************************************************************************************************/ CHero::CHero() { InitActor(); } /****************************************************************************************************************** 함수명 : CHero::~CHero() 작성자 : 작성일 : 목적 : 출력 : [일자][수정자] : 수정내용 *******************************************************************************************************************/ CHero::~CHero() { DestroyActor(); } VOID CHero::InitActor() { CActor::InitActor(); ZeroMemory(&m_stFeatureEx, sizeof(FEATUREEX)); m_bWeaponImgIdx = 0; m_bHairImgIdx = 0; m_bHorseImgIdx = 0; m_bYedoCnt = 0; m_bFireHitCnt = 0; m_shHitSpeed = 0; m_pxHairImage = NULL; m_pxWeaponImage = NULL; m_pxHorseImage = NULL; m_bUseBanwol = FALSE; m_bUseErgum = FALSE; m_bIsMon = FALSE; m_bShieldCurrFrm = 0; m_wShieldCurrDelay = 0; m_dwCurrHairFrame = 0; m_dwCurrWeaponFrame = 0; m_dwCurrHorseFrame = 0; m_shCurrMagicID = 0; ZeroMemory(&m_rcHair, sizeof(RECT)); ZeroMemory(&m_rcWeapon, sizeof(RECT)); ZeroMemory(&m_rcHorse, sizeof(RECT)); } VOID CHero::DestroyActor() { CActor::DestroyActor(); InitActor(); } /****************************************************************************************************************** 함수명 : CHero::Create() 작성자 : 작성일 : 목적 : 입력 : CImageHandler* pxImgHandler WORD wActor BYTE bMtn WORD bDir WORD wPosX WORD wPosY FEATURE stFeature 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CHero::Create(CImageHandler* pxImgHandler, BYTE bMtn, BYTE bDir, WORD wPosX, WORD wPosY, FEATURE* pstFeature, FEATUREEX* pstFeatureEx) { if ( CActor::Create(pxImgHandler, pstFeature, bMtn, bDir, wPosX, wPosY) ) { m_bIsMon = FALSE; // memcpy(&m_stFeatureEx, pstFeatureEx, sizeof(FEATUREEX)); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! m_stFeatureEx.bHorse = 0; m_stFeatureEx.wDressColor = 0XFF; m_stFeatureEx.wHairColor = 0XFF; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if ( m_stFeature.bHair >= _MAX_HAIR ) m_stFeature.bHair = _HAIR_NONE; if ( m_stFeature.bWeapon >= _MAX_WEAPON ) m_stFeature.bWeapon = _WEAPON_NONE; if ( m_stFeatureEx.bHorse >= _MAX_HORSE ) m_stFeatureEx.bHorse= _HORSE_NONE; m_bHorseImgIdx = _IMAGE_HORSE; if ( m_stFeature.bGender == _GENDER_MAN ) { m_bHairImgIdx = _IMAGE_M_HAIR; if ( m_stFeature.bWeapon != _WEAPON_NONE ) m_bWeaponImgIdx = _IMAGE_M_WEAPON1+(m_stFeature.bWeapon-1)/10; } else if ( m_stFeature.bGender == _GENDER_WOMAN ) { m_bHairImgIdx = _IMAGE_WM_HAIR; if ( m_stFeature.bWeapon != _WEAPON_NONE ) m_bWeaponImgIdx = _IMAGE_WM_WEAPON1+(m_stFeature.bWeapon-1)/10; } else return FALSE; if ( m_stFeature.bHair != _HAIR_NONE ) m_pxHairImage = &pxImgHandler->m_xImageList[m_bHairImgIdx]; else m_pxHairImage = NULL; if ( m_stFeature.bWeapon != _WEAPON_NONE ) m_pxWeaponImage = &pxImgHandler->m_xImageList[m_bWeaponImgIdx]; else m_pxWeaponImage = NULL; if ( m_stFeatureEx.bHorse != _HORSE_NONE ) m_pxHorseImage = &pxImgHandler->m_xImageList[m_bHorseImgIdx]; else m_pxHorseImage = NULL; return TRUE; } return FALSE; } VOID CHero::PlayActSound() { INT nWaveNum = -1; if ( m_dwCurrFrame == m_dwFstFrame+1 && m_bCurrMtn == _MT_HITTED ) { switch ( m_stHitter.bWeapon ) { case 21: case 24: // 단검, 비단검. case 8: case 9: // 목검, 아리수목검. case 18: case 22: case 23: case 26: case 27: case 28: case 30: // 사모검. 청동검. 철검. 청음검. 벽사검. 천령. 곡성검. case 1: case 4: case 11: case 13: case 14: case 20: case 25: case 29: case 31: // 유월도. 묵청대도. 육합도. 군도. 도룡보도. 사각도. 세첨도. 예도. 초혼도. nWaveNum = 70; break; case 5: case 10: case 12: // 삼적대부. 청동도끼. 연자부. case 15: // 파뇌진당. nWaveNum = 71; break; case 2: case 3: case 6: case 7: case 16: case 17: case 19: // 삼지창. 천형목. 홍아창. 곡괭이. 청마창, 용아장. 제마봉 nWaveNum = 72; break; default: nWaveNum = 73; // 맨손. break; } if ( m_stFeature.bDress == 3 ) // 미갑주. nWaveNum += 10; } else if ( m_dwCurrFrame == m_dwFstFrame+2 && m_bCurrMtn == _MT_HITTED ) { if ( m_stFeature.bGender == _GENDER_MAN ) nWaveNum = 138; else nWaveNum = 139; } else if ( m_dwCurrFrame == m_dwFstFrame+1 && m_bCurrMtn == _MT_DIE ) { if ( m_stFeature.bGender == _GENDER_MAN ) nWaveNum = 144; else nWaveNum = 145; } else if ( m_dwCurrFrame == m_dwFstFrame+1 && m_bCurrMtn >= _MT_ONEVSWING && m_bCurrMtn <= _MT_SPEARHSWING ) { if ( m_bFireHitCnt == 2 ) { nWaveNum = 137; } else if ( m_bYedoCnt == 2 ) { /* if ( m_stFeature.bGender == _GENDER_MAN ) { g_xSound.PlayActorWav(m_wPosX, m_wPosY, g_xGameProc.m_xMyHero.m_wPosX, g_xGameProc.m_xMyHero.m_wPosY, 130); } else { g_xSound.PlayActorWav(m_wPosX, m_wPosY, g_xGameProc.m_xMyHero.m_wPosX, g_xGameProc.m_xMyHero.m_wPosY, 131); } */ m_bYedoCnt = 0; } else if ( m_bUseBanwol ) { nWaveNum = 133; } else if ( m_bUseErgum ) { nWaveNum = 132; } } else if ( m_dwCurrFrame == m_dwFstFrame+2 && m_bCurrMtn >= _MT_ONEVSWING && m_bCurrMtn <= _MT_SPEARHSWING ) { switch ( m_stFeature.bWeapon ) { case 21: case 24: // 단검, 비단검. nWaveNum = 50; break; case 8: case 9: // 목검, 아리수목검. nWaveNum = 51; break; case 18: case 22: case 23: case 26: case 27: case 28: case 30: // 사모검. 청동검. 철검. 청음검. 벽사검. 천령. 곡성검. nWaveNum = 52; break; case 1: case 4: case 11: case 13: case 14: case 20: case 25: case 29: case 31: // 유월도. 묵청대도. 육합도. 군도. 도룡보도. 사각도. 세첨도. 예도. 초혼도. nWaveNum = 53; break; case 5: case 10: case 12: // 삼적대부. 청동도끼. 연자부. nWaveNum = 54; break; case 15: // 파뇌진당. nWaveNum = 55; break; case 2: case 3: case 6: case 7: case 16: case 17: case 19: // 삼지창. 천형목. 홍아창. 곡괭이. 청마창, 용아장. 제마봉 nWaveNum = 56; break; default: nWaveNum = 57; // 맨손. break; } } else if ( m_dwCurrFrame == m_dwFstFrame+1 && (m_bCurrMtn == _MT_SPELL1 || m_bCurrMtn == _MT_SPELL2) ) { const INT nMagicSndTbl[31] = { 0, 6, 8, 14, 15, 9, 0, 20, 21, 32, 1, 2, 16, 29, 24, 10, 17, 33, 19, 31, 28, 22, 13, 21, 5, 0, 12, 11, 0, 18, 30, }; if ( m_shCurrMagicID < 31 ) { nWaveNum = nMagicSndTbl[m_shCurrMagicID]*10 + 10000; } if ( nWaveNum < 10010 ) nWaveNum = -1; } /* if ( nWaveNum != -1 ) g_xSound.PlayActorWav(m_wPosX, m_wPosY, g_xGameProc.m_xMyHero.m_wPosX, g_xGameProc.m_xMyHero.m_wPosY, nWaveNum); */} VOID CHero::PlayMoveSound() { if ( m_bCurrMtn == _MT_WALK || m_bCurrMtn == _MT_RUN || m_bCurrMtn == _MT_HORSEWALK || m_bCurrMtn == _MT_HORSERUN || m_bCurrMtn == _MT_MOODEPO || m_bCurrMtn == _MT_PUSHBACK ) { /* if ( m_dwCurrFrame == m_dwEndFrame-5 || m_bBackStepFrame == m_dwEndFrame-5 ) g_xSound.PlayActorWav(m_wPosX, m_wPosY, g_xGameProc.m_xMyHero.m_wPosX, g_xGameProc.m_xMyHero.m_wPosY, 1,100); if ( m_dwCurrFrame == m_dwEndFrame-2 || m_bBackStepFrame == m_bBackStepFrameCnt-2 ) g_xSound.PlayActorWav(m_wPosX, m_wPosY, g_xGameProc.m_xMyHero.m_wPosX, g_xGameProc.m_xMyHero.m_wPosY, 1,100); */ } } VOID CHero::ShowShield() { if ( m_nState & 0X100000 ) { WORD wShieldFrm; if ( m_bCurrMtn == _MT_HITTED ) wShieldFrm = m_bShieldCurrFrm + 853; else wShieldFrm = m_bShieldCurrFrm + 850; if ( g_xMainWnd.Get3DDevice() ) { if( SUCCEEDED(g_xMainWnd.Get3DDevice()->BeginScene()) ) { D3DVECTOR vTrans; D3DMATRIX matTrans; D3DMATRIX matScale; D3DMATRIX matRot; D3DMATRIX matWorld; D3DMATRIX matWorldOriginal; g_xMainWnd.Get3DDevice()->GetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal); D3DMATERIAL7 mtrl; CWHWilImageData* pxWilImg; pxWilImg = &g_xGameProc.m_xImage.m_xImageList[_IMAGE_MAGIC]; if ( pxWilImg->NewSetIndex(wShieldFrm) ) { // if ( !D3DWILTextr_GetSurface(pxWilImg->m_szWilFileName, wShieldFrm) ) // D3DWILTextr_Restore(pxWilImg->m_szWilFileName, wShieldFrm, g_xMainWnd.Get3DDevice()); vTrans.x = (FLOAT)m_shScrnPosX+(FLOAT)pxWilImg->m_lpstNewCurrWilImageInfo->shWidth/2+pxWilImg->m_lpstNewCurrWilImageInfo->shPX-400; vTrans.y = (FLOAT)-m_shScrnPosY-(FLOAT)pxWilImg->m_lpstNewCurrWilImageInfo->shHeight/2-pxWilImg->m_lpstNewCurrWilImageInfo->shPY+300; vTrans.z = 0; D3DUtil_SetTranslateMatrix(matTrans, vTrans); D3DUtil_SetScaleMatrix(matScale, (FLOAT)pxWilImg->m_lpstNewCurrWilImageInfo->shWidth, (FLOAT)pxWilImg->m_lpstNewCurrWilImageInfo->shHeight, 0.0f); D3DMath_MatrixMultiply(matWorld, matScale, matTrans); g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld); // g_xMainWnd.Get3DDevice()->SetTexture(0, D3DWILTextr_GetSurface(pxWilImg->m_szWilFileName, wShieldFrm)); g_xGameProc.m_xImage.AddTextr(_TEXTR_FILE_MAGIC,_IMAGE_MAGIC, wShieldFrm); LPDIRECTDRAWSURFACE7 lpddsTextr = g_xGameProc.m_xImage.GetTextrImg(_TEXTR_FILE_MAGIC, _IMAGE_MAGIC, wShieldFrm); g_xMainWnd.Get3DDevice()->SetTexture(0, lpddsTextr); D3DUtil_InitMaterial(mtrl, (FLOAT)255/255.0f, (FLOAT)255/255.0f, (FLOAT)255/255.0f); mtrl.diffuse.a = 0/255.0f; g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl); SetBlendRenderState(g_xMainWnd.Get3DDevice(), _BLEND_LIGHTINV, mtrl); g_xMainWnd.Get3DDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX, m_avBoard, 4, NULL); // 원상복귀. ZeroMemory(&mtrl, sizeof(mtrl)); mtrl.diffuse.r = mtrl.diffuse.g = mtrl.diffuse.b = 0.1f; mtrl.ambient.r = mtrl.ambient.g = mtrl.ambient.b = 1.0f; g_xMainWnd.Get3DDevice()->SetMaterial(&mtrl); ResetBlendenderState(g_xMainWnd.Get3DDevice()); g_xMainWnd.Get3DDevice()->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal); } g_xMainWnd.Get3DDevice()->EndScene(); } } } } /****************************************************************************************************************** 함수명 : CHero::UpdateMove(BOOL bIsMoveTime) 작성자 : 작성일 : 목적 : 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CHero::UpdateMove(BOOL bIsMoveTime) { if ( m_bCurrMtn == _MT_WALK || m_bCurrMtn == _MT_RUN || m_bCurrMtn == _MT_HORSEWALK || m_bCurrMtn == _MT_HORSERUN || m_bCurrMtn == _MT_MOODEPO || m_bCurrMtn == _MT_PUSHBACK ) { m_wCurrDelay = 0; if ( bIsMoveTime ) { if ( m_bCurrMtn == _MT_PUSHBACK ) { m_bBackStepFrame += 2; if ( m_bBackStepFrame >= m_bBackStepFrameCnt ) { m_dwCurrFrame++; m_bBackStepFrame = m_bBackStepFrameCnt; } } else if ( m_bCurrMtn == _MT_MOODEPO ) { m_dwCurrFrame+=2; if ( m_dwCurrFrame >= m_dwEndFrame ) m_dwCurrFrame = m_dwEndFrame; } else { m_dwCurrFrame++; PlayMoveSound(); if ( m_bMsgHurryCheck ) { m_dwCurrFrame++; } } if ( m_bCurrMtn == _MT_PUSHBACK ) { if ( m_bBackStepFrame >= m_bBackStepFrameCnt-m_bMoveNextFrmCnt && !m_bIsMoved ) { SetMoved(); m_bIsMoved = TRUE; } } else { if ( m_dwCurrFrame >= m_dwEndFrame-m_bMoveNextFrmCnt && !m_bIsMoved ) { SetMoved(); m_bIsMoved = TRUE; } } } // 연속적인 프레임 중에서 해야할일. if ( m_dwCurrFrame >= m_dwEndFrame ) { m_dwCurrFrame = m_dwEndFrame - 1; m_shShiftTileX = 0; m_shShiftTileY = 0; m_shShiftPixelX = 0; m_shShiftPixelY = 0; m_dwCurrEffectFrame = 0; m_dwFstEffectFrame = 0; m_dwEndEffectFrame = 0; m_bEffectFrame = 0; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; m_bUseEffect = FALSE; m_bUseSwordEffect = FALSE; m_dwCurrFrame = m_dwFstFrame; m_bBackStepFrame = 0; m_bBackStepFrameCnt = 0; m_bIsMoved = FALSE; if ( m_stFeatureEx.bHorse == _HORSE_NONE ) { if ( m_bWarMode ) SetMotionFrame(_MT_ATTACKMODE, m_bCurrDir); else SetMotionFrame(_MT_STAND, m_bCurrDir); } else { SetMotionFrame(_MT_HORSESTAND, m_bCurrDir); } } else if ( m_dwCurrFrame < m_dwEndFrame ) { if ( m_bCurrMtn != _MT_PUSHBACK ) SetMoving(); else SetBackStepMoving(); } return TRUE; } return FALSE; } VOID CHero::OnCharDescPacket(LPPACKETMSG lpPacketMsg) { CHARDESC stCharDesc; FEATURE stFeature; fnDecode6BitBuf(lpPacketMsg->szEncodeData, (char*)&stCharDesc, sizeof(CHARDESC)); memcpy(&stFeature, &stCharDesc.nFeature, sizeof(FEATURE)); m_nState = stCharDesc.nStatus; if( m_nState & 0X2 ) m_bOpenHealth = TRUE; else m_bOpenHealth = FALSE; ChangeFeature(stFeature, m_stFeatureEx); } VOID CHero::OnFeatureChanged(LPPACKETMSG lpPacketMsg) { FEATURE stFeature; LONG nFeature = MAKELONG(lpPacketMsg->stDefMsg.wParam, lpPacketMsg->stDefMsg.wTag); memcpy(&stFeature, &nFeature, sizeof(LONG)); ChangeFeature(stFeature, m_stFeatureEx); } VOID CHero::OnCharStatusChanged(LPPACKETMSG lpPacketMsg) { m_shHitSpeed = lpPacketMsg->stDefMsg.wSeries; m_nState = MAKELONG(lpPacketMsg->stDefMsg.wParam, lpPacketMsg->stDefMsg.wTag); if( m_nState & 0X2 ) m_bOpenHealth = TRUE; else m_bOpenHealth = FALSE; } VOID CHero::OnRush(LPPACKETMSG lpPacketMsg) { BYTE bDir = lpPacketMsg->stDefMsg.wSeries; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; SetMotionFrame(_MT_MOODEPO, bDir); m_bMoveSpeed = _SPEED_WALK; SetMoving(); } VOID CHero::OnBackStep(LPPACKETMSG lpPacketMsg) { BYTE bDir = lpPacketMsg->stDefMsg.wSeries; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; SetMotionFrame(_MT_PUSHBACK, bDir); if ( m_bCurrDir < 4 ) m_bMoveDir = m_bCurrDir + 4; else m_bMoveDir = m_bCurrDir - 4; m_bBackStepFrame = 0; m_bBackStepFrameCnt = 6; m_bMoveSpeed = _SPEED_WALK; SetBackStepMoving(); } VOID CHero::OnDeath(LPPACKETMSG lpPacketMsg) { BYTE bDir; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = lpPacketMsg->stDefMsg.wSeries; OnCharDescPacket(lpPacketMsg); SetMotionFrame(_MT_DIE, bDir); if ( lpPacketMsg->stDefMsg.wIdent == SM_DEATH ) { m_dwCurrFrame = m_dwEndFrame - 1; m_bIsDead = TRUE; } } VOID CHero::OnWalk(LPPACKETMSG lpPacketMsg) { BYTE bDir; CHARDESC stCharDesc; FEATURE stFeature; // FEATUREEX stFeatureEx; // m_wPosX = lpPacketMsg->stDefMsg.wParam; // m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = LOBYTE(lpPacketMsg->stDefMsg.wSeries); m_bLightSize = HIBYTE(lpPacketMsg->stDefMsg.wSeries); fnDecode6BitBuf(lpPacketMsg->szEncodeData, (char*)&stCharDesc, sizeof(CHARDESC)); // fnDecode6BitBuf(&lpPacketMsg->szEncodeData[_FEATURESIZE*2], (char*)&stFeatureEx, sizeof(FEATUREEX)); memcpy(&stFeature, &stCharDesc.nFeature, sizeof(FEATURE)); m_nState = stCharDesc.nStatus; if( m_nState & 0X2 ) m_bOpenHealth = TRUE; else m_bOpenHealth = FALSE; ChangeFeature(stFeature, m_stFeatureEx); if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionFrame(_MT_WALK, bDir); else SetMotionFrame(_MT_HORSEWALK, bDir); m_bMoveSpeed = _SPEED_WALK; SetMoving(); } VOID CHero::OnRun(LPPACKETMSG lpPacketMsg) { BYTE bDir; CHARDESC stCharDesc; FEATURE stFeature; // FEATUREEX stFeatureEx; // m_wPosX = lpPacketMsg->stDefMsg.wParam; // m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = LOBYTE(lpPacketMsg->stDefMsg.wSeries); m_bLightSize = HIBYTE(lpPacketMsg->stDefMsg.wSeries); fnDecode6BitBuf(lpPacketMsg->szEncodeData, (char*)&stCharDesc, sizeof(CHARDESC)); // fnDecode6BitBuf(&lpPacketMsg->szEncodeData[_CHARDESCSIZE], (char*)&stFeatureEx, sizeof(FEATUREEX)); memcpy(&stFeature, &stCharDesc.nFeature, sizeof(FEATURE)); m_nState = stCharDesc.nStatus; if( m_nState & 0X2 ) m_bOpenHealth = TRUE; else m_bOpenHealth = FALSE; ChangeFeature(stFeature, m_stFeatureEx); if ( m_stFeatureEx.bHorse == _HORSE_NONE ) { SetMotionFrame(_MT_RUN, bDir); m_bMoveSpeed = _SPEED_RUN; } else { SetMotionFrame(_MT_HORSERUN, bDir); m_bMoveSpeed = _SPEED_HORSERUN; } SetMoving(); } VOID CHero::OnTurn(LPPACKETMSG lpPacketMsg) { BYTE bDir; CHARDESC stCharDesc; FEATURE stFeature; INT nPos; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = LOBYTE(lpPacketMsg->stDefMsg.wSeries); m_bLightSize = HIBYTE(lpPacketMsg->stDefMsg.wSeries); fnDecode6BitBuf(lpPacketMsg->szEncodeData, (char*)&stCharDesc, sizeof(CHARDESC)); fnDecode6BitBuf(&lpPacketMsg->szEncodeData[_CHARDESCSIZE], (char*)&m_stFeatureEx , sizeof(FEATUREEX)); if (strlen(lpPacketMsg->szEncodeData) > _CHARDESCSIZE) { nPos = fnDecode6BitBuf(&lpPacketMsg->szEncodeData[_CHARDESCSIZE +_FEATURESIZEEX], m_szName, sizeof(m_szName)); m_szName[nPos] = '\0'; CHAR* szClr = strrchr(m_szName, '/'); if ( szClr ) { m_dwNameClr = GetUserNameColor(atoi(szClr+1)); *szClr = '\0'; } } memcpy(&stFeature, &stCharDesc.nFeature, sizeof(FEATURE)); m_nState = stCharDesc.nStatus; if( m_nState & 0X2 ) m_bOpenHealth = TRUE; else m_bOpenHealth = FALSE; if ( !m_bIsMon ) { ChangeFeature(stFeature, m_stFeatureEx); if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionFrame(_MT_STAND, bDir); else SetMotionFrame(_MT_HORSESTAND, bDir); } else { SetMotionFrame(_MT_MON_STAND, bDir); } } VOID CHero::OnStruck(LPPACKETMSG lpPacketMsg) { MESSAGEBODYWL stMsgBodyWl; FEATURE stFeature; FLOAT wHPRate = (FLOAT)((FLOAT)lpPacketMsg->stDefMsg.wParam/(FLOAT)lpPacketMsg->stDefMsg.wTag); WORD wDamage = lpPacketMsg->stDefMsg.wSeries; m_wHP = lpPacketMsg->stDefMsg.wParam; m_wMAXHP = lpPacketMsg->stDefMsg.wTag; m_bHPPercent = wHPRate*100; m_bShieldCurrFrm = 0; fnDecode6BitBuf(lpPacketMsg->szEncodeData, (char*)&stMsgBodyWl, sizeof(MESSAGEBODYWL)); memcpy(&stFeature, &stMsgBodyWl.lParam1, sizeof(LONG)); if ( !m_bIsMon ) { ChangeFeature(stFeature, m_stFeatureEx); if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionFrame(_MT_HITTED, m_bCurrDir); else SetMotionFrame(_MT_HORSEHIT, m_bCurrDir); } else { SetMotionFrame(_MT_MON_HITTED, m_bCurrDir); } // 몬스터일때. if ( m_stHitter.bGender == _GENDER_MON ) { CMagic* pxMagic; switch ( m_stHitter.bDress ) { case 2: // 케팔로프. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_KEPAL, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this, 0); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 8: // 갑주개미. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_GREATANT, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 14: // 병용개미. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_ANT, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 16: // 드난개미. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_WORKANT, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; case 67: // 촉룡신. pxMagic = new CMagic; pxMagic->CreateMagic(_MONMAGIC_BIGGINE_CHAR, m_wPosX, m_wPosY, m_wPosX, m_wPosY, this); g_xGameProc.m_xMagicList.AddNode(pxMagic); break; default : break; } } ZeroMemory(&m_stHitter, sizeof(FEATURE)); } VOID CHero::OnHit(LPPACKETMSG lpPacketMsg) { BYTE bDir; bDir = lpPacketMsg->stDefMsg.wSeries; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; if ( !m_bIsMon ) { m_dwCurrEffectFrame = 50; m_dwFstEffectFrame = 50; m_dwEndEffectFrame = 60; m_bEffectFrame = 0; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; m_bWarMode = TRUE; if ( lpPacketMsg->stDefMsg.wIdent == SM_WIDEHIT ) { SetMotionFrame(_MT_ONEHSWING, bDir); LoadEffect(&g_xGameProc.m_xImage, _SKILL_BANWOL, bDir); m_bUseSwordEffect = TRUE; } else if ( lpPacketMsg->stDefMsg.wIdent == SM_POWERHIT ) { SetMotionFrame(_MT_ONEVSWING, bDir); LoadEffect(&g_xGameProc.m_xImage, _SKILL_YEDO, bDir); m_bUseSwordEffect = TRUE; } else if ( lpPacketMsg->stDefMsg.wIdent == SM_FIREHIT ) { SetMotionFrame(_MT_ONEVSWING, bDir); LoadEffect(&g_xGameProc.m_xImage, _SKILL_FIRESWORD, bDir); m_bUseSwordEffect = TRUE; } else if ( lpPacketMsg->stDefMsg.wIdent == SM_LONGHIT ) { SetMotionFrame(_MT_ONEVSWING, bDir); LoadEffect(&g_xGameProc.m_xImage, _SKILL_ERGUM, bDir); m_bUseSwordEffect = TRUE; } else { bDir = LOBYTE(lpPacketMsg->stDefMsg.wSeries); BYTE bAttackMode = HIBYTE(lpPacketMsg->stDefMsg.wSeries); SetMotionFrame(_MT_ONEVSWING, bDir); } } } VOID CHero::OnMagicFire(LPPACKETMSG lpPacketMsg) { POINT ptPos; BYTE bMagicID; INT nMagicTargetID, nPos; ptPos.x = lpPacketMsg->stDefMsg.wParam; ptPos.y = lpPacketMsg->stDefMsg.wTag; bMagicID = lpPacketMsg->stDefMsg.wSeries; nPos = fnDecode6BitBuf(lpPacketMsg->szEncodeData, (CHAR*)&nMagicTargetID, sizeof(INT)); if ( bMagicID == _SKILL_SKELLETON ) { return; } if ( bMagicID == _SKILL_SHOOTLIGHTEN ) { CElecMagic* pxElecMagic; pxElecMagic = new CElecMagic; pxElecMagic->CreateMagic(bMagicID, m_wPosX, m_wPosY, ptPos.x, ptPos.y, NULL, nMagicTargetID); g_xGameProc.m_xMagicList.AddNode(pxElecMagic); } // if ( bMagicID == _SKILL_SHOOTLIGHTEN || bMagicID == _SKILL_FIRE ) else if ( bMagicID == _SKILL_FIRE ) { BYTE bDir16 = (BYTE)g_xGameProc.m_xMap.CalcDirection8(m_wPosX, m_wPosY, ptPos.x, ptPos.y); POINT ptTileGap = {0, 0}; POINT ptTileDest = {0, 0}; BYTE bLoopCnt = 0; BYTE bDelay = 0; if ( bMagicID == _SKILL_SHOOTLIGHTEN ) { bLoopCnt = 15; bDelay = 70; } else { bLoopCnt = 5; bDelay = 150; } switch ( bDir16 ) { case 0 : ptTileGap.x = 0; ptTileGap.y = -1; break; case 1 : ptTileGap.x = 1; ptTileGap.y = -1; break; case 2 : ptTileGap.x = 1; ptTileGap.y = 0; break; case 3 : ptTileGap.x = 1; ptTileGap.y = 1; break; case 4 : ptTileGap.x = 0; ptTileGap.y = 1; break; case 5 : ptTileGap.x = -1; ptTileGap.y = 1; break; case 6 : ptTileGap.x = -1; ptTileGap.y = 0; break; case 7 : ptTileGap.x = -1; ptTileGap.y = -1; break; } for ( INT nCnt = 0; nCnt < bLoopCnt; nCnt++ ) { CMagicStream* pxMagicStream; pxMagicStream = new CMagicStream; ptTileDest.x = m_wPosX + ptTileGap.x*(nCnt+1); ptTileDest.y = m_wPosY + ptTileGap.y*(nCnt+1); pxMagicStream->CreateMagic(bMagicID, m_wPosX, m_wPosY, ptTileDest.x, ptTileDest.y, NULL, nMagicTargetID, nCnt*bDelay, ptTileGap); if ( bMagicID == _SKILL_SHOOTLIGHTEN ) g_xGameProc.m_xMagicList.AddNode(pxMagicStream); else g_xGameProc.m_xGroundMagicList.AddNode(pxMagicStream); } } else if ( bMagicID == _SKILL_SHIELD ) { CMagic* pxMagic; pxMagic = new CMagic; pxMagic->CreateMagic(bMagicID, m_wPosX, m_wPosY, m_wPosX, m_wPosY, NULL, m_dwIdentity); g_xGameProc.m_xMagicList.AddNode(pxMagic); } else if ( bMagicID != _SKILL_EARTHFIRE && bMagicID != _SKILL_HOLYSHIELD ) { CMagic* pxMagic; pxMagic = new CMagic; pxMagic->CreateMagic(bMagicID, m_wPosX, m_wPosY, ptPos.x, ptPos.y, NULL, nMagicTargetID); g_xGameProc.m_xMagicList.AddNode(pxMagic); } m_shCurrMagicID = bMagicID; } VOID CHero::OnSpell(LPPACKETMSG lpPacketMsg) { BYTE bMagicDir; INT nMagicID; POINT ptTargetPos; ptTargetPos.x = lpPacketMsg->stDefMsg.wParam; ptTargetPos.y = lpPacketMsg->stDefMsg.wTag; // bDir = lpPacketMsg->stDefMsg.wSeries; // nPos = fnDecode6BitBuf(lpPacketMsg->szEncodeData, szDecodeMsg, sizeof(szDecodeMsg)); // szDecodeMsg[nPos] = '\0'; bMagicDir = g_xGameProc.m_xMap.CalcDirection8(m_wPosX, m_wPosY, ptTargetPos.x, ptTargetPos.y); nMagicID = atoi(lpPacketMsg->szEncodeData); if ( nMagicID == _SKILL_FIREBALL || nMagicID == _SKILL_FIREBALL2 || nMagicID == _SKILL_FIRE || nMagicID == _SKILL_SHOOTLIGHTEN || nMagicID == _SKILL_HANGMAJINBUB || nMagicID== _SKILL_DEJIWONHO || nMagicID == _SKILL_FIRECHARM || nMagicID == _SKILL_BIGCLOAK || nMagicID == _SKILL_SINSU ) LoadEffect(&g_xGameProc.m_xImage, nMagicID, bMagicDir); else LoadEffect(&g_xGameProc.m_xImage, nMagicID); if ( nMagicID == _SKILL_SHOWHP ) m_bEffectFrameCnt = 20; else if ( nMagicID == _SKILL_LIGHTFLOWER ) m_bEffectFrameCnt = 20; else if ( nMagicID == _SKILL_SPACEMOVE ) m_bEffectFrameCnt = 19; else if ( nMagicID == _SKILL_LIGHTENING ) m_bEffectFrameCnt = 17; m_bWarMode = m_bUseEffect = TRUE; /* if ( nMagicID == _SKILL_SHIELD ) { m_dwFstEffectFrame = 50; m_dwEndEffectFrame = 60; m_dwCurrEffectFrame = 50; m_bEffectFrame = 0; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; } */ m_shCurrMagicID = nMagicID; switch( nMagicID ) { case _SKILL_HANGMAJINBUB: case _SKILL_DEJIWONHO: case _SKILL_FIRECHARM: case _SKILL_FIRE: case _SKILL_FIREBALL2: case _SKILL_SINSU: case _SKILL_FIREBALL: case _SKILL_SHOOTLIGHTEN: case _SKILL_BIGCLOAK: SetMotionFrame(_MT_SPELL1, bMagicDir); break; case _SKILL_FIREWIND: case _SKILL_AMYOUNSUL: case _SKILL_TAMMING: case _SKILL_KILLUNDEAD: case _SKILL_HEALLING: case _SKILL_HOLYSHIELD: case _SKILL_BIGHEALLING: case _SKILL_LIGHTFLOWER: case _SKILL_SKELLETON: case _SKILL_SNOWWIND: case _SKILL_SHIELD: case _SKILL_SHOWHP: case _SKILL_EARTHFIRE: case _SKILL_FIREBOOM: case _SKILL_SPACEMOVE: case _SKILL_CLOAK: case _SKILL_LIGHTENING: default: SetMotionFrame(_MT_SPELL2, bMagicDir); break; } } VOID CHero::OnButch(LPPACKETMSG lpPacketMsg) { BYTE bDir; m_wPosX = lpPacketMsg->stDefMsg.wParam; m_wPosY = lpPacketMsg->stDefMsg.wTag; bDir = lpPacketMsg->stDefMsg.wSeries; SetMotionFrame(_MT_CUT, bDir); } /****************************************************************************************************************** 함수명 : CHero::UpdatePacketState() 작성자 : 작성일 : 목적 : 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CHero::UpdatePacketState() { LPPACKETMSG lpPacketMsg = NULL; if ( m_bCurrMtn == _MT_STAND || m_bCurrMtn == _MT_ATTACKMODE || m_bCurrMtn == _MT_HORSESTAND || (m_bCurrMtn==_MT_SPELL1 && m_dwCurrFrame == m_dwEndFrame-2) ) { LPPACKETMSG lpPacketMsg; SHORT shLeftMsgCnt = m_xPacketQueue.GetCount(); if ( shLeftMsgCnt > 0 ) { lpPacketMsg = (LPPACKETMSG)m_xPacketQueue.PopQ(); if ( shLeftMsgCnt >= 3 ) m_bMsgHurryCheck = TRUE; else m_bMsgHurryCheck = FALSE; if ( lpPacketMsg ) { switch ( lpPacketMsg->stDefMsg.wIdent ) { case SM_SITDOWN: case SM_BUTCH: { OnButch(lpPacketMsg); break; } case SM_FEATURECHANGED: { OnFeatureChanged(lpPacketMsg); break; } case SM_CHARSTATUSCHANGE: { OnCharStatusChanged(lpPacketMsg); break; } case SM_OPENHEALTH: { OnOpenHealth(lpPacketMsg); break; } case SM_CLOSEHEALTH: { OnCloseHealth(lpPacketMsg); break; } case SM_CHANGELIGHT: { OnChangeLight(lpPacketMsg); break; } case SM_USERNAME: { OnUserName(lpPacketMsg); break; } case SM_CHANGENAMECOLOR: { OnChangeNameClr(lpPacketMsg); break; } case SM_HEALTHSPELLCHANGED: { OnHealthSpellChanged(lpPacketMsg); break; } case SM_RUSH: { OnRush(lpPacketMsg); break; } case SM_BACKSTEP: { OnBackStep(lpPacketMsg); break; } case SM_NOWDEATH: case SM_DEATH: { OnDeath(lpPacketMsg); break; } case SM_WALK: { OnWalk(lpPacketMsg); break; } case SM_RUN: { OnRun(lpPacketMsg); break; } case SM_TURN: { OnTurn(lpPacketMsg); break; } case SM_STRUCK: { OnStruck(lpPacketMsg); break; } case SM_HIT: case SM_FIREHIT: case SM_LONGHIT: case SM_POWERHIT: case SM_WIDEHIT: { OnHit(lpPacketMsg); break; } case SM_MAGICFIRE: { OnMagicFire(lpPacketMsg); break; } case SM_SPELL: { OnSpell(lpPacketMsg); break; } default: { break; } } } SAFE_DELETE(lpPacketMsg); return TRUE; } } return FALSE; } /****************************************************************************************************************** 함수명 : CHero::UpdateMotionState() 작성자 : 작성일 : 목적 : 입력 : INT nLoopTime BOOL bIsMoveTime 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CHero::UpdateMotionState(INT nLoopTime, BOOL bIsMoveTime) { if ( m_bWarMode ) m_dwWarModeTime += nLoopTime; m_wABlendCurrDelay += nLoopTime; if ( m_wABlendCurrDelay >= m_wABlendDelay ) { m_wABlendCurrDelay = 0; m_wABlendDelay = 0; m_bABlendRev = FALSE; } if ( m_bCurrMtn == _MT_DIE && m_dwCurrFrame >= m_dwEndFrame-1 ) { m_bIsDead = TRUE; } if ( m_bIsDead ) { SetMotionFrame(_MT_DIE, m_bCurrDir); m_dwCurrFrame = m_dwEndFrame - 1; return; } if ( UpdateMove(bIsMoveTime) ) { UpdatePacketState(); return; } else { m_wCurrDelay += nLoopTime; m_wShieldCurrDelay += nLoopTime; if ( m_wShieldCurrDelay > 150 ) { m_bShieldCurrFrm++; m_wShieldCurrDelay = 0; if ( m_bShieldCurrFrm > 2 ) m_bShieldCurrFrm = 0; } if ( m_wCurrDelay > m_wDelay ) { m_wCurrDelay = 0; if ( m_dwCurrFrame < m_dwEndFrame ) { m_dwCurrFrame++; PlayActSound(); if ( (m_bCurrMtn == _MT_SPELL2 || m_bCurrMtn == _MT_SPELL1) && m_bUseEffect ) { m_dwCurrEffectFrame++; m_bEffectFrame++; } if ( m_bMsgHurryCheck ) { m_wDelay = m_wDelay/2; m_bMsgHurryCheck = FALSE; } } } UpdatePacketState(); if ( m_dwWarModeTime > _WARMODE_TIME ) { m_dwWarModeTime = 0; m_bWarMode = FALSE; } if ( m_dwCurrFrame >= m_dwEndFrame-1 ) { if ( (m_bCurrMtn == _MT_SPELL2) && m_bUseEffect ) { if ( m_dwCurrEffectFrame - m_dwFstEffectFrame < m_bEffectFrameCnt-2 ) { m_dwCurrFrame = m_dwEndFrame - 2; } } } else if ( m_dwCurrFrame >= m_dwEndFrame-3 ) { if ( (m_bCurrMtn == _MT_SPELL1) && m_bUseEffect ) { if ( m_dwCurrEffectFrame - m_dwFstEffectFrame < m_bEffectFrameCnt-5 ) { m_dwCurrFrame = m_dwEndFrame - 4; } } } if ( m_dwCurrFrame >= m_dwEndFrame ) { m_dwCurrEffectFrame = 0; m_dwFstEffectFrame = 0; m_dwEndEffectFrame = 0; m_bEffectFrame = 0; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; m_bUseEffect = FALSE; m_bUseSwordEffect = FALSE; m_dwCurrFrame = m_dwFstFrame; if ( m_stFeatureEx.bHorse == _HORSE_NONE ) { if ( m_bWarMode ) SetMotionFrame(_MT_ATTACKMODE, m_bCurrDir); else SetMotionFrame(_MT_STAND, m_bCurrDir); } else { SetMotionFrame(_MT_HORSESTAND, m_bCurrDir); } } } } /****************************************************************************************************************** 함수명 : CHero::ChangeFeature() 작성자 : 작성일 : 목적 : BYTE bGender, BYTE bWear, BYTE bHair, BYTE bWeapon; 입력 : WORD wActor BYTE bHair BYTE bWeapon 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CHero::ChangeFeature(FEATURE stFeature, FEATUREEX stFeatureEx) { if ( CActor::ChangeFeature(stFeature) ) { CImageHandler* pxImgHandler = &g_xGameProc.m_xImage; m_stFeatureEx = stFeatureEx; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // m_stFeatureEx.bHorse = 0; // m_stFeatureEx.wDressColor = 0XFFFF; // m_stFeatureEx.wHairColor = 0XFFFF; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if ( m_stFeature.bHair >= _MAX_HAIR ) m_stFeature.bHair = _HAIR_NONE; if ( m_stFeature.bWeapon >= _MAX_WEAPON ) m_stFeature.bWeapon = _WEAPON_NONE; if ( m_stFeatureEx.bHorse >= _MAX_HORSE ) m_stFeatureEx.bHorse= _HORSE_NONE; m_bHorseImgIdx = _IMAGE_HORSE; if ( m_stFeature.bGender == _GENDER_MAN ) { m_bHairImgIdx = _IMAGE_M_HAIR; if ( m_stFeature.bWeapon != _WEAPON_NONE ) m_bWeaponImgIdx = _IMAGE_M_WEAPON1+(m_stFeature.bWeapon-1)/10; } else if ( m_stFeature.bGender == _GENDER_WOMAN ) { m_bHairImgIdx = _IMAGE_WM_HAIR; if ( m_stFeature.bWeapon != _WEAPON_NONE ) m_bWeaponImgIdx = _IMAGE_WM_WEAPON1+(m_stFeature.bWeapon-1)/10; } else return FALSE; if ( m_stFeature.bHair != _HAIR_NONE ) m_pxHairImage = &pxImgHandler->m_xImageList[m_bHairImgIdx]; else m_pxHairImage = NULL; if ( m_stFeature.bWeapon != _WEAPON_NONE ) m_pxWeaponImage = &pxImgHandler->m_xImageList[m_bWeaponImgIdx]; else m_pxWeaponImage = NULL; if ( m_stFeatureEx.bHorse != _HORSE_NONE ) m_pxHorseImage = &pxImgHandler->m_xImageList[m_bHorseImgIdx]; else m_pxHorseImage = NULL; return TRUE; } return FALSE; } /****************************************************************************************************************** 함수명 : CHero::DrawActor() 작성자 : 작성일 : 목적 : 입력 : BOOL bFocused BOOL bShadowAblended 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CHero::DrawActor(CMapHandler* pxMap, BOOL bFocused, BOOL bShadowAblended, BOOL bUseScrnPos, BOOL bDrawShadow) { // 좌표처리. if ( bUseScrnPos ) { m_shScrnPosX = (m_wPosX - pxMap->m_shStartViewTileX) * _CELL_WIDTH + _VIEW_CELL_X_START - pxMap->m_shViewOffsetX + m_shShiftPixelX; m_shScrnPosY = (m_wPosY - pxMap->m_shStartViewTileY) * _CELL_HEIGHT+ _VIEW_CELL_Y_START - pxMap->m_shViewOffsetY + m_shShiftPixelY; } BYTE bShadowType; SHORT shShadowPX; SHORT shShadowPY; SHORT shPX, shPY; //---------------------------------------------------------------------------------------------------------------// // 각 이미지 세팅및 좌표영역 체크. //---------------------------------------------------------------------------------------------------------------// // 말. if ( m_stFeatureEx.bHorse != _HORSE_NONE && m_pxHorseImage != NULL ) { if ( m_bCurrMtn >= _START_HORSE_MTN ) { m_dwCurrHorseFrame = (m_stFeatureEx.bHorse*_MAX_HORSE_FRAME-_MAX_HORSE_FRAME)+(m_dwCurrFrame-(_MAX_HERO_FRAME*m_stFeature.bDress)-_START_HORSE_FRAME); if ( !m_pxHorseImage->NewSetIndex(m_dwCurrHorseFrame) ) return FALSE; shPX = m_pxHorseImage->m_lpstNewCurrWilImageInfo->shPX; shPY = m_pxHorseImage->m_lpstNewCurrWilImageInfo->shPY; SetRect(&m_rcHorse, m_shScrnPosX + shPX, m_shScrnPosY + shPY, m_shScrnPosX + shPX + m_pxHorseImage->m_lpstNewCurrWilImageInfo->shWidth, m_shScrnPosX + shPY + m_pxHorseImage->m_lpstNewCurrWilImageInfo->shHeight); } } // 무기. if ( m_stFeature.bWeapon != _WEAPON_NONE && m_pxWeaponImage != NULL ) { if ( m_bCurrMtn < _MAX_WEAPON_MTN ) { m_dwCurrWeaponFrame = (((m_stFeature.bWeapon-1)%10)*_MAX_WEAPON_FRAME)+(m_dwCurrFrame-(_MAX_HERO_FRAME*m_stFeature.bDress)); if ( !m_pxWeaponImage->NewSetIndex(m_dwCurrWeaponFrame) ) return FALSE; shPX = m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shPX; shPY = m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shPY; SetRect(&m_rcWeapon, m_shScrnPosX + shPX, m_shScrnPosY + shPY, m_shScrnPosX + shPX + m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shWidth, m_shScrnPosY + shPY + m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shHeight); } } // 캐릭터. if ( m_pxActorImage ) { if ( !m_pxActorImage->NewSetIndex(m_dwCurrFrame) ) return FALSE; shPX = m_pxActorImage->m_lpstNewCurrWilImageInfo->shPX; shPY = m_pxActorImage->m_lpstNewCurrWilImageInfo->shPY; bShadowType = m_pxActorImage->m_lpstNewCurrWilImageInfo->bShadow; shShadowPX = m_pxActorImage->m_lpstNewCurrWilImageInfo->shShadowPX; shShadowPY = m_pxActorImage->m_lpstNewCurrWilImageInfo->shShadowPY; SetRect(&m_rcActor, m_shScrnPosX + shPX, m_shScrnPosY + shPY, m_shScrnPosX + shPX + m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_shScrnPosY + shPY + m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight); if ( ( m_rcActor.right - m_rcActor.left ) > _CELL_WIDTH + _TARGETRGN_GAPX ) { m_rcTargetRgn.left = m_rcActor.left + ( (m_rcActor.right - m_rcActor.left) - (_CELL_WIDTH + _TARGETRGN_GAPX) )/2; m_rcTargetRgn.right = m_rcActor.left + ( (m_rcActor.right - m_rcActor.left) + (_CELL_WIDTH + _TARGETRGN_GAPX) )/2; } else { m_rcTargetRgn.left = m_rcActor.left; m_rcTargetRgn.right = m_rcActor.right; } if ( ( m_rcActor.bottom - m_rcActor.top ) > _CELL_HEIGHT + _TARGETRGN_GAPY ) { m_rcTargetRgn.top = m_rcActor.top + ( (m_rcActor.bottom - m_rcActor.top) - (_CELL_HEIGHT + _TARGETRGN_GAPY) )/2; m_rcTargetRgn.bottom = m_rcActor.top + ( (m_rcActor.bottom - m_rcActor.top) + (_CELL_HEIGHT + _TARGETRGN_GAPY) )/2; } else { m_rcTargetRgn.top = m_rcActor.top; m_rcTargetRgn.bottom = m_rcActor.bottom; } } // 머리. if ( m_stFeature.bHair != _HAIR_NONE && m_pxHairImage != NULL ) { m_dwCurrHairFrame = (m_stFeature.bHair*_MAX_HERO_FRAME-_MAX_HERO_FRAME)+(m_dwCurrFrame-(_MAX_HERO_FRAME*m_stFeature.bDress)); if ( !m_pxHairImage->NewSetIndex(m_dwCurrHairFrame) ) return FALSE; shPX = m_pxHairImage->m_lpstNewCurrWilImageInfo->shPX; shPY = m_pxHairImage->m_lpstNewCurrWilImageInfo->shPY; SetRect(&m_rcHair, m_shScrnPosX + shPX, m_shScrnPosY + shPY, m_shScrnPosX + shPX + m_pxHairImage->m_lpstNewCurrWilImageInfo->shWidth, m_shScrnPosY + shPY + m_pxHairImage->m_lpstNewCurrWilImageInfo->shHeight); } //---------------------------------------------------------------------------------------------------------------// // 그림자그리기. //---------------------------------------------------------------------------------------------------------------// BYTE bOpaRate = 70; WORD wState = GetCharState(); // 무기. if ( m_stFeature.bWeapon != _WEAPON_NONE && m_pxWeaponImage != NULL ) { if ( m_bCurrMtn < _MAX_WEAPON_MTN ) { if ( bDrawShadow ) { if ( !m_bIsDead ) { g_xMainWnd.DrawWithShadowABlend( m_rcWeapon.left, m_rcWeapon.top, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shHeight, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shPX, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shPY, (WORD*)m_pxWeaponImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, g_xGameProc.m_wShadowClr, bShadowAblended, bOpaRate); } /* else { g_xMainWnd.DrawWithShadowABlend( m_rcWeapon.left+3, m_rcWeapon.top-2, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shHeight, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shPX, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shPY, (WORD*)m_pxWeaponImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, g_xGameProc.m_wShadowClr, bShadowAblended, bOpaRate); } */ } } } // 말. if ( m_stFeatureEx.bHorse != _HORSE_NONE && m_pxHorseImage != NULL ) { if ( m_bCurrMtn >= _START_HORSE_MTN ) { if ( bDrawShadow ) { if ( !m_bIsDead ) { g_xMainWnd.DrawWithShadowABlend( m_rcHorse.left, m_rcHorse.top, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shHeight, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shPX, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shPY, (WORD*)m_pxHorseImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, g_xGameProc.m_wShadowClr, bShadowAblended, bOpaRate); } else { g_xMainWnd.DrawWithShadowABlend( m_rcHorse.left+3, m_rcHorse.top+2, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shHeight, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shPX, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shPY, (WORD*)m_pxHorseImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, g_xGameProc.m_wShadowClr, bShadowAblended, bOpaRate); } } } } // 캐릭터. if ( m_pxActorImage ) { INT nStartX1 = m_shScrnPosX + shShadowPX; INT nStartY1 = m_shScrnPosY + shShadowPY; if ( bDrawShadow ) { if ( !m_bIsDead ) { g_xMainWnd.DrawWithShadowABlend( nStartX1, nStartY1, m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxActorImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, g_xGameProc.m_wShadowClr, bShadowAblended, bShadowType, bOpaRate); } else { g_xMainWnd.DrawWithShadowABlend( m_rcActor.left+3, m_rcActor.top+2, m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxActorImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, g_xGameProc.m_wShadowClr, bShadowAblended, 50, bOpaRate); } } } // 머리는 그림자를 그리지 않는다. if ( m_wABlendDelay ) { bShadowAblended = TRUE; if ( m_wABlendDelay ) { if ( !m_bABlendRev ) bOpaRate = 100 - ( (m_wABlendCurrDelay * 100) / m_wABlendDelay ); else bOpaRate = ( (m_wABlendCurrDelay * 100) / m_wABlendDelay ); } if ( bFocused ) { if ( !m_bABlendRev ) bOpaRate -= 20; else bOpaRate += 20; } if ( bOpaRate < 0 && bOpaRate > 100 ) bOpaRate = 0; } else if ( wState==_STATE_ABLEND ) bShadowAblended = TRUE; //---------------------------------------------------------------------------------------------------------------// // 이미지 그리기. //---------------------------------------------------------------------------------------------------------------// // 말. if ( m_stFeatureEx.bHorse != _HORSE_NONE && m_pxHorseImage != NULL ) { if ( m_bCurrMtn >= _START_HORSE_MTN ) { DrawWithEffected(m_rcHorse.left, m_rcHorse.top, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxHorseImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxHorseImage->m_pbCurrImage, 0XFFFF, 0XFFFF, bFocused, bOpaRate, wState); } } // 무기를 먼저 그려야될방향. if ( m_stFeature.bWeapon != _WEAPON_NONE && m_pxWeaponImage != NULL && g_xSpriteInfo.m_bWOrder[(m_dwCurrFrame-(_MAX_HERO_FRAME*m_stFeature.bDress))] ) { if ( m_bCurrMtn < _MAX_WEAPON_MTN ) { DrawWithEffected(m_rcWeapon.left, m_rcWeapon.top, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxWeaponImage->m_pbCurrImage, 0XFFFF, 0XFFFF, bFocused, bOpaRate, wState); /* g_xMainWnd.DrawWithImageForCompClipRgn( m_rcWeapon.left, m_rcWeapon.top, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxWeaponImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, bFocused); */ } } // 캐릭터. if ( m_pxActorImage != NULL ) { DrawWithEffected(m_rcActor.left, m_rcActor.top, m_pxActorImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxActorImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxActorImage->m_pbCurrImage, m_stFeatureEx.wDressColor, m_stFeatureEx.wHairColor, bFocused, bOpaRate, wState); } // 머리. if ( m_stFeature.bHair != _HAIR_NONE && m_pxHairImage != NULL ) { DrawWithEffected(m_rcHair.left, m_rcHair.top, m_pxHairImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxHairImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxHairImage->m_pbCurrImage, m_stFeatureEx.wDressColor, m_stFeatureEx.wHairColor, bFocused, bOpaRate, wState); } // 무기를 나중에 그려야될 방향. if ( m_stFeature.bWeapon != _WEAPON_NONE && m_pxWeaponImage != NULL && !g_xSpriteInfo.m_bWOrder[(m_dwCurrFrame-(_MAX_HERO_FRAME*m_stFeature.bDress))] ) { if ( m_bCurrMtn < _MAX_WEAPON_MTN ) { DrawWithEffected(m_rcWeapon.left, m_rcWeapon.top, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxWeaponImage->m_pbCurrImage, 0XFFFF, 0XFFFF, bFocused, /*bOpaRate*/20, wState); /* g_xMainWnd.DrawWithImageForCompClipRgn( m_rcWeapon.left, m_rcWeapon.top, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shWidth, m_pxWeaponImage->m_lpstNewCurrWilImageInfo->shHeight, (WORD*)m_pxWeaponImage->m_pbCurrImage, _CLIP_WIDTH, _CLIP_HEIGHT, bFocused); */ } } DrawEffect(); ShowShield(); if ( !bDrawShadow ) return TRUE; if ( bUseScrnPos ) { if ( m_bLightSize == 2 ) g_xGameProc.m_xLightFog.SetLightRadiusWithCircle(m_rcActor.left+_CELL_WIDTH/2, m_rcActor.top+_CELL_HEIGHT/2, 3, 100, 100, 100); else g_xGameProc.m_xLightFog.SetLightRadiusWithCircle(m_rcActor.left+_CELL_WIDTH/2, m_rcActor.top+_CELL_HEIGHT/2, m_bLightSize, 255, 255, 255); } else { if ( m_bLightSize == 2 ) g_xGameProc.m_xLightFog.SetLightRadiusWithCircle(400, 242, 3, 100, 100, 100); else g_xGameProc.m_xLightFog.SetLightRadiusWithCircle(400, 242, m_bLightSize, 255, 255, 255); } return TRUE; } /****************************************************************************************************************** CMyHero Class *******************************************************************************************************************/ /****************************************************************************************************************** 함수명 : CMyHero::CMyHero() 작성자 : 작성일 : 목적 : 출력 : [일자][수정자] : 수정내용 *******************************************************************************************************************/ CMyHero::CMyHero() { InitActor(); } /****************************************************************************************************************** 함수명 : CMyHero::~CMyHero() 작성자 : 작성일 : 목적 : 출력 : [일자][수정자] : 수정내용 *******************************************************************************************************************/ CMyHero::~CMyHero() { DestroyActor(); } VOID CMyHero::InitActor() { CHero::InitActor(); m_wOldPosX = 0; m_wOldPosY = 0; m_bOldDir = 0; m_dwWarModeTime = 0; m_dwMotionLockTime = 0; m_wMagicDelayTime = 0; m_wMagicPKDelayTime = 0; m_bJob = 0; m_nGlod = 0; m_dwLastHitTime = timeGetTime(); m_dwLastSpellTime = timeGetTime(); m_dwLastMagicTime = timeGetTime(); m_dwLastStruckTime = timeGetTime(); m_dwLastPKStruckTime= timeGetTime(); m_dwLastRushTime = timeGetTime(); m_dwLastFireHitTime = timeGetTime(); m_bCanRun = FALSE; m_bInputLock = FALSE; m_bMotionLock = FALSE; m_bWarMode = FALSE; m_pxMap = NULL; m_bAttackMode = _MT_ONEHSWING; ZeroMemory(&m_stAbility, sizeof(ACTORABILITY)); ZeroMemory(&m_stSubAbility, sizeof(ACTORSUBABILITY)); } VOID CMyHero::DestroyActor() { INT nCnt; SHORT shLeftMsgCnt; LPPACKETMSG lpPacketMsg; CHero::DestroyActor(); lpPacketMsg = NULL; shLeftMsgCnt = m_xPriorPacketQueue.GetCount(); // 쌓여있는 패킷을 지운다. if ( shLeftMsgCnt > 0 ) { for ( nCnt = 0; nCnt < shLeftMsgCnt; nCnt++ ) { lpPacketMsg = (LPPACKETMSG)m_xPriorPacketQueue.PopQ(); if ( lpPacketMsg ) { SAFE_DELETE(lpPacketMsg); } } } InitActor(); } BOOL CMyHero::Create(CImageHandler* pxImgHandler, BYTE bMtn, BYTE bDir, WORD wPosX, WORD wPosY, FEATURE* pstFeature, FEATUREEX* pstFeatureEx) { ZeroMemory(&m_stAbility, sizeof(ACTORABILITY)); ZeroMemory(&m_stSubAbility, sizeof(ACTORSUBABILITY)); if ( !(CHero::Create(pxImgHandler, bMtn, bDir, wPosX, wPosY, pstFeature, pstFeatureEx)) ) return FALSE; return TRUE; } /****************************************************************************************************************** 함수명 : CMyHero::SetMapHandler() 작성자 : 작성일 : 목적 : 입력 : CMapHandler* pxMap 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CMyHero::SetMapHandler(CMapHandler* pxMap) { m_pxMap = pxMap; } VOID CMyHero::OnHealthSpellChanged(LPPACKETMSG lpPacketMsg) { m_stAbility.wHP = lpPacketMsg->stDefMsg.wParam; m_stAbility.wMaxHP = lpPacketMsg->stDefMsg.wSeries; m_stAbility.wMP = lpPacketMsg->stDefMsg.wTag; if ( m_stAbility.wHP <= 0 ) m_stAbility.wHP = m_bHPPercent = 0; else { FLOAT wHPRate= (FLOAT)((FLOAT)m_stAbility.wHP/(FLOAT)m_stAbility.wMaxHP); m_bHPPercent = wHPRate * 100; } } /****************************************************************************************************************** 함수명 : CMyHero::UpdatePacketState() 작성자 : 작성일 : 목적 : 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CMyHero::UpdatePacketState() { LPPACKETMSG lpPacketMsg = NULL; SHORT shLeftMsgCnt = m_xPriorPacketQueue.GetCount(); if ( shLeftMsgCnt > 0 ) { lpPacketMsg = (LPPACKETMSG)m_xPriorPacketQueue.PopQ(); if ( lpPacketMsg ) { if ( lpPacketMsg->stDefMsg.wIdent == SM_NOWDEATH || lpPacketMsg->stDefMsg.wIdent == SM_DEATH ) { OnDeath(lpPacketMsg); SAFE_DELETE(lpPacketMsg); return TRUE; } } } if ( m_bCurrMtn == _MT_STAND || m_bCurrMtn == _MT_ATTACKMODE || m_bCurrMtn == _MT_HORSESTAND || (m_bCurrMtn==_MT_SPELL1 && m_dwCurrFrame==m_dwEndFrame - 2) ) { LPPACKETMSG lpPacketMsg; SHORT shLeftMsgCnt = m_xPacketQueue.GetCount(); if ( shLeftMsgCnt > 0 ) { lpPacketMsg = (LPPACKETMSG)m_xPacketQueue.PopQ(); if ( shLeftMsgCnt >= 3 ) m_bMsgHurryCheck = TRUE; else m_bMsgHurryCheck = FALSE; if ( lpPacketMsg ) { switch ( lpPacketMsg->stDefMsg.wIdent ) { case SM_STRUCK: { m_bInputLock = TRUE; m_stAbility.wHP = lpPacketMsg->stDefMsg.wParam; m_stAbility.wMaxHP = lpPacketMsg->stDefMsg.wTag; OnStruck(lpPacketMsg); if ( m_dwNameClr == RGB(255, 0, 0) ) { m_dwLastPKStruckTime = timeGetTime(); } m_dwLastStruckTime = timeGetTime(); break; } case SM_RUSH: { m_bInputLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; OnRush(lpPacketMsg); if ( !CheckMyPostion() ) AdjustMyPostion(); m_pxMap->ScrollMap(m_bMoveDir, m_dwCurrFrame-m_dwFstFrame, m_bMoveSpeed); break; } case SM_BACKSTEP: { m_bInputLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; OnBackStep(lpPacketMsg); if ( !CheckMyPostion() ) AdjustMyPostion(); m_pxMap->ScrollMap(m_bMoveDir, m_dwCurrFrame-m_dwFstFrame, m_bMoveSpeed); break; } case SM_FEATURECHANGED: { OnFeatureChanged(lpPacketMsg); break; } case SM_OPENHEALTH: { OnOpenHealth(lpPacketMsg); break; } case SM_CLOSEHEALTH: { OnCloseHealth(lpPacketMsg); break; } case SM_CHANGELIGHT: { OnChangeLight(lpPacketMsg); break; } case SM_USERNAME: { OnUserName(lpPacketMsg); break; } case SM_CHANGENAMECOLOR: { OnChangeNameClr(lpPacketMsg); break; } case SM_CHARSTATUSCHANGE: { OnCharStatusChanged(lpPacketMsg); break; } case SM_MAGICFIRE: { OnMagicFire(lpPacketMsg); break; } case SM_HEALTHSPELLCHANGED: { OnHealthSpellChanged(lpPacketMsg); break; } default: { break; } } } SAFE_DELETE(lpPacketMsg); return TRUE; } } return FALSE; } /****************************************************************************************************************** 함수명 : CMyHero::SetOldPosition() 작성자 : 작성일 : 목적 : 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CMyHero::SetOldPosition() { m_wPosX = m_wOldPosX; m_wPosY = m_wOldPosY; m_bCurrDir = m_bOldDir; if ( m_stFeatureEx.bHorse == _HORSE_NONE ) { if ( SetMotionFrame(_MT_STAND, m_bCurrDir) ) { AdjustMyPostion(); m_bMotionLock = m_bInputLock = FALSE; return TRUE; } } else { if ( SetMotionFrame(_MT_HORSESTAND, m_bCurrDir) ) { AdjustMyPostion(); m_bMotionLock = m_bInputLock = FALSE; return TRUE; } } return FALSE; } /****************************************************************************************************************** 함수명 : CMyHero::CheckMyPostion() 작성자 : 작성일 : 목적 : 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CMyHero::CheckMyPostion() { if ( m_wPosX != m_pxMap->m_shStartViewTileX + _GAPX_TILE_CHAR_MAP || m_wPosY != m_pxMap->m_shStartViewTileY + _GAPY_TILE_CHAR_MAP ) { return FALSE; } return TRUE; } /****************************************************************************************************************** 함수명 : CMyHero::AdjustMyPostion() 작성자 : 작성일 : 목적 : 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CMyHero::AdjustMyPostion() { m_pxMap->SetStartViewTile(m_wPosX-_GAPX_TILE_CHAR_MAP, m_wPosY-_GAPY_TILE_CHAR_MAP); m_pxMap->LoadNewMapBuffer(); } /****************************************************************************************************************** 함수명 : CMyHero::SetMotionState() 작성자 : 작성일 : 목적 : 입력 : BYTE bMtn BYTE bDir LPPOINT lpptTarget 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CMyHero::SetMotionState(BYTE bMtn, BYTE bDir, INT nMouseTargetID, BOOL bIsDead, LPPOINT lpptPos, SHORT shSkill) { if ( !m_bIsMon ) { switch ( bMtn ) { case _MT_WALK: case _MT_HORSEWALK: { if ( lpptPos ) { POINT ptNext; for ( INT nCnt = 0; nCnt < _MAX_DIRECTION; nCnt++ ) { m_pxMap->GetNextTileCanMove(lpptPos->x, lpptPos->y, nCnt, 1, &ptNext); if ( !m_pxMap->IsDoorOpen(ptNext.x, ptNext.y) ) { g_xClientSocket.SendOpenDoor(ptNext.x, ptNext.y, m_pxMap->GetDoor(ptNext.x, ptNext.y)); break; } } g_xClientSocket.SendActMsg(CM_WALK, lpptPos->x, lpptPos->y, bDir); m_bMotionLock = m_bInputLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; SetMotionFrame(bMtn, bDir); m_bMoveSpeed = _SPEED_WALK; m_pxMap->ScrollMap(m_bMoveDir, m_dwCurrFrame-m_dwFstFrame, m_bMoveSpeed); } break; } case _MT_RUN: case _MT_HORSERUN: { if ( lpptPos ) { POINT ptNext; POINT ptStart; if ( bMtn == _MT_RUN ) m_bMoveSpeed = _SPEED_RUN; else m_bMoveSpeed = _SPEED_HORSERUN; m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 1, &ptStart); for ( INT nCnt = 0; nCnt < _MAX_DIRECTION; nCnt++ ) { for ( INT nSpeedCnt = 0; nSpeedCnt < m_bMoveSpeed; nSpeedCnt++ ) { m_pxMap->GetNextTileCanMove(ptStart.x, ptStart.y, nCnt, nSpeedCnt+1, &ptNext); if ( !m_pxMap->IsDoorOpen(ptNext.x, ptNext.y) ) { g_xClientSocket.SendOpenDoor(ptNext.x, ptNext.y, m_pxMap->GetDoor(ptNext.x, ptNext.y)); break; } } } g_xClientSocket.SendActMsg(CM_RUN, lpptPos->x, lpptPos->y, bDir); m_bMotionLock = m_bInputLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; SetMotionFrame(bMtn, bDir); m_pxMap->ScrollMap(m_bMoveDir, m_dwCurrFrame-m_dwFstFrame, m_bMoveSpeed); } break; } case _MT_ONEHSWING: { if ( m_bAttackMode == _MT_ONEHSWING || m_bAttackMode == _MT_ONEVSWING ) { BYTE bAttackStyle = rand()%2; if ( bAttackStyle ) m_bAttackMode = _MT_ONEVSWING; else m_bAttackMode = _MT_ONEHSWING; m_bAttackMode = _MT_ONEVSWING; } if ( lpptPos && CanNextHit() ) { m_bMotionLock = m_bInputLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; m_bWarMode = TRUE; m_dwWarModeTime = 0; if ( m_bUseErgum && g_xGameProc.TargetInLongAttack(bDir) ) { SetMotionFrame(_MT_ONEVSWING, bDir); LoadEffect(&g_xGameProc.m_xImage, _SKILL_ERGUM, bDir); m_bUseSwordEffect = TRUE; g_xClientSocket.SendActMsg(CM_LONGHIT, lpptPos->x, lpptPos->y, bDir); } else if ( m_bFireHitCnt == 1 && m_stAbility.wMP > 7 ) { SetMotionFrame(_MT_ONEVSWING, bDir); LoadEffect(&g_xGameProc.m_xImage, _SKILL_FIRESWORD, bDir); m_bUseSwordEffect = TRUE; g_xClientSocket.SendActMsg(CM_FIREHIT, lpptPos->x, lpptPos->y, bDir); m_bFireHitCnt = 2; } else if ( m_bYedoCnt == 1 ) { SetMotionFrame(_MT_ONEVSWING, bDir); LoadEffect(&g_xGameProc.m_xImage, _SKILL_YEDO, bDir); m_bUseSwordEffect = TRUE; g_xClientSocket.SendActMsg(CM_POWERHIT, lpptPos->x, lpptPos->y, bDir); m_bYedoCnt = 2; } else if ( m_bUseBanwol && m_stAbility.wMP > 3 ) { SetMotionFrame(_MT_ONEHSWING, bDir); LoadEffect(&g_xGameProc.m_xImage, _SKILL_BANWOL, bDir); m_bUseSwordEffect = TRUE; g_xClientSocket.SendActMsg(CM_WIDEHIT, lpptPos->x, lpptPos->y, bDir); } else { SetMotionFrame(m_bAttackMode, bDir); if ( m_bAttackMode == _MT_WHEELWIND ) { LoadEffect(&g_xGameProc.m_xImage, _SKILL_JUMPSHOT, bDir); m_bUseSwordEffect = TRUE; } else if ( m_bAttackMode == _MT_RANDSWING ) { LoadEffect(&g_xGameProc.m_xImage, _SKILL_RANDSWING, bDir); m_bUseSwordEffect = TRUE; } WORD wAttackStyle; if ( m_bAttackMode != _MT_ONEVSWING && m_bAttackMode != _MT_ONEHSWING ) wAttackStyle = _MT_ONEVSWING; else { wAttackStyle = m_bAttackMode; } g_xClientSocket.SendHitMsg(CM_HIT, lpptPos->x, lpptPos->y, bDir, wAttackStyle); } } break; } case _MT_MOODEPO: { if ( lpptPos ) { g_xClientSocket.SendSpellMsg(shSkill, lpptPos->x, lpptPos->y, 0); // 무태보 시간값 기록. m_dwLastRushTime = timeGetTime(); m_bMotionLock = m_bInputLock = TRUE; m_bWarMode = TRUE; } break; } case _MT_SPELL2: case _MT_SPELL1: { if ( lpptPos ) { g_xClientSocket.SendSpellMsg(shSkill, lpptPos->x, lpptPos->y, nMouseTargetID); m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; m_bMotionLock = m_bInputLock = TRUE; m_bWarMode = TRUE; if ( m_shCurrMagicID == _SKILL_FIREBALL || m_shCurrMagicID == _SKILL_FIREBALL2 || m_shCurrMagicID == _SKILL_FIRE || m_shCurrMagicID == _SKILL_SHOOTLIGHTEN || m_shCurrMagicID == _SKILL_HANGMAJINBUB || m_shCurrMagicID== _SKILL_DEJIWONHO || m_shCurrMagicID == _SKILL_FIRECHARM || m_shCurrMagicID == _SKILL_SINSU || m_shCurrMagicID == _SKILL_BIGCLOAK ) LoadEffect(&g_xGameProc.m_xImage, m_shCurrMagicID, bDir); else LoadEffect(&g_xGameProc.m_xImage, m_shCurrMagicID); m_bUseEffect = TRUE; /* if ( m_shCurrMagicID == _SKILL_SHIELD ) { m_dwFstEffectFrame = 50; m_dwEndEffectFrame = 60; m_dwCurrEffectFrame = 50; m_bEffectFrame = 0; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; } */ if ( m_shCurrMagicID == _SKILL_SHOWHP ) m_bEffectFrameCnt = 20; else if ( m_shCurrMagicID == _SKILL_LIGHTFLOWER ) m_bEffectFrameCnt = 15; else if ( m_shCurrMagicID == _SKILL_SPACEMOVE ) m_bEffectFrameCnt = 19; else if ( m_shCurrMagicID == _SKILL_LIGHTENING ) m_bEffectFrameCnt = 17; SetMotionFrame(bMtn, bDir); } break; } case _MT_CUT: { m_bInputLock = TRUE; m_bMotionLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; SetMotionFrame(bMtn, bDir); g_xClientSocket.SendActMsg(CM_SITDOWN, m_wPosX, m_wPosY, bDir); if ( nMouseTargetID && bIsDead ) { g_xClientSocket.SendButchAnimal(m_wPosX, m_wPosY, bDir, nMouseTargetID); } break; } case _MT_HORSESTAND: case _MT_STAND: { if ( bDir != m_bCurrDir ) { g_xClientSocket.SendActMsg(CM_TRUN, m_wPosX, m_wPosY, bDir); m_bMotionLock = TRUE; m_bInputLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; SetMotionFrame(bMtn, bDir); } break; } } } else { switch ( bMtn ) { case _MT_HORSESTAND: case _MT_STAND: { bMtn = _MT_MON_STAND; if ( bDir != m_bCurrDir ) g_xClientSocket.SendActMsg(CM_TRUN, m_wPosX, m_wPosY, bDir); // m_bMotionLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; SetMotionFrame(bMtn, bDir); break; } case _MT_WALK: case _MT_HORSEWALK: { bMtn = _MT_MON_WALK; g_xClientSocket.SendActMsg(CM_WALK, m_wPosX, m_wPosY, bDir); m_bMotionLock = m_bInputLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; SetMotionFrame(bMtn, bDir); m_bMoveSpeed = _SPEED_WALK; m_pxMap->ScrollMap(m_bMoveDir, m_dwCurrFrame-m_dwFstFrame, m_bMoveSpeed); break; } case _MT_ONEHSWING: { bMtn = _MT_MON_ATTACK_A; m_bMotionLock = m_bInputLock = TRUE; m_wOldPosX = m_wPosX; m_wOldPosY = m_wPosY; m_bOldDir = m_bCurrDir; m_bWarMode = TRUE; m_dwWarModeTime = 0; SetMotionFrame(_MT_MON_ATTACK_A, bDir); g_xClientSocket.SendHitMsg(CM_HIT, lpptPos->x, lpptPos->y, bDir, 0); break; } } } m_dwMotionLockTime = 0; } /****************************************************************************************************************** 함수명 : CMyHero::UpdateMotionState() 작성자 : 작성일 : 목적 : 입력 : INT nLoopTime 출력 : VOID [일자][수정자] : 수정내용 *******************************************************************************************************************/ VOID CMyHero::UpdateMotionState(INT nLoopTime, BOOL bIsMoveTime) { if ( m_bMotionLock ) m_dwMotionLockTime += nLoopTime; if ( m_bWarMode ) m_dwWarModeTime += nLoopTime; m_wABlendCurrDelay += nLoopTime; if ( m_wABlendCurrDelay >= m_wABlendDelay ) { m_wABlendCurrDelay = 0; m_wABlendDelay = 0; m_bABlendRev = FALSE; } if ( m_bCurrMtn == _MT_DIE && m_dwCurrFrame >= m_dwEndFrame-1 ) { m_bIsDead = TRUE; } if ( m_bIsDead ) { if ( m_bIsMon ) SetMotionFrame(_MT_MON_DIE, m_bCurrDir); else SetMotionFrame(_MT_DIE, m_bCurrDir); m_dwCurrFrame = m_dwEndFrame - 1; m_bInputLock = TRUE; return; } if ( UpdateMove(bIsMoveTime) ) { UpdatePacketState(); return; } else { if ( !m_bIsMon ) { m_wCurrDelay += nLoopTime; m_wShieldCurrDelay += nLoopTime; if ( m_wShieldCurrDelay > 150 ) { m_bShieldCurrFrm++; m_wShieldCurrDelay = 0; if ( m_bShieldCurrFrm > 2 ) m_bShieldCurrFrm = 0; } if ( m_wCurrDelay > m_wDelay ) { m_wCurrDelay = 0; if ( m_dwCurrFrame < m_dwEndFrame ) { m_dwCurrFrame++; PlayActSound(); if ( (m_bCurrMtn == _MT_SPELL2 || m_bCurrMtn == _MT_SPELL1) && m_bUseEffect ) { m_dwCurrEffectFrame++; m_bEffectFrame++; } } } UpdatePacketState(); // 연속적인 프레임 중에서 해야할일. if ( m_dwMotionLockTime > _MOTION_LOCKTIME ) { m_dwMotionLockTime = 0; m_bMotionLock = FALSE; // SetOldPosition(); } if ( m_dwWarModeTime > _WARMODE_TIME ) { m_dwWarModeTime = 0; m_bWarMode = FALSE; } if ( m_dwCurrFrame >= m_dwEndFrame-1 ) { if ( (m_bCurrMtn == _MT_SPELL2) && m_bUseEffect ) { if ( m_dwCurrEffectFrame - m_dwFstEffectFrame < m_bEffectFrameCnt-2 ) { m_dwCurrFrame = m_dwEndFrame - 2; } } } else if ( m_dwCurrFrame >= m_dwEndFrame-3 ) { if ( (m_bCurrMtn == _MT_SPELL1) && m_bUseEffect ) { if ( m_dwCurrEffectFrame - m_dwFstEffectFrame < m_bEffectFrameCnt-5 ) { m_dwCurrFrame = m_dwEndFrame - 4; } } } if ( m_dwCurrFrame >= m_dwEndFrame ) { switch ( m_bCurrMtn ) { case _MT_CUT: { m_bInputLock = FALSE; m_bMotionLock = FALSE; m_dwCurrFrame = m_dwFstFrame; if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionFrame(_MT_STAND, m_bCurrDir); else SetMotionFrame(_MT_HORSESTAND, m_bCurrDir); } break; case _MT_STAND: case _MT_HORSESTAND: { m_bInputLock = FALSE; m_bMotionLock = FALSE; m_bUseEffect = FALSE; m_bUseSwordEffect = FALSE; m_dwCurrFrame = m_dwFstFrame; break; } case _MT_ATTACKMODE: { if ( !m_bWarMode ) SetMotionFrame(_MT_STAND, m_bCurrDir); else { m_bInputLock = FALSE; m_bMotionLock = FALSE; m_dwCurrFrame = m_dwFstFrame; } break; } default: { m_dwCurrEffectFrame = 0; m_dwFstEffectFrame = 0; m_dwEndEffectFrame = 0; m_bEffectFrame = 0; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; m_bUseEffect = FALSE; m_bUseSwordEffect = FALSE; if ( !m_bMotionLock ) { m_bInputLock = FALSE; if ( m_stFeatureEx.bHorse == _HORSE_NONE ) { if ( m_bWarMode ) SetMotionFrame(_MT_ATTACKMODE, m_bCurrDir); else SetMotionFrame(_MT_STAND, m_bCurrDir); } else { SetMotionFrame(_MT_HORSESTAND, m_bCurrDir); } } else { m_dwCurrFrame = m_dwEndFrame-1; } } break; } } if ( m_bCurrMtn == _MT_STAND || m_bCurrMtn == _MT_HORSESTAND ) { POINT ptMouse; GetCursorPos(&ptMouse); ScreenToClient(g_xMainWnd.GetSafehWnd(), &ptMouse); m_bCanRun = FALSE; if ( HIBYTE(GetKeyState(VK_RBUTTON)) || ( HIBYTE(GetKeyState(VK_LBUTTON)) && HIBYTE(GetKeyState(VK_CONTROL))) ) { OnRButtonDown(ptMouse); } else if ( HIBYTE(GetKeyState(VK_LBUTTON)) ) { OnLButtonDown(ptMouse); /* LPARAM lParam = MAKELPARAM((WORD)ptMouse.x, (WORD)ptMouse.y); WPARAM wParam = 0; g_xGameProc.OnLButtonDown(wParam, lParam); */ } } } else { m_wCurrDelay += nLoopTime; m_wShieldCurrDelay += nLoopTime; m_wABlendCurrDelay += nLoopTime; if ( m_wShieldCurrDelay > 150 ) { m_bShieldCurrFrm++; m_wShieldCurrDelay = 0; if ( m_bShieldCurrFrm > 2 ) m_bShieldCurrFrm = 0; } if ( m_wCurrDelay > m_wDelay ) { m_wCurrDelay = 0; if ( m_dwCurrFrame < m_dwEndFrame ) { m_dwCurrFrame++; } } UpdatePacketState(); // 연속적인 프레임 중에서 해야할일. if ( m_dwMotionLockTime > _MOTION_LOCKTIME ) { m_dwMotionLockTime = 0; m_bMotionLock = FALSE; // SetOldPosition(); } if ( m_dwWarModeTime > _WARMODE_TIME ) { m_dwWarModeTime = 0; m_bWarMode = FALSE; } if ( m_dwCurrFrame >= m_dwEndFrame ) { switch ( m_bCurrMtn ) { case _MT_MON_STAND: { m_bInputLock = FALSE; m_bMotionLock = FALSE; m_bUseEffect = FALSE; m_bUseSwordEffect = FALSE; m_dwCurrFrame = m_dwFstFrame; break; } default: { m_dwCurrEffectFrame = 0; m_dwFstEffectFrame = 0; m_dwEndEffectFrame = 0; m_bEffectFrame = 0; m_bEffectFrameCnt = _DEFAULT_SPELLFRAME; m_bUseEffect = FALSE; m_bUseSwordEffect = FALSE; if ( !m_bMotionLock ) { m_bInputLock = FALSE; SetMotionFrame(_MT_MON_STAND, m_bCurrDir); } else { m_dwCurrFrame = m_dwEndFrame-1; } } break; } } if ( m_bCurrMtn == _MT_MON_STAND ) { POINT ptMouse; GetCursorPos(&ptMouse); ScreenToClient(g_xMainWnd.GetSafehWnd(), &ptMouse); m_bCanRun = FALSE; if ( HIBYTE(GetKeyState(VK_RBUTTON)) || ( HIBYTE(GetKeyState(VK_LBUTTON)) && HIBYTE(GetKeyState(VK_CONTROL))) ) { OnRButtonDown(ptMouse); } else if ( HIBYTE(GetKeyState(VK_LBUTTON)) ) { OnLButtonDown(ptMouse); /* LPARAM lParam = MAKELPARAM((WORD)ptMouse.x, (WORD)ptMouse.y); WPARAM wParam = 0; g_xGameProc.OnLButtonDown(wParam, lParam); */ } } } } } /****************************************************************************************************************** 함수명 : CMyHero::UpdateMove(BOOL bIsMoveTime) 작성자 : 작성일 : 목적 : 입력 : BOOL bIsMoveTime 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CMyHero::UpdateMove(BOOL bIsMoveTime) { if ( !m_bIsMon ) { if ( m_bCurrMtn == _MT_WALK || m_bCurrMtn == _MT_RUN || m_bCurrMtn == _MT_HORSEWALK || m_bCurrMtn == _MT_HORSERUN || m_bCurrMtn == _MT_MOODEPO || m_bCurrMtn == _MT_PUSHBACK) { m_wCurrDelay = 0; if ( bIsMoveTime ) { if ( m_bCurrMtn == _MT_PUSHBACK ) { m_bBackStepFrame += 2; if ( m_bBackStepFrame >= m_bBackStepFrameCnt ) { m_dwCurrFrame++; m_bBackStepFrame = m_bBackStepFrameCnt; } } else if ( m_bCurrMtn == _MT_MOODEPO ) { m_dwCurrFrame += 2; if ( m_dwCurrFrame >= m_dwEndFrame ) { m_dwCurrFrame = m_dwEndFrame; } } else { m_dwCurrFrame++; PlayMoveSound(); /* if ( m_bMsgHurryCheck ) { m_dwCurrFrame++; } */ } if ( m_bCurrMtn == _MT_PUSHBACK ) { if ( m_bBackStepFrame >= m_bBackStepFrameCnt-m_bMoveNextFrmCnt && !m_bIsMoved ) { SetMoved(); m_bIsMoved = TRUE; } } else { if ( m_dwCurrFrame >= m_dwEndFrame-m_bMoveNextFrmCnt && !m_bIsMoved ) { SetMoved(); m_bIsMoved = TRUE; } } } // 연속적인 프레임 중에서 해야할일. if ( m_dwCurrFrame >= m_dwEndFrame ) { m_dwCurrFrame = m_dwEndFrame-1; m_bCanRun = FALSE; switch ( m_bCurrMtn ) { case _MT_MOODEPO: { if ( m_bInputLock ) { m_bIsMoved = FALSE; m_bInputLock = FALSE; m_pxMap->SetMovedTileBuffer(m_shShiftTileX, m_shShiftTileY); m_bMoveSpeed = 0; m_shShiftPixelX = 0; m_shShiftPixelY = 0; m_shShiftTileX = 0; m_shShiftTileY = 0; // 이동후 좌표확인. if ( CheckMyPostion() == FALSE ) AdjustMyPostion(); if ( m_bWarMode ) SetMotionFrame(_MT_ATTACKMODE, m_bCurrDir); else SetMotionFrame(_MT_STAND, m_bCurrDir); } break; } case _MT_PUSHBACK: { if ( m_bInputLock ) { m_bIsMoved = FALSE; m_bInputLock = FALSE; m_pxMap->SetMovedTileBuffer(m_shShiftTileX, m_shShiftTileY); m_bMoveSpeed = 0; m_shShiftPixelX = 0; m_shShiftPixelY = 0; m_shShiftTileX = 0; m_shShiftTileY = 0; m_bBackStepFrame = 0; m_bBackStepFrameCnt = 0; // 이동후 좌표확인. if ( CheckMyPostion() == FALSE ) AdjustMyPostion(); if ( m_bWarMode ) SetMotionFrame(_MT_ATTACKMODE, m_bCurrDir); else SetMotionFrame(_MT_STAND, m_bCurrDir); } break; } case _MT_WALK: case _MT_HORSEWALK: { if ( !m_bMotionLock && m_bInputLock ) { m_bIsMoved = FALSE; m_bInputLock = FALSE; m_pxMap->SetMovedTileBuffer(m_shShiftTileX, m_shShiftTileY); m_bMoveSpeed = 0; m_shShiftPixelX = 0; m_shShiftPixelY = 0; m_shShiftTileX = 0; m_shShiftTileY = 0; if ( m_bCurrMtn == _MT_WALK && m_stFeatureEx.bHorse == _HORSE_NONE ) { if ( m_bWarMode ) { SetMotionFrame(_MT_ATTACKMODE, m_bCurrDir); } else SetMotionFrame(_MT_STAND, m_bCurrDir); } else SetMotionFrame(_MT_HORSESTAND, m_bCurrDir); // 이동후 좌표확인. if ( CheckMyPostion() == FALSE ) AdjustMyPostion(); POINT ptMouse; GetCursorPos(&ptMouse); ScreenToClient(g_xMainWnd.GetSafehWnd(), &ptMouse); if ( HIBYTE(GetKeyState(VK_RBUTTON)) || ( HIBYTE(GetKeyState(VK_LBUTTON)) && HIBYTE(GetKeyState(VK_CONTROL))) ) { m_bCanRun = TRUE; OnRButtonDown(ptMouse); } else if ( HIBYTE(GetKeyState(VK_LBUTTON)) ) { OnLButtonDown(ptMouse); } } break; } case _MT_RUN: case _MT_HORSERUN: { if ( !m_bMotionLock && m_bInputLock ) { m_bIsMoved = FALSE; m_bInputLock = FALSE; m_pxMap->SetMovedTileBuffer(m_shShiftTileX, m_shShiftTileX); m_bMoveSpeed = 0; m_shShiftPixelX = 0; m_shShiftPixelY = 0; m_shShiftTileX = 0; m_shShiftTileY = 0; if ( m_bCurrMtn == _MT_RUN && m_stFeatureEx.bHorse == _HORSE_NONE ) { if ( m_bWarMode ) { SetMotionFrame(_MT_ATTACKMODE, m_bCurrDir); } else SetMotionFrame(_MT_STAND, m_bCurrDir); } else SetMotionFrame(_MT_HORSESTAND, m_bCurrDir); if ( CheckMyPostion() == FALSE ) AdjustMyPostion(); POINT ptMouse; GetCursorPos(&ptMouse); ScreenToClient(g_xMainWnd.GetSafehWnd(), &ptMouse); if ( HIBYTE(GetKeyState(VK_RBUTTON)) || ( HIBYTE(GetKeyState(VK_LBUTTON)) && HIBYTE(GetKeyState(VK_CONTROL))) ) { m_bCanRun = TRUE; OnRButtonDown(ptMouse); } else if ( HIBYTE(GetKeyState(VK_LBUTTON)) ) { OnLButtonDown(ptMouse); } } break; } } } else { switch ( m_bCurrMtn ) { case _MT_WALK: case _MT_RUN: case _MT_HORSEWALK: case _MT_HORSERUN: case _MT_MOODEPO: m_pxMap->ScrollMap(m_bMoveDir, m_dwCurrFrame-m_dwFstFrame, m_bMoveSpeed); // m_pxMap->ScrollMap(m_bMoveDir, m_wCurrDelay, m_wDelay*(m_dwEndFrame-m_dwFstFrame), m_bMoveSpeed); break; case _MT_PUSHBACK: m_pxMap->ScrollMap(m_bMoveDir, m_bBackStepFrame, m_bMoveSpeed); break; } } // 연속적인 프레임 중에서 해야할일. if ( m_dwMotionLockTime > _MOTION_LOCKTIME ) { m_dwMotionLockTime = 0; m_bMotionLock = FALSE; // SetOldPosition(); } if ( m_dwWarModeTime > _WARMODE_TIME ) { m_dwWarModeTime = 0; m_bWarMode = FALSE; } return TRUE; } } else { if ( m_bCurrMtn == _MT_MON_WALK ) { m_wCurrDelay = 0; if ( bIsMoveTime ) { m_dwCurrFrame++; if ( m_dwCurrFrame >= m_dwEndFrame-m_bMoveNextFrmCnt && !m_bIsMoved ) { SetMoved(); m_bIsMoved = TRUE; } } if ( m_dwCurrFrame >= m_dwEndFrame ) { m_dwCurrFrame = m_dwEndFrame-1; m_bCanRun = FALSE; switch ( m_bCurrMtn ) { case _MT_MON_WALK: { if ( !m_bMotionLock && m_bInputLock ) { m_bIsMoved = FALSE; m_bInputLock = FALSE; m_pxMap->SetMovedTileBuffer(m_shShiftTileX, m_shShiftTileY); m_bMoveSpeed = 0; m_shShiftPixelX = 0; m_shShiftPixelY = 0; m_shShiftTileX = 0; m_shShiftTileY = 0; SetMotionFrame(_MT_MON_STAND, m_bCurrDir); // 이동후 좌표확인. if ( CheckMyPostion() == FALSE ) AdjustMyPostion(); POINT ptMouse; GetCursorPos(&ptMouse); ScreenToClient(g_xMainWnd.GetSafehWnd(), &ptMouse); if ( HIBYTE(GetKeyState(VK_LBUTTON)) ) { OnLButtonDown(ptMouse); } } break; } } } else { switch ( m_bCurrMtn ) { case _MT_MON_WALK: m_pxMap->ScrollMap(m_bMoveDir, m_dwCurrFrame-m_dwFstFrame, m_bMoveSpeed); break; } } // 연속적인 프레임 중에서 해야할일. if ( m_dwMotionLockTime > _MOTION_LOCKTIME ) { m_dwMotionLockTime = 0; m_bMotionLock = FALSE; // SetOldPosition(); } if ( m_dwWarModeTime > _WARMODE_TIME ) { m_dwWarModeTime = 0; m_bWarMode = FALSE; } return TRUE; } } return FALSE; } /****************************************************************************************************************** 함수명 : CMyHero:DrawActor() 작성자 : 작성일 : 목적 : 입력 : BOOL bFocused BOOL bShadowAblended 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CMyHero::DrawActor(BOOL bFocused, BOOL bShadowAblended, BOOL bUseScrnPos, BOOL bDrawShadow) { // 캐릭터 좌표는 고정. m_shScrnPosX = _CHAR_CENTER_XPOS - 24; m_shScrnPosY = _CHAR_CENTER_YPOS - 16; if ( m_bIsMon ) { if ( CActor::DrawActor(m_pxMap, bFocused, bShadowAblended, bUseScrnPos, bDrawShadow) ) return TRUE; } else { if ( CHero::DrawActor(m_pxMap, bFocused, bShadowAblended, bUseScrnPos, bDrawShadow) ) return TRUE; } return FALSE; } /****************************************************************************************************************** 함수명 : CMyHero::CalcDirection() 작성자 : 작성일 : 목적 : 입력 : INT nTargetTileX INT nTargetTileY 출력 : [일자][수정자] : 수정내용 *******************************************************************************************************************/ BYTE CMyHero::CalcDirection(INT nTargetTileX, INT nTargetTileY) { INT nWidth = nTargetTileX - m_wPosX; INT nHeight = nTargetTileY - m_wPosY; FLOAT rLineLength, rBottomInTriangle; INT nDimension; BYTE bDir; rLineLength = (FLOAT)sqrt(nWidth*nWidth+nHeight*nHeight); // 기본. // 7 0 1 // 6 2 // 5 4 3 // 일단은 4개의 분면(90도기준)으로 나누고 분면에 대한 cos값을 적용한다. ( nWidth >= 0 ) ? ( nHeight < 0 ? (rBottomInTriangle=(FLOAT)-nHeight, nDimension=0) : (rBottomInTriangle=(FLOAT) nWidth, nDimension=2) ): ( nHeight >= 0 ? (rBottomInTriangle=(FLOAT) nHeight, nDimension=4) : (rBottomInTriangle=(FLOAT)-nWidth, nDimension=6) ); // 6(cos45) 0(cos 0) 0(cos45) // 4(cos90) 2(cos 0) 2(cos 0) // 4(cos45) 2(cos90) 2(cos45) FLOAT rCosVal = rBottomInTriangle/rLineLength; // cos(0), cos(pi/8), cos(pi/4), cos(pi/2) CONST FLOAT rCosVal8[4] = { 1.0f, 0.923880f, 0.707107f, 0.382683f }; // 각분면을 3개의 영역으로 나누어서 영역을 재조정한다. bDir = 0; for ( INT nCnt = 0; nCnt < 4; nCnt++ ) { if( rCosVal <= rCosVal8[nCnt] ) bDir = nDimension+(nCnt+1)/2; else break; } if( bDir >= 8 ) bDir = 0; return bDir; } /****************************************************************************************************************** 함수명 : CMyHero::GetPosMouseToTile() 작성자 : 작성일 : 목적 : 입력 : INT nXPos INT nYPos 출력 : POINT [일자][수정자] : 수정내용 *******************************************************************************************************************/ POINT CMyHero::GetPosMouseToTile(INT nXPos, INT nYPos) { POINT ptTilePos; if ( m_pxMap ) { ptTilePos.x = m_pxMap->m_shStartViewTileX + (nXPos - _VIEW_CELL_X_START) / _CELL_WIDTH; ptTilePos.y = m_pxMap->m_shStartViewTileY + (nYPos - _VIEW_CELL_Y_START) / _CELL_HEIGHT; } return ptTilePos; } BOOL CMyHero::CanNextHit() { DWORD dwCurrTick; INT nNextHit, nLevelFast; BOOL bAttackSlow = FALSE; nLevelFast = min(370, m_stAbility.bLevel*14); nLevelFast = min(800, nLevelFast + m_shHitSpeed * 60); if ( m_stAbility.bHandWeight > m_stAbility.bMaxHandWeight ) bAttackSlow = TRUE; if ( bAttackSlow ) nNextHit = 1400 - nLevelFast + 1500; else nNextHit = 1400 - nLevelFast; dwCurrTick = timeGetTime(); if ( dwCurrTick - m_dwLastHitTime > nNextHit ) { m_dwLastHitTime = dwCurrTick; return TRUE; } return FALSE; } BOOL CMyHero::CanWalk() { if ( timeGetTime() - m_dwLastSpellTime < m_wMagicPKDelayTime ) return TRUE; return FALSE; } BOOL CMyHero::CanRun() { if ( m_stAbility.wHP < _RUN_MINHEALTH ) return FALSE; if ( (timeGetTime() - m_dwLastPKStruckTime < 3000) || (timeGetTime() - m_dwLastSpellTime < m_wMagicPKDelayTime ) ) return FALSE; return TRUE; } //---------------------------------------------------------------------------------------------------------------// // 유저 입력함수. //---------------------------------------------------------------------------------------------------------------// /****************************************************************************************************************** 함수명 : CMyHero::OnLButtonDown() 작성자 : 작성일 : 목적 : 입력 : POINT ptMouse INT nTargetID POINT* lpptTargetPos 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CMyHero::OnLButtonDown(POINT ptMouse, INT nTargetID, BOOL bIsDead, POINT* lpptTargetPos) { POINT ptTargetTile; POINT ptMouseTilePos; BYTE bDir; if ( g_xGameProc.m_xInterface.OnLButtonDown(ptMouse) ) return FALSE; if ( m_wABlendDelay ) return FALSE; if ( !m_bMotionLock && !m_bInputLock ) { SHORT shLeftMsgCnt = m_xPacketQueue.GetCount(); if ( shLeftMsgCnt > 0 ) { UpdatePacketState(); return FALSE; } ptMouseTilePos = GetPosMouseToTile(ptMouse.x, ptMouse.y); bDir = CalcDirection(ptMouseTilePos.x, ptMouseTilePos.y); if ( m_wPosX == ptMouseTilePos.x && m_wPosY == ptMouseTilePos.y ) bDir = m_bCurrDir; INT nLength; if ( lpptTargetPos ) nLength = (INT)sqrt((m_wPosX-lpptTargetPos->x)*(m_wPosX-lpptTargetPos->x) + (m_wPosY-lpptTargetPos->y)*(m_wPosY-lpptTargetPos->y)); else nLength = (INT)sqrt((m_wPosX-ptMouseTilePos.x)*(m_wPosX-ptMouseTilePos.x) + (m_wPosY-ptMouseTilePos.y)*(m_wPosY-ptMouseTilePos.y)); // 1. SHIFT.(강제 공격) if ( HIBYTE(GetKeyState(VK_SHIFT)) ) { if ( m_stFeatureEx.bHorse == _HORSE_NONE ) { if ( m_bUseErgum && g_xGameProc.TargetInLongAttack(bDir) ) { if ( m_stFeatureEx.bHorse == _HORSE_NONE && !bIsDead ) { // 공격한다. ptTargetTile.x = m_wPosX; ptTargetTile.y = m_wPosY; SetMotionState(_MT_ONEHSWING, bDir, nTargetID, bIsDead, &ptTargetTile); } } else { ptTargetTile.x = m_wPosX; ptTargetTile.y = m_wPosY; SetMotionState(_MT_ONEHSWING, bDir, nTargetID, bIsDead, &ptTargetTile); } } } // 2. ALT.(썰기) else if ( HIBYTE(GetKeyState(VK_MENU)) ) { SetMotionState(_MT_CUT, bDir, nTargetID, bIsDead, &ptTargetTile); } /* // 3. 클릭한타일이 내 캐릭터가 위치한 곳인가? else if () { // 아이템이 있는가? if () { // 아이템을 줍는다. } }*/ // 4. 클릭한 좌표가 Actor 영역 안에 있는가? else if ( nTargetID != -1 && lpptTargetPos ) { //1. 타겟 타일의 위치가 1타일 이내인가? if ( nLength < 2 && nLength > 0 ) { if ( m_stFeatureEx.bHorse == _HORSE_NONE && !bIsDead ) { // 공격한다. ptTargetTile.x = m_wPosX; ptTargetTile.y = m_wPosY; bDir = CalcDirection(lpptTargetPos->x, lpptTargetPos->y); SetMotionState(_MT_ONEHSWING, bDir, nTargetID, bIsDead, &ptTargetTile); } } // Actor가 있는 방향으로 이동 가능한가?(맵속성체크) else if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 1, &ptTargetTile) && nLength > 0) { // 1타일 이동한다. if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_WALK, bDir, nTargetID, bIsDead, &ptTargetTile); else SetMotionState(_MT_HORSEWALK, bDir, nTargetID, bIsDead, &ptTargetTile); } else { if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_STAND, bDir); else SetMotionState(_MT_HORSESTAND, bDir); } /*// Actor가 NPC인가? if () { // 대화창이나 상점창을 연다. } // Actor가 공격 가능한가? else if() { // Actor의 위치가 1타일 내인가? if () { // 공격한다. } // Actor가 있는 방향으로 이동 가능한가?(맵속성체크) else if () { // 1타일 이동한다. } }*/ } // 6. 현재 마우스타일방향으로 이동 가능한가?(맵속성체크) else if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 1, &ptTargetTile) && nLength > 0 ) { // 1타일 이동한다. if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_WALK, bDir, nTargetID, bIsDead, &ptTargetTile); else SetMotionState(_MT_HORSEWALK, bDir, nTargetID, bIsDead, &ptTargetTile); } // 7. 이동 할수 없다면 주변에 이동할수 있는 타일을 찾아내어 목적 타일과의 가장 가까운 타일을 찾아낸다. else if ( !m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 1, &ptTargetTile) ) { INT nSelectedDir = -1; INT nDistance; INT nSelectedDistance = 100; for ( INT nCnt = 0; nCnt < _MAX_DIRECTION; nCnt++ ) { if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, nCnt, 1, &ptTargetTile) ) { nDistance = (INT)(sqrt((ptTargetTile.x-ptMouseTilePos.x)*(ptTargetTile.x-ptMouseTilePos.x) + (ptTargetTile.y-ptMouseTilePos.y)*(ptTargetTile.y-ptMouseTilePos.y))); if ( nDistance <= nSelectedDistance ) { nSelectedDistance = nDistance; nSelectedDir = nCnt; } } } if ( nSelectedDir != -1 && nDistance > 0 ) { // 1타일 이동한다. m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, nSelectedDir, 1, &ptTargetTile); if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_WALK, nSelectedDir, nTargetID, bIsDead, &ptTargetTile); else SetMotionState(_MT_HORSEWALK, nSelectedDir, nTargetID, bIsDead, &ptTargetTile); } else { if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_STAND, bDir); else SetMotionState(_MT_HORSESTAND, bDir); } } else { if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_STAND, bDir); else SetMotionState(_MT_HORSESTAND, bDir); } } return FALSE; } /****************************************************************************************************************** 함수명 : CMyHero::OnRButtonDown() 작성자 : 작성일 : 목적 : 입력 : POINT ptMouse 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CMyHero::OnRButtonDown(POINT ptMouse) { POINT ptTargetTile; POINT ptMouseTilePos; BYTE bDir; if ( m_wABlendDelay ) return FALSE; if ( !m_bMotionLock && !m_bInputLock ) { SHORT shLeftMsgCnt = m_xPacketQueue.GetCount(); if ( shLeftMsgCnt > 0 ) { UpdatePacketState(); return FALSE; } ptMouseTilePos = GetPosMouseToTile(ptMouse.x, ptMouse.y); bDir = CalcDirection(ptMouseTilePos.x, ptMouseTilePos.y); //1. 타겟 타일의 위치가 1타일 이내인가? if ( (INT)(sqrt((m_wPosX-ptMouseTilePos.x)*(m_wPosX-ptMouseTilePos.x) + (m_wPosY-ptMouseTilePos.y)*(m_wPosY-ptMouseTilePos.y))) < 2 ) { // 방향을 바꾼다. if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_STAND, bDir); else SetMotionState(_MT_HORSESTAND, bDir); } //2. 움직인다. else { // 달릴수 있을때. if ( m_bCanRun ) { m_bCanRun = FALSE; if ( m_stFeatureEx.bHorse != _HORSE_NONE ) { // 목적지타일과의 방향으로 1, 2, 3타일째의 위치에 방해물이 없을때. if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 1, &ptTargetTile) && m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 2, &ptTargetTile) && m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 3, &ptTargetTile) ) { // 3타일 이동한다. m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 3, &ptTargetTile); SetMotionState(_MT_HORSERUN, bDir, 0, FALSE, &ptTargetTile); } // 목적지타일과의 방향으로 1타일째의 위치에 방해물이 없을때. else if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 1, &ptTargetTile) ) { SetMotionState(_MT_HORSEWALK, bDir, 0, FALSE, &ptTargetTile); } // 목적지타일과의 방향으로 1타일째의 위치에 방해물이 있을때. else { INT nSelectedDir = -1; INT nDistance; INT nSelectedDistance = 100; for ( INT nCnt = 0; nCnt < _MAX_DIRECTION; nCnt++ ) { if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, nCnt, 1, &ptTargetTile) ) { nDistance = (INT)(sqrt((ptTargetTile.x-ptMouseTilePos.x)*(ptTargetTile.x-ptMouseTilePos.x) + (ptTargetTile.y-ptMouseTilePos.y)*(ptTargetTile.y-ptMouseTilePos.y))); if ( nDistance <= nSelectedDistance ) { nSelectedDistance = nDistance; nSelectedDir = nCnt; } } } if ( nSelectedDir != -1 ) { // 1타일 이동한다. m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, nSelectedDir, 1, &ptTargetTile); SetMotionState(_MT_HORSEWALK, nSelectedDir, 0, FALSE, &ptTargetTile); } else { SetMotionState(_MT_HORSESTAND, nSelectedDir); } } } // 말을 안타고 있을때. else { // 목적지타일과의 방향으로 1, 2타일째의 위치에 방해물이 없을때. if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 1, &ptTargetTile) && m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 2, &ptTargetTile) ) { // 2타일 이동한다. m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 2, &ptTargetTile); SetMotionState(_MT_RUN, bDir, 0, FALSE, &ptTargetTile); } // 목적지타일과의 방향으로 1타일째의 위치에 방해물이 없을때. else if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 1, &ptTargetTile) ) { SetMotionState(_MT_WALK, bDir, 0, FALSE, &ptTargetTile); } // 목적지타일과의 방향으로 1타일째의 위치에 방해물이 있을때. else { INT nSelectedDir = -1; INT nDistance; INT nSelectedDistance = 100; for ( INT nCnt = 0; nCnt < _MAX_DIRECTION; nCnt++ ) { if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, nCnt, 1, &ptTargetTile) ) { nDistance = (INT)(sqrt((ptTargetTile.x-ptMouseTilePos.x)*(ptTargetTile.x-ptMouseTilePos.x) + (ptTargetTile.y-ptMouseTilePos.y)*(ptTargetTile.y-ptMouseTilePos.y))); if ( nDistance <= nSelectedDistance ) { nSelectedDistance = nDistance; nSelectedDir = nCnt; } } } if ( nSelectedDir != -1 ) { // 1타일 이동한다. m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, nSelectedDir, 1, &ptTargetTile); SetMotionState(_MT_WALK, nSelectedDir, 0, FALSE, &ptTargetTile); } else { SetMotionState(_MT_STAND, nSelectedDir); } } } } else { // 목적지타일과의 방향으로 1타일째의 위치에 방해물이 없을때. if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, bDir, 1, &ptTargetTile) ) { if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_WALK, bDir, 0, FALSE, &ptTargetTile); else SetMotionState(_MT_HORSEWALK, bDir, 0, FALSE, &ptTargetTile); } // 목적지타일과의 방향으로 1타일째의 위치에 방해물이 있을때. else { INT nSelectedDir = -1; INT nDistance; INT nSelectedDistance = 100; for ( INT nCnt = 0; nCnt < _MAX_DIRECTION; nCnt++ ) { if ( m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, nCnt, 1, &ptTargetTile) ) { nDistance = (INT)(sqrt((ptTargetTile.x-ptMouseTilePos.x)*(ptTargetTile.x-ptMouseTilePos.x) + (ptTargetTile.y-ptMouseTilePos.y)*(ptTargetTile.y-ptMouseTilePos.y))); if ( nDistance <= nSelectedDistance ) { nSelectedDistance = nDistance; nSelectedDir = nCnt; } } } if ( nSelectedDir != -1 ) { // 1타일 이동한다. m_pxMap->GetNextTileCanMove(m_wPosX, m_wPosY, nSelectedDir, 1, &ptTargetTile); if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_WALK, nSelectedDir, 0, FALSE, &ptTargetTile); else SetMotionState(_MT_HORSEWALK, nSelectedDir, 0, FALSE, &ptTargetTile); } else { if ( m_stFeatureEx.bHorse == _HORSE_NONE ) SetMotionState(_MT_STAND, bDir); else SetMotionState(_MT_HORSESTAND, bDir); } } } } } return FALSE; } VOID CMyHero::SetMagic(LPCLIENTMAGICRCD pstMagic, BYTE bKeyNum, BYTE bDir, INT nTargetID, FEATURE stTargetFeature, POINT ptTargetPos) { DWORD dwCurrTick = timeGetTime(); if ( !m_bMotionLock && !m_bInputLock ) { switch ( m_shCurrMagicID ) { case _SKILL_MOOTEBO: if ( dwCurrTick - m_dwLastRushTime > 3000 ) { SetMotionState(_MT_MOODEPO, bDir, 0, FALSE, &ptTargetPos, m_shCurrMagicID); // SetMotionState(_MT_MOODEPO, bDir, &ptTargetPos, bKeyNum, 0); } break; case _SKILL_HANGMAJINBUB: case _SKILL_DEJIWONHO: case _SKILL_FIRECHARM: case _SKILL_FIRE: case _SKILL_FIREBALL2: case _SKILL_SINSU: case _SKILL_FIREBALL: case _SKILL_SHOOTLIGHTEN: case _SKILL_BIGCLOAK: m_dwLastSpellTime = dwCurrTick; m_wMagicDelayTime = 200 + pstMagic->stStdMagic.nDelayTime; SetMotionState(_MT_SPELL1, bDir, nTargetID, TRUE, &ptTargetPos, m_shCurrMagicID); break; case _SKILL_FIREWIND: case _SKILL_AMYOUNSUL: case _SKILL_TAMMING: case _SKILL_KILLUNDEAD: case _SKILL_HEALLING: case _SKILL_HOLYSHIELD: case _SKILL_BIGHEALLING: case _SKILL_LIGHTFLOWER: case _SKILL_SKELLETON: case _SKILL_SNOWWIND: case _SKILL_SHIELD: case _SKILL_SHOWHP: case _SKILL_EARTHFIRE: case _SKILL_FIREBOOM: case _SKILL_SPACEMOVE: case _SKILL_CLOAK: case _SKILL_LIGHTENING: m_dwLastSpellTime = dwCurrTick; m_wMagicDelayTime = 200 + pstMagic->stStdMagic.nDelayTime; SetMotionState(_MT_SPELL2, bDir, nTargetID, TRUE, &ptTargetPos, m_shCurrMagicID); break; } } switch ( m_shCurrMagicID ) { // 염화결. case _SKILL_FIRESWORD: if ( dwCurrTick - m_dwLastFireHitTime > 10000 ) g_xClientSocket.SendSpellMsg(m_shCurrMagicID, 0, 0, nTargetID); break; // 염화결이외의 검법. case _SKILL_BANWOL: case _SKILL_ERGUM: if ( dwCurrTick - m_dwLastSpellTime > 200 ) { m_dwLastSpellTime = dwCurrTick; m_wMagicDelayTime = 0; g_xClientSocket.SendSpellMsg(m_shCurrMagicID, 0, 0, nTargetID); } break; } // 공격마법일때 접속종료 못하게하는 Delay. switch ( m_shCurrMagicID ) { case _SKILL_MOOTEBO: case _SKILL_FIRESWORD: case _SKILL_BANWOL: case _SKILL_ERGUM: case _SKILL_FIRECHARM: case _SKILL_FIRE: case _SKILL_FIREBALL2: case _SKILL_FIREBALL: case _SKILL_SHOOTLIGHTEN: case _SKILL_AMYOUNSUL: case _SKILL_KILLUNDEAD: case _SKILL_LIGHTFLOWER: case _SKILL_SNOWWIND: case _SKILL_EARTHFIRE: m_dwLastMagicTime = dwCurrTick; break; } // 사람을 공격했을때 움직임 패널티 Delay. m_wMagicPKDelayTime = 0; if ( nTargetID ) { if ( stTargetFeature.bGender == 0 || stTargetFeature.bGender == 1 ) m_wMagicPKDelayTime = 300 + GetRandomNum(1, 1100); } } /****************************************************************************************************************** 함수명 : CMyHero::OnKeyDown() 작성자 : 작성일 : 목적 : 입력 : WPARAM wParam LPARAM lParam POINT ptMouse 출력 : BOOL [일자][수정자] : 수정내용 *******************************************************************************************************************/ BOOL CMyHero::OnKeyDown(WPARAM wParam, LPARAM lParam, POINT ptMouse, POINT ptTargetPos, INT nMosueTargetID, FEATURE stTargetFeature) { BYTE bDir, bMagicKey; POINT ptTargetTile, ptMouseTilePos; LPCLIENTMAGICRCD pstMagic; DWORD dwCurrTick; bMagicKey = 0; ZeroMemory(&ptTargetTile, sizeof(POINT)); switch ( wParam ) { case 'A': { } case VK_F1: { bMagicKey = '1'; break; } case VK_F2: { bMagicKey = '2'; break; } case VK_F3: { bMagicKey = '3'; break; } case VK_F4: { bMagicKey = '4'; break; } case VK_F5: { bMagicKey = '5'; break; } case VK_F6: { bMagicKey = '6'; break; } case VK_F7: { bMagicKey = '7'; break; } case VK_F8: { bMagicKey = '8'; break; } case VK_SPACE: { static INT nMode = 0; nMode++; switch ( nMode ) { case 0: m_bAttackMode = _MT_ONEHSWING; break; case 1: m_bAttackMode = _MT_ONEVSWING; break; case 2: m_bAttackMode = _MT_TWOVSWING; break; case 3: m_bAttackMode = _MT_TWOHSWING; break; case 4: m_bAttackMode = _MT_SPEARVSWING; break; case 5: m_bAttackMode = _MT_SPEARHSWING; break; case 6: m_bAttackMode = _MT_WHEELWIND; break; case 7: m_bAttackMode = _MT_RANDSWING; break; case 8: m_bAttackMode = _MT_BACKDROPKICK; break; case 9: m_bAttackMode = _MT_ONEHSWING; break; } if ( nMode > 8 ) nMode = 0; break; } } dwCurrTick = timeGetTime(); // 마법이용가능 Delay Time Check. if ( dwCurrTick - m_dwLastSpellTime > 500 + m_wMagicDelayTime ) { // 마법이 제대로 세팅되었는지 Check. if ( bMagicKey ) { if ( nMosueTargetID == NULL ) ptMouseTilePos = GetPosMouseToTile(ptMouse.x, ptMouse.y); else ptMouseTilePos = ptTargetPos; bDir = CalcDirection(ptMouseTilePos.x, ptMouseTilePos.y); pstMagic = g_xGameProc.m_xInterface.m_xStatusWnd.GetMagicByKey(bMagicKey); if ( pstMagic ) { if ( (10 + pstMagic->stStdMagic.bDefSpell) <= m_stAbility.wMP ) { m_shCurrMagicID = pstMagic->stStdMagic.wMagicID; SetMagic(pstMagic, bMagicKey, bDir, nMosueTargetID, stTargetFeature, ptMouseTilePos); } else g_xGameProc.m_xInterface.m_xClientSysMsg.AddSysMsg("마력이 모자랍니다."); } } } return TRUE; }
[ "fjljfat@4a88d1ba-22b1-11df-8001-4f4b503b426e" ]
[ [ [ 1, 6162 ] ] ]
a79c55664c4d7bdf26df503bde2d7c842ba798be
5d3c1be292f6153480f3a372befea4172c683180
/trunk/Event Heap/c++/Windows/samples/4_errorHandler/StatefulErrorHandlerTest.h
2f7946dd6c81ba2e6a821255158a55160f1b1f5e
[ "Artistic-2.0" ]
permissive
BackupTheBerlios/istuff-svn
5f47aa73dd74ecf5c55f83765a5c50daa28fa508
d0bb9963b899259695553ccd2b01b35be5fb83db
refs/heads/master
2016-09-06T04:54:24.129060
2008-05-02T22:33:26
2008-05-02T22:33:26
40,820,013
0
0
null
null
null
null
UTF-8
C++
false
false
4,365
h
#include <idk.h> #include <idk_th.h> #include <idk_ne.h> #include <idk_ut.h> // // this is an example of "stateful" error handler. // error handler of this type is spawned per each connection by // an error handler factory and there's no chance to be called // from multiple threads at the same time. // this type is suitable for tasks which require variable states. // this sample shows an implementation of stateful error handler // which marks any servers unable to be connected for the specified // duration as dead so that the app can check the server's status. // // // exception to notify that the connection is failing for a long time. // class ConnectionTimedoutException : public idk_ut_Exception { IDK_UT_EXCEPTION_DECL(ConnectionTimedoutException, idk_ut_Exception); }; IDK_UT_EXCEPTION_IMPL(ConnectionTimedoutException, idk_ut_Exception); // // stateful error handler. // class TimeoutErrorHandler : public idk_ut_RealObject, public eh2_ConnectErrorHandler // Stateful handler does not need lock. { IDK_UT_REFCOUNTED_IMPL(); // this macro is necessary to mix-in // eh2_ConnectErrorHandler interface private: int m_timeoutDuration; idk_long m_timeoutAbsTime; int m_serverDead; public: // the timeout value is passed by the factory TimeoutErrorHandler(int timeout) { m_timeoutDuration = timeout; m_timeoutAbsTime = 0; m_serverDead = 0; } int isServerDead() const { return m_serverDead; } virtual void startConnect(eh2_ErrorContext* ctx) { // calculates the absolute time of timeout m_timeoutAbsTime = idk_ut_SystemUtil::getCurrentTimeMillis() + m_timeoutDuration; } virtual void endConnect(eh2_ErrorContext* ctx, int isSuccess) { if (isSuccess) { // connection established. // if the server was marked as "dead", clears it. m_serverDead = 0; } } virtual void errorOnConnect(eh2_ErrorContext* ctx, idk_ut_Exception& ex) { int diff = m_timeoutAbsTime - idk_ut_SystemUtil::getCurrentTimeMillis(); if (diff > 0) { // timeout has not been reached yet. seems temporary failure. printf("TimeoutErrorHandler: Connection failed, retrying. (%d milliseconds left)\n", diff); } else { printf("TimeoutErrorHandler: Attempt to connect timed out. The server seems dead.\n"); // timeout has been reached. the server seems dead. m_serverDead = 1; // throws an exception to terminate the attempt in case of // blocking app's thread. throw ConnectionTimedoutException("Attempt to connect timed out"); } } }; IDK_UT_SHAREDPTR_DECL(TimeoutErrorHandler); // // main // class StatefulErrorHandlerTest : eh2_Consts { public: void run() { eh2_EventHeapFactory* ehf = eh2_EventHeapFactory::cs_getInstance(); // create an instance of error handler // the handler is stateful, so you have to create // one instance per connection. TimeoutErrorHandlerPtr errorHandlerPtr = new TimeoutErrorHandler(15000); // 15 secs for timeout try { // create a connection passing the error handler // instead of creating an event heap client directly. // an exception can be raised by the error handler. eh2_ConnectionPtr connPtr = ehf->createConnection("localhost", -1, errorHandlerPtr.cast()); // create an event heap client object eh2_EventHeapPtr ehPtr = connPtr->createEventHeap(NULL, 0); // set timeout to poll the server's state. ehPtr->setTimeout(3000); eh2_EventPtr templatePtr = eh2_Event::cs_create("MyEvent"); while (1) { try { printf("Waiting for MyEvent...\n"); eh2_EventPtr resultPtr = ehPtr->waitForEvent(templatePtr); printf("MyEvent %d received.\n", resultPtr->getPostValueInt(FN_SEQUENCENUM) ); } catch (idk_th_MonitorTimedoutException&) { // waitForEvent timed out. // Checks if the server is dead. if (errorHandlerPtr->isServerDead()) { // The server seems dead. exits program. printf("The error handler indicated the server is dead. Exiting...\n"); break; } } } } catch (idk_ut_Exception& ex) { printf("Exception raised. [%s]\n", ex.getMessage()); } // the error handler must be healthy until all connections // and event heap clients which use the handler are gone. } };
[ "ballagas@2a53cb5c-8ff1-0310-8b75-b3ec22923d26" ]
[ [ [ 1, 141 ] ] ]
6d4cc95b08c6069ead1df3dd39322cb22f3bd301
877bad5999a3eeab5d6d20b5b69a273b730c5fd8
/TestKhoaLuan/DirectShowTVSample/WinCap/SampleGrabber.cpp
ab5affe28c04123d7dff681e168df6033bb9f4ef
[]
no_license
eaglezhao/tracnghiemweb
ebdca23cb820769303d27204156a2999b8381e03
aaae7bb7b9393a8000d395c1d98dcfc389e3c4ed
refs/heads/master
2021-01-10T12:26:27.694468
2010-10-06T01:15:35
2010-10-06T01:15:35
45,880,587
1
0
null
null
null
null
UTF-8
C++
false
false
5,001
cpp
#include "StdAfx.h" #include "samplegrabber.h" //----------------------------------------------------------------------------- // Name: StillCap() // Desc: Constructor //----------------------------------------------------------------------------- StillCap::StillCap(void) : m_cRef(0) { ZeroMemory(&m_MediaType, sizeof(AM_MEDIA_TYPE)); } //----------------------------------------------------------------------------- // Name: ~StillCap() // Desc: Destructor //----------------------------------------------------------------------------- StillCap::~StillCap(void) { _ASSERTE(m_cRef == 0); } //----------------------------------------------------------------------------- // Name: SetMediaType() // Desc: Store the media type that the Sample Grabber connected with // // mt: Reference to the media type //----------------------------------------------------------------------------- HRESULT StillCap::SetMediaType(AM_MEDIA_TYPE& mt) { if (mt.majortype != MEDIATYPE_Video) { return VFW_E_INVALIDMEDIATYPE; } if ((mt.formattype != FORMAT_VideoInfo) || (mt.cbFormat < sizeof(VIDEOINFOHEADER)) || (mt.pbFormat == NULL)) { return VFW_E_INVALIDMEDIATYPE; } return CopyMediaType(&m_MediaType, &mt); } //----------------------------------------------------------------------------- // Name: QueryInterface() // Desc: Our impementation of IUnknown::QueryInterface //----------------------------------------------------------------------------- STDMETHODIMP StillCap::QueryInterface(REFIID riid, void **ppvObject) { if (NULL == ppvObject) return E_POINTER; if (riid == __uuidof(IUnknown)) *ppvObject = static_cast<IUnknown*>(this); else if (riid == __uuidof(ISampleGrabberCB)) *ppvObject = static_cast<ISampleGrabberCB*>(this); else return E_NOTIMPL; AddRef(); return S_OK; } // Note: ISampleGrabber supports two callback methods: One gets the IMediaSample // and one just gets a pointer to the buffer. //----------------------------------------------------------------------------- // Name: SampleCB() // Desc: Callback that gets the media sample. (NOTIMPL - We don't use this one.) //----------------------------------------------------------------------------- STDMETHODIMP StillCap::SampleCB(double SampleTime, IMediaSample *pSample) { return E_NOTIMPL; } //----------------------------------------------------------------------------- // Name: BufferCB() // Desc: Callback that gets the buffer. We write the bits to a bmp file. // // Note: In general it's a bad idea to do anything time-consuming inside the // callback (like write a bmp file) because you can stall the graph. Also // on Win9x you might be holding the Win16 Mutex which can cause deadlock. // // Here, I know that (a) I'm not rendering the video, (b) I'm getting still // images one at a time, not a stream, (c) I'm running XP. However there's // probably a better way to design this. //----------------------------------------------------------------------------- STDMETHODIMP StillCap::BufferCB(double SampleTime, BYTE *pBuffer, long BufferLen) { // Create the file. HANDLE hf = CreateFile( "C:\\Test.bmp", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL ); if (hf == INVALID_HANDLE_VALUE) { MessageBox(0, TEXT("Cannot create the file!"), TEXT("Error"), MB_OK | MB_ICONERROR); return E_FAIL; } // Size of the BITMAPINFO part of the VIDEOINFOHEADER long cbBitmapInfoSize = m_MediaType.cbFormat - SIZE_PREHEADER; // BITMAPINFO is the BITMAPINFOHEADER plus (possibly) palette entries or color masks, // so the size can change. We have to be careful to write the correct number of bytes. // In theory we validated these assumptions earlier _ASSERTE(m_MediaType.formattype == FORMAT_VideoInfo); _ASSERTE(m_MediaType.cbFormat >= sizeof(VIDEOINFOHEADER)); _ASSERTE(m_MediaType.pbFormat != NULL); VIDEOINFOHEADER *pVideoHeader = (VIDEOINFOHEADER*)m_MediaType.pbFormat; // I'm forcing the biCompression to RGB to work around a driver issue (?) in the // Logitech web cam. The camera sets biCompression to FOURCC 'RGB5' which doesn't // mean anything as far as I can determine. pVideoHeader->bmiHeader.biCompression = 0; // Prepare the bitmap file header BITMAPFILEHEADER bfh; ZeroMemory(&bfh, sizeof(bfh)); bfh.bfType = 'MB'; // Little-endian bfh.bfSize = sizeof( bfh ) + BufferLen + cbBitmapInfoSize; bfh.bfOffBits = sizeof( BITMAPFILEHEADER ) + cbBitmapInfoSize; DWORD dwWritten = 0; // Write the file header WriteFile( hf, &bfh, sizeof( bfh ), &dwWritten, NULL ); dwWritten = 0; // Write the BITMAPINFO WriteFile(hf, HEADER(pVideoHeader), cbBitmapInfoSize, &dwWritten, NULL); // Write the bits dwWritten = 0; WriteFile( hf, pBuffer, BufferLen, &dwWritten, NULL ); CloseHandle( hf ); return S_OK; }
[ [ [ 1, 161 ] ] ]
f7b41d65a97d1ffb7c04536860212340de3af1b9
f177b64040f6e70ff885ca6911babf647103ddaa
/source/Images.cpp
c9a2dd37c4ec80a74c2779983d41fb8ff3cf60aa
[]
no_license
xflash/redraid
b7b662853a09e529e20b5ceee74b4f51ba6d6689
1d6b010bbadc2586232ec92df99be7ec49adb43d
refs/heads/master
2016-09-10T03:57:18.746840
2008-06-07T16:11:18
2008-06-07T16:11:18
32,315,933
0
0
null
null
null
null
UTF-8
C++
false
false
566
cpp
#include <ulib/ulib.h> #include "Images.h" #include "gfx_creep.h" #include "gfx_health.h" #include "gfx_bullet.h" #include "gfx_select.h" const T_IMAGE images[] = { {ID_CREEP, (const char*)gfx_creep, (int)gfx_creep_size, 16, 16, 10}, {ID_HEALTH, (const char*)gfx_health, (int)gfx_health_size, 31, 4, 10}, {ID_BULLET, (const char*)gfx_bullet, (int)gfx_bullet_size, 8, 8, 10}, {ID_SELECTOR, (const char*)gfx_select, (int)gfx_select_size, 24, 24, 10}, }; unsigned int getImagesSize() { return (sizeof(images)/sizeof(T_IMAGE)); }
[ "rcoqueugniot@c32521c4-154f-0410-b136-dfa89fbbf926" ]
[ [ [ 1, 17 ] ] ]
78c4b224b2ce6ab1c7066d2682a46dd536bd421e
7f07dc82acc4672d7c121ab4bf5329a71eb77c70
/inc/GuitarTuner.h
961be3ce7da7e3b13e0f19e3f9e2caee372abbb9
[]
no_license
drstrangecode/Bada_EasyGuitarTuner
4f24fa9d79d2f45215f42f3c69a30bc14c3af99a
55bc9a85e63895ddd9a24fc8b23d7343a1453715
refs/heads/master
2020-06-09T05:40:30.390031
2011-11-05T11:57:10
2011-11-05T11:57:10
2,636,726
0
0
null
null
null
null
UTF-8
C++
false
false
1,479
h
#ifndef _GUITARTUNER_H_ #define _GUITARTUNER_H_ #include <FApp.h> #include <FBase.h> #include <FSystem.h> #include <FUi.h> /** * [GuitarTuner] application must inherit from Application class * which provides basic features necessary to define an application. */ class GuitarTuner : public Osp::App::Application, public Osp::System::IScreenEventListener { public: /** * [GuitarTuner] application must have a factory method that creates an instance of itself. */ static Osp::App::Application* CreateInstance(void); public: GuitarTuner(); ~GuitarTuner(); public: // Called when the application is initializing. bool OnAppInitializing(Osp::App::AppRegistry& appRegistry); // Called when the application is terminating. bool OnAppTerminating(Osp::App::AppRegistry& appRegistry, bool forcedTermination = false); // Called when the application's frame moves to the top of the screen. void OnForeground(void); // Called when this application's frame is moved from top of the screen to the background. void OnBackground(void); // Called when the system memory is not sufficient to run the application any further. void OnLowMemory(void); // Called when the battery level changes. void OnBatteryLevelChanged(Osp::System::BatteryLevel batteryLevel); // Called when the screen turns on. void OnScreenOn (void); // Called when the screen turns off. void OnScreenOff (void); }; #endif
[ [ [ 1, 60 ] ] ]
43814e5d8a3990a68f48ce42773d956894205ff7
77aa13a51685597585abf89b5ad30f9ef4011bde
/dep/src/boost/boost/fusion/sequence/intrinsic/value_at_key.hpp
9add44664a215b51d0f7bced98c6d7c4475ef01b
[ "BSL-1.0" ]
permissive
Zic/Xeon-MMORPG-Emulator
2f195d04bfd0988a9165a52b7a3756c04b3f146c
4473a22e6dd4ec3c9b867d60915841731869a050
refs/heads/master
2021-01-01T16:19:35.213330
2009-05-13T18:12:36
2009-05-14T03:10:17
200,849
8
10
null
null
null
null
UTF-8
C++
false
false
1,755
hpp
/*============================================================================= Copyright (c) 2001-2006 Joel de Guzman Copyright (c) 2006 Dan Marsden Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(FUSION_VALUE_AT_KEY_05052005_0229) #define FUSION_VALUE_AT_KEY_05052005_0229 #include <boost/mpl/int.hpp> #include <boost/fusion/support/tag_of.hpp> namespace boost { namespace fusion { // Special tags: struct sequence_facade_tag; struct array_tag; // boost::array tag struct mpl_sequence_tag; // mpl sequence tag struct std_pair_tag; // std::pair tag namespace extension { template <typename Tag> struct value_at_key_impl { template <typename Sequence, typename Key> struct apply; }; template <> struct value_at_key_impl<sequence_facade_tag> { template <typename Sequence, typename Key> struct apply : Sequence::template value_at_key<Sequence, Key> {}; }; template <> struct value_at_key_impl<array_tag>; template <> struct value_at_key_impl<mpl_sequence_tag>; template <> struct value_at_key_impl<std_pair_tag>; } namespace result_of { template <typename Sequence, typename N> struct value_at_key : extension::value_at_key_impl<typename detail::tag_of<Sequence>::type>:: template apply<Sequence, N> {}; } }} #endif
[ "pepsi1x1@a6a5f009-272a-4b40-a74d-5f9816a51f88" ]
[ [ [ 1, 59 ] ] ]
c4370f355c31e493303713a2d59511a9fd9ba7ff
4aadb120c23f44519fbd5254e56fc91c0eb3772c
/Source/src/EduNetCore/EduNetLog.h
c6da6bec6a8e4047997c19b15d0b07764fc3e77a
[]
no_license
janfietz/edunetgames
d06cfb021d8f24cdcf3848a59cab694fbfd9c0ba
04d787b0afca7c99b0f4c0692002b4abb8eea410
refs/heads/master
2016-09-10T19:24:04.051842
2011-04-17T11:00:09
2011-04-17T11:00:09
33,568,741
0
0
null
null
null
null
UTF-8
C++
false
false
2,939
h
#ifndef __EDUNETLOG_H__ #define __EDUNETLOG_H__ //----------------------------------------------------------------------------- // Copyright (c) 2009, Jan Fietz, Cyrus Preuss // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of EduNetGames nor the names of its contributors // may be used to endorse or promote products derived from this software // without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //----------------------------------------------------------------------------- #include <sstream> //----------------------------------------------------------------------------- namespace EduNet { //------------------------------------------------------------------------- enum ELogType { ELogType_Status, ELogType_Message, ELogType_Warning, ELogType_Error, }; //------------------------------------------------------------------------- class Log { public: static void setLogColor( ELogType eType ); //! print a line on the console static void printLine (const char* message); static void printLine (const std::ostringstream& message); //! print a line on the console static void printMessage (const char* message); static void printMessage (const std::ostringstream& message); //! like printMessage but prefix as warning static void printWarning (const char* message); static void printWarning (const std::ostringstream& message); //! like printMessage but prefix as error static void printError (const char* message); static void printError (const std::ostringstream& message); }; } #endif // __EDUNETLOG_H__
[ "janfietz@localhost" ]
[ [ [ 1, 71 ] ] ]
8db5fbaf04d47682007e928d797d219dfc5b1daf
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/0.8/cpp-object.sourceforge.net/src/cpp_object/arguments/declare_types.test.cpp
8af753e136a6e413edec79107443d3e51008027c
[]
no_license
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
71
cpp
#include <cpp_object/arguments/declare_types.hpp> int main() { }
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
[ [ [ 1, 5 ] ] ]
a1abd9f56767b34c048d974fec7613c1bbd3aec5
f2b4a9d938244916aa4377d4d15e0e2a6f65a345
/gxlib/gxl.ctr.farray.h
7ca4ac6bf0ad120110de0951ce5a8e485217be40
[ "Apache-2.0" ]
permissive
notpushkin/palm-heroes
d4523798c813b6d1f872be2c88282161cb9bee0b
9313ea9a2948526eaed7a4d0c8ed2292a90a4966
refs/heads/master
2021-05-31T19:10:39.270939
2010-07-25T12:25:00
2010-07-25T12:25:00
62,046,865
2
1
null
null
null
null
UTF-8
C++
false
false
27,930
h
/* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef _GXLIB_CONTAINER_FAST_ARRAY_H_ #define _GXLIB_CONTAINER_FAST_ARRAY_H_ #define TEMPLATE template <class T, uint32 SIZ> #define QUAL iFastArray<T,SIZ> #define ASSERTF( a, b ) // The FastArray template implements a generic dynamic array container // It is equivalent in implementation to the DynamicArray except that it // does not properly handles storage of complex data types. // Constructors and destructors NOT called to ensure data integrity at the expence of time // It is used for data types which does not rely on a destructor/copy constructor. template <class T, uint32 SIZ=13> class iFastArray { // Forwards private: struct Chunk; enum { ChunkSizeConst = SIZ }; public: // Forwards class Iterator; class ConstIterator; // Constructor/destructor inline iFastArray(); inline ~iFastArray(); // Take a copy of another list inline iFastArray( const iFastArray& rvalue ); // Append inline iFastArray& operator += ( const iFastArray& rvalue ); // Assigment inline iFastArray& operator = ( const iFastArray& rvalue ); /////////////////////////// // Insertion / removal // Add item to the end of the list inline void Add( T item ); // Add an item ( if it isn't already exists ) inline void AddUnique( T item ); // Remove item from the end. // Returns sentinal if there are no items to remove inline T Remove( T sentinal ); // Push an item at the begining inline void Push( T item ); // Push an item ( if it isn't already exists ) inline void PushUnique( T item ); // Pops an item from the start of the list, does not delete it. // Returns sentinal if none exists inline T Pop( T sentinal ); // Insert node in order ( requires less than op ) inline Iterator Insert( T node ); // Insert node in order if it doesn't already exists inline Iterator InsertUnique( T node ); // Insert node before 'beforeHere' inline Iterator Insert( const Iterator& beforeHere, T node ); // Insert node after 'afterHere' inline Iterator InsertAfter( const Iterator& afterHere, T node ); // Insert node before 'beforeHere' inline Iterator InsertBefore( const Iterator& beforeHere, T node ); // Remove item from the list inline Iterator Remove( const Iterator& it ); // Remove items fit->lit from the list inline void Remove( const Iterator& fit, const Iterator& lit); // Remove item from the list inline Iterator Remove( uint32 n ); // Remove last n items from the list inline void RemoveLast( uint32 n ); // Remove item by iterator inline Iterator RemovePack( const Iterator& it ); // Remove all inline void RemoveAll(); ///////////////////////////// // Access methods // Returns true if there are any valid nodes in the list inline operator bool() const; // Find an item, returns an iterator for it's location template <class K> Iterator Find( const K& item ) { for( Iterator it(First()); it != End(); ++it ) { if ( *it == item ) return it; } return End(); } // Find an item, returns an iterator for it's location template <class K> ConstIterator Find( const K& item ) const { for( ConstIterator it(First()); it != End(); ++it ) { if ( *it == item ) return it; } return End(); } // Find an item and remove it if exists, returns true if found. template <class K> bool FindRemove( const K& item ) { Iterator found( Find( item ) ); if ( found != End() ) { Remove( found ); return true; } return false; } // Return the element at 'index', asserts if out of bounds inline T& operator[] ( uint32 index ); // Return the constant element at 'index' inline const T& operator[] ( uint32 index ) const; //////////////////////////// // Iterator access methods // Returns an iterator for the first element. inline Iterator First(); // Returns an const iterator for the first element. inline ConstIterator First() const; // Returns an iterator for the last element. inline Iterator Last(); // Returns an const iterator for the last element. inline ConstIterator Last() const; // Returns an iterator for the end of the list ( not the last element ) inline Iterator End(); // Returns an const iterator for the end of the list ( not the last element ) inline ConstIterator End() const; // Returns an iterator for the n-th element inline Iterator Index( uint32 n ); // Returns an const iterator for the n-th element inline ConstIterator Index( uint32 n ) const; //////////////////////////// // Information methods: // Return count of active nodes. inline uint32 GetSize() const; // Return true if list empty inline bool IsEmpty() const; // Return the position of this iterator inline uint32 Index( Iterator it ) const; // Return the position of this iterator inline uint32 Index( ConstIterator it ) const; ///////////////////////////// // Misc list only methods: // Swap two elem inline void Swap( Iterator& it1, Iterator& it2 ); // Returns true if node exists in the list inline bool Exists( const Iterator& it ) const; // Reset the list. This method removes all nodes from the list but // does __NOT__ destroy them !!! inline void Reset(); // Sort the list in the increasing order. // This function requires the elements to have the // "less than" operator defined. // Selection sort. inline void Sort(); ////////////////////////// // Non constant iterator class Iterator { public: // Def constructor Iterator() { head = chunk = NULL; node = NULL; } // Construct iterator from the node Iterator( Chunk* aHead, Chunk* aChunk ) { head = aHead; chunk= aChunk; if ( chunk ) node = &chunk->data[0]; else node = NULL; } // Assignment Iterator& operator = ( const Iterator &other ) { head = other.head; chunk = other.chunk; node = other.node; return *this; } // Compare iterator bool operator == ( const Iterator& other ) const { return node == other.node; } // Compare bool operator != ( const Iterator& other ) const { return !operator == ( other ); } // Compare iterator bool operator == ( const ConstIterator& other ) const { return node == other.node; } // Compare bool operator != ( const ConstIterator& other ) const { return !operator == ( other ); } // Compare with another node bool operator == ( const T& otherNode ) const { return (*node) == otherNode; } // Compare bool operator != ( const T& otherNode ) const { return !operator == ( otherNode ); } // Return contents of iterator T& operator * () const { check( node != NULL );//, (TEXT("Can't reference to non-existant node"))); return *node; } // Return contents of iterator T& operator -> () const { check( node != NULL );//, (TEXT("Can't reference to non-existant node"))); return *node; } // Increment by number of nodes Iterator& operator += ( sint32 n ) { while ( n-- ) operator++(); return *this; } // Decrement by number of nodes Iterator& operator -= ( sint32 n ) { while ( n-- ) operator--(); return *this; } // Prefx increment to next Iterator& operator ++ () { if ( node && ++node >= ( &chunk->data[chunk->count] ) ) { chunk = chunk->next; if ( chunk != head ) node = &chunk->data[0]; else node = NULL; } return *this; } // Postfx increment to next Iterator operator ++ ( int ) { Iterator it(*this); operator++(); return it; } // Increment n-th nodes forward Iterator operator + ( sint32 n ) { Iterator it(*this); return it += n; } // Prefx decrement to prev Iterator& operator -- () { if ( node && --node < ( &chunk->data[0] ) ) { if ( chunk == head ) { node = NULL; } else { chunk = chunk->prev; node = &chunk->data[chunk->count-1]; } } return *this; } // Postfx decrement ro prev Iterator operator -- (int) { Iterator it(*this); operator--(); return it; } // Decrement n-th node backwards Iterator operator - ( sint32 n ) { Iterator it(*this); while ( n-- ) --it; return it; } private: // Friends friend class iFastArray<T,SIZ>; friend class ConstIterator; // Private membrs T* node; // Pointer to the current node Chunk* head; Chunk* chunk; // Pointer to the current chunk // Private membrs Iterator( Chunk* aHead, Chunk* aChunk, T* aNode ) { head = aHead; chunk = aChunk; node = aNode; } Iterator( Chunk* aHead, Chunk* aChunk, uint32 n ) { head = aHead; chunk = aChunk; node = &chunk->data[n]; } }; //////////////////////// // A constant iterator class ConstIterator { public: // Def constructor ConstIterator() { head = chunk = NULL; node = NULL; } // Construct from a node ConstIterator( Chunk* aHead, Chunk* aChunk ) { head = aHead; chunk = aChunk; if ( chunk ) node = &chunk->data[0]; else node = NULL; } // Construct ConstIterator from Iterator ConstIterator( const Iterator& it ) { head = it.head; chunk = it.chunk; node = it.node; } // Assignment ConstIterator& operator = ( const Iterator& other ) { head = other.head; chunk = other.chunk; node = other.node; return *this; } // Assignment ConstIterator& operator = ( const ConstIterator& other ) { head = other.head; chunk = other.chunk; node = other.node; return *this; } // Compare existing iterator bool operator == ( const Iterator& other ) const { return node == other.node; } // Compare bool operator != ( const Iterator& other ) const { return ! (operator == ( other )); } // Compare bool operator == ( const ConstIterator& other ) const { return node == other.node; } // Compare bool operator != ( const ConstIterator& other ) const { return ! (operator == ( other )); } // Compare with another node bool operator == ( const T& otherNode ) const { return (*node) == otherNode; } // Compare bool operator != ( const T& otherNode ) const { return !( operator == ( otherNode )); } // Return content const T& operator * () const { check( node != NULL );//, (TEXT("Can't reference non-existant node"))); return *node; } // Return content const T& operator -> () const { check( node != NULL );//, (TEXT("Can't reference non-existant node"))); return *node; } // Increment by number nodes ConstIterator& operator += ( sint32 n ) { while (n--) operator++(); return *this; } // Decrement by number nodes ConstIterator& operator -= ( sint32 n ) { while (n--) operator--(); return *this; } // Prefx increment to next ConstIterator& operator ++ () { if ( node && ++node >= ( &chunk->data[chunk->count] )) { chunk = chunk->next; if ( chunk != head ) node = &chunk->data[0]; else node = NULL; } return *this; } // Postfix increment to next ConstIterator operator ++ ( int ) { ConstIterator it(*this); operator++(); return it; } // Increment n nodes forwards ConstIterator operator + ( sint32 n ) { ConstIterator it(*this); return it += n; } // Prefx decrement to prev ConstIterator& operator -- () { if ( node && --node < ( &chunk->data[0] ) ) { if ( chunk == head ) { node = NULL; } else { chunk = chunk->prev; node = &chunk->data[chunk->count-1]; } } return *this; } // Postfx decrement to prev ConstIterator operator -- (int) { ConstIterator it(*this); operator--(); return it; } // Decrement n node backwards ConstIterator operator - ( sint32 n ) { ConstIterator it(*this); while( n-- ) --it; return it; } private: // Friends friend class iFastArray<T,SIZ>; friend class Iterator; // Private membrs const T* node; Chunk* head; Chunk* chunk; // Private membrs ConstIterator( Chunk* aHead, Chunk* aChunk, const T* aNode ) { node = aNode; head = aHead; chunk = aChunk; } ConstIterator( Chunk* aHead, Chunk* aChunk, uint32 n ) { head = aHead; chunk = aChunk; node = &chunk->data[n]; } }; private: // Header of chunk struct Chunk { Chunk* next; // Next chunk Chunk* prev; // Previous chunk uint32 count; // Number of elements in chunk T data[SIZ]; // Array of data Chunk() { count = 0; } }; /////////////////////// // Private membrs Chunk* head; }; ///////////////////////////////////////////////////////////////////// // Inlines // DynamicArray // Constructors TEMPLATE QUAL::iFastArray() { Reset(); } // ~DynamicArray // Dtor TEMPLATE QUAL::~iFastArray() { RemoveAll(); } // DynamicArray // Take a copy TEMPLATE QUAL::iFastArray( const iFastArray& rvalue ) { Reset(); operator += ( rvalue ); } // operator =: // Assignment TEMPLATE QUAL& QUAL::operator = ( const iFastArray& rvalue ) { if ( this ==&rvalue ) { return *this; } RemoveAll(); operator += ( rvalue ); return *this; } // operator += // Append TEMPLATE QUAL& QUAL::operator += ( const iFastArray& rvalue ) { // nothing to copy ? if ( !rvalue.head ) return *this; Chunk* last; Chunk* curr = rvalue.head; if ( head ) { last = head->prev; } else { // make first chunk for this list last = head = new Chunk(); head->prev = head; head->next = head; // Copy elements memcpy( &head->count, &curr->count, curr->count*sizeof(T)+sizeof(uint32)); // next node curr = curr->next; if ( curr == rvalue.head ) return *this; } do { Chunk* newChunk = new Chunk(); // Copy elements memcpy( &newChunk->count, &curr->count, curr->count*sizeof(T)+sizeof(uint32)); // link it newChunk->next = head; newChunk->prev = last; head->prev = newChunk; head->next = newChunk; last = newChunk; curr = curr->next; } while ( curr != rvalue.head ); return *this; } ///////////////////////////////// // Insertion / removal TEMPLATE void QUAL::Add( T item ) { // pointer to last node Chunk* tail; // if no nodes, add a new chunk to the end if ( !head ) { // create a first chunk tail = head = new Chunk(); head->prev = head; tail->next = tail; } else { // end node tail = head->prev; if ( tail->count == SIZ ) { // add a new chunk after tail Chunk* newEnd = new Chunk(); newEnd->next = head; newEnd->prev = tail; head->prev = newEnd; tail->next = newEnd; tail = newEnd; } } // put the data in the chunk tail->data[tail->count++] = item; } // AddUnique // TEMPLATE void QUAL::AddUnique( T item ) { if ( Find( item ) == End() ) Add( item ); } // Remove // Remove an item from the end TEMPLATE T QUAL::Remove( T sentinal ) { Chunk* c; // abort if no elems if ( !head ) return sentinal; // last chunk c = head->prev; // take a copy of last elem T v = c->data[ --c->count ]; if ( !c->count ) { if ( c == head ) { delete c; head = NULL; } else { Chunk* p = c->prev; p->next = head; head->prev = p; delete c; } } return v; } // Push: // TEMPLATE void QUAL::Push( T item ) { // if empty, add a new chunk to the end if ( !head ) { head = new Chunk(); head->next = head; head->prev = head; } else { // check for size if ( head->count == SIZ ) { // add a new chunk Chunk* newFirst = new Chunk(); newFirst->next = head; newFirst->prev = head->prev; head->prev->next = newFirst; head->prev = newFirst; head = newFirst; } else { // make a room // note: there will always be at least one node memmove( &head->data[1], &head->data[0], head->count*sizeof(T) ); } } // increment number of nodes in the chunk head->count++; // call copy ctor head->data[0] = item; } // PushUnique: // TEMPLATE void QUAL::PushUnique( T item ) { if ( Find( item ) == End() ) Push( item ); } // Pop: // TEMPLATE T QUAL::Pop( T sentinal ) { Iterator first( First() ); if ( first == End() ) return sentinal; T data = (*first); Remove( first ); return data; } // Insert: // TEMPLATE typename QUAL::Iterator QUAL::Insert( T node ) { if ( !head ) { Add( node ); return First(); } Iterator it( First() ); while ( it != End() && *it < node ) ++it; if ( it == End() ) { Add( node ); return Last(); } return InsertBefore( it, node ); } // InsertUnique: // TEMPLATE typename QUAL::Iterator QUAL::InsertUnique( T node ) { if ( !head ) { Add( node ); return First(); } Iterator it( First() ); while ( it != End() && *it < node ) ++it; if ( it == End() ) { Add( node ); return Last(); } else if ( *it > node ) return InsertBefore( it, node ); return End(); } // Insert: // TEMPLATE typename QUAL::Iterator QUAL::Insert( const Iterator& beforeHere, T item ) { return InsertBefore( beforeHere, item ); } // InsertAfter: // TEMPLATE typename QUAL::Iterator QUAL::InsertAfter( const Iterator& afterHere, T item ) { Iterator temp( afterHere ); return InsertBefore( ++temp, item ); } // InsertBefore: // TEMPLATE typename QUAL::Iterator QUAL::InsertBefore( const Iterator& beforeHere, T item ) { // if inserting before End() it means same as add if ( beforeHere == End() ) { Add( item ); return Last(); } // if inserting before First, it sames as push if ( beforeHere == First() ) { Push( item ); return First(); } // copy chunk ptr Chunk* c = beforeHere.chunk; // figure out which index we need to insert before uint32 index = beforeHere.node - (&c->data[0]); // inserting before the start of chunk ? if ( index == 0 && c->count == SIZ ) { // insert at the end of the previous chunk // or insert a new chunk between this and previous for // a new node.. Chunk* prev = c->prev; // is prev full ? if ( prev->count == SIZ || prev == head ) { // create a new chunk and insert it Chunk* newChunk = new Chunk(); // insert new chunk before 'c' newChunk->next = c; newChunk->prev = c->prev; c->prev->next = newChunk; c->prev = newChunk; prev = newChunk; } // add the new node at the end of the prev chunk // use a copy ctor to insert elem prev->data[prev->count++] = item; // return iterator to newly inserted node return Iterator( head, prev, &prev->data[ prev->count-1 ] ); } // will it fit in this chunk ? if ( c->count == SIZ ) { // handle a full chunk lets split it into two chunks Chunk* nextChunk = new Chunk(); // insert new chunk after 'c' nextChunk->prev = c; nextChunk->next = c->next; c->next->prev = nextChunk; c->next = nextChunk; // move last half into first half of next chunk memmove(&nextChunk->data[0], &c->data[SIZ/2], (SIZ-SIZ/2)*sizeof(T) ); // adjust counts c->count = SIZ/2; nextChunk->count = (SIZ-SIZ/2); // move next chunk to next block if index in 2nd half if ( index > SIZ/2 ) { c = nextChunk; index -= SIZ / 2; } } // there is room in this chunk memmove( &c->data[index+1], &c->data[index], (c->count-index)*sizeof(T) ); // add the new node c->data[index] = item; c->count++; // return iterator return Iterator( head, c, &c->data[index] ); } TEMPLATE void QUAL::Remove( const Iterator& fit, const Iterator& lit) { int dist = Index( lit ) - Index( fit ); Iterator it = fit; while( dist-- ) { it = Remove( it ); } } // Remove: // TEMPLATE typename QUAL::Iterator QUAL::Remove( const Iterator& it ) { if ( !head || it == End() ) return it; Chunk* c = it.chunk; T* node = it.node; // if not removing the last T* last = &c->data[c->count - 1]; if ( node < last ) { // fill da gap memmove(node,node+1,(last - node) * sizeof(T)); } // last one ? if ( c->count == 1 ) { if ( c == head ) { if ( c->next == head ) { // only chunk left delete c; head = NULL; node = NULL; c = NULL; } else { // remove chunk c->prev->next = c->next; c->next->prev = c->prev; Chunk* t = c; c = c->next; delete t; node = &c->data[0]; head = c; } } else { // remove the chunk c->prev->next = c->next; c->next->prev = c->prev; Chunk* t = c; c = c->next; delete t; node = ( c == head ) ? NULL : &c->data[0]; } } else { c->count --; if ( node == last ) { c = c->next; node = ( c == head ) ? NULL : &c->data[0]; } } return Iterator( head, c, node ); } // Remove: // TEMPLATE typename QUAL::Iterator QUAL::Remove( uint32 n ) { Iterator it = First(); it += n; return Remove( it ); } // RemoveLast: // remove last 'n' items TEMPLATE void QUAL::RemoveLast( uint32 n ) { if ( head ) { Chunk* last = head->prev; while ( last != head && last->count <= n ) { // count off n -= last->count; // walk last = last->prev; } if ( n > SIZ ) { RemoveAll(); return; } else if ( n ) { // trim last->count -= n; } // remove all chunks following this one Chunk* curr = last->next; while ( curr != head ) { Chunk* next = curr->next; delete curr; curr = next; } last->next = head; head->prev = last; } } // RemovePack: // Remove the item specified by iterator and fill it's position with // random node elsewhere in the list TEMPLATE typename QUAL::Iterator QUAL::RemovePack( const Iterator& it ) { Chunk* c = it.chunk; if ( !head || it == End() ) return it; if ( c->count == 1 ) { if ( head == c ) { if ( c->next == head ) { delete head; head = NULL; return End(); } else { Iterator n( head, c->next ); // unlink head = c->next; c->prev->next = c->next; c->next->prev = c->prev; delete c; return n; } } Iterator n( head, c->next ); // unlink c->prev->next = c->next; c->next->prev = c->prev; delete c; return n; } else { T* node = it.node; // decr number of nodes c->count --; // if node not the last in the chunk if ( node != &c->data[ c->count ] ) { // move last element to old node *node = &c->data[ c->count ]; // Return the same iterator ( new data ) return it; } else { // return first element return Iterator( head, c->next ); } } } // RemoveAll: // TEMPLATE void QUAL::RemoveAll() { if ( head ) { Chunk* first = head->next; while ( first != head ) { Chunk* next = first->next; delete first; first = next; } delete first; head = NULL; } } ///////////////////// // Access // operator Bool() // TEMPLATE QUAL::operator bool() const { return head ? true : false; } // Index: // Return the iterator at the index'th item ( of End() ) TEMPLATE typename QUAL::Iterator QUAL::Index( uint32 index ) { if ( index >= Count() ) return End(); return First() + index; } // Index: // TEMPLATE typename QUAL::ConstIterator QUAL::Index( uint32 index ) const { if ( index >= Count() ) return End(); return First() + index; } // operator [] // return the elem at index, asserts if out of bounds TEMPLATE T& QUAL::operator[] ( uint32 index ) { check( index < GetSize() ); //, ("Out of bounds, index=%u", index)); return *(First() + index); } // operator[] // TEMPLATE const T& QUAL::operator[] ( uint32 index ) const { check( index < GetSize() );//, ("Out of bounds, index=%u", index)); const T& ret = *(First() + index); return ret; } // First: // return iterator to the first element TEMPLATE typename QUAL::Iterator QUAL::First() { return Iterator( head, head ); } // First: // TEMPLATE typename QUAL::ConstIterator QUAL::First() const { return ConstIterator( head, head ); } // Last: // return iterator to the last element TEMPLATE typename QUAL::Iterator QUAL::Last() { if ( head ) return Iterator( head, head->prev, &(head->prev->data[head->prev->count - 1 ])); return End(); } // Last: // TEMPLATE typename QUAL::ConstIterator QUAL::Last() const { if ( head ) return ConstIterator( head, head->prev, &(head->prev->data[head->prev->count - 1 ])); return End(); } // End: // return the end of the list ( not the last element ) TEMPLATE typename QUAL::Iterator QUAL::End() { return Iterator( NULL, NULL ); } // End: // TEMPLATE typename QUAL::ConstIterator QUAL::End() const { return ConstIterator( NULL, NULL ); } ///////////////////////////// // Information methods // Count: // count of active nodes TEMPLATE uint32 QUAL::GetSize() const { uint32 count = 0; Chunk* c = head; if ( c ) { do { count += c->count; c = c->next; } while ( c != head ); } return count; } // IsEmpty // TEMPLATE bool QUAL::IsEmpty() const { return head == NULL; } // Index // Returns the position of iterator TEMPLATE uint32 QUAL::Index( Iterator it ) const { return Index( ConstIterator( it ) ); } // Index // TEMPLATE uint32 QUAL::Index( ConstIterator it ) const { uint32 count = 0; for( ConstIterator j( First() ); j != it; ++j, ++count ); return count; } ///////////////////////// // Misc list only mtds // Exists // Returns true if node exists TEMPLATE bool QUAL::Exists( const Iterator& node ) const { check( false )//, ("Exists(iterator) not implemented")); return false; } // Reset // TEMPLATE void QUAL::Reset() { head = NULL; } // Swap // Swap two elements TEMPLATE void QUAL::Swap( Iterator& it1, Iterator& it2 ) { check( false );//, ("Swap( Iterator, Iterator) not implemented")); } ///////////////////////////// // Utility methods // Sort: // TEMPLATE void QUAL::Sort() { sint32 n = (sint32)Count(); for( sint32 i = 0; i < n; i++ ) { // Find smallest index sint32 min = i; for( uint32 j = i + 1; j < n; j++ ) if ( operator[](j) < operator[](min) ) min = j; // Swap if ( i != min ) { T tmp = operator [](i); operator [](i) = operator [](min); operator [](min)= tmp; } } } #undef QUAL #undef TEMPLATE #endif //_GXLIB_CONTAINER_FAST_ARRAY_H_
[ "palmheroesteam@2c21ad19-eed7-4c86-9350-8a7669309276" ]
[ [ [ 1, 1374 ] ] ]
3d0175c19229ef86e03020a2b6767952017d9903
7b379862f58f587d9327db829ae4c6493b745bb1
/JuceLibraryCode/modules/juce_gui_basics/windows/juce_ResizableWindow.h
3b082d9d1749c2637bb33c076125d9c7db01b262
[]
no_license
owenvallis/Nomestate
75e844e8ab68933d481640c12019f0d734c62065
7fe7c06c2893421a3c77b5180e5f27ab61dd0ffd
refs/heads/master
2021-01-19T07:35:14.301832
2011-12-28T07:42:50
2011-12-28T07:42:50
2,950,072
2
0
null
null
null
null
UTF-8
C++
false
false
17,205
h
/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ #ifndef __JUCE_RESIZABLEWINDOW_JUCEHEADER__ #define __JUCE_RESIZABLEWINDOW_JUCEHEADER__ #include "juce_TopLevelWindow.h" #include "../mouse/juce_ComponentDragger.h" #include "../layout/juce_ResizableBorderComponent.h" #include "../layout/juce_ResizableCornerComponent.h" //============================================================================== /** A base class for top-level windows that can be dragged around and resized. To add content to the window, use its setContentOwned() or setContentNonOwned() methods to give it a component that will remain positioned inside it (leaving a gap around the edges for a border). It's not advisable to add child components directly to a ResizableWindow: put them inside your content component instead. And overriding methods like resized(), moved(), etc is also not recommended - instead override these methods for your content component. (If for some obscure reason you do need to override these methods, always remember to call the super-class's resized() method too, otherwise it'll fail to lay out the window decorations correctly). By default resizing isn't enabled - use the setResizable() method to enable it and to choose the style of resizing to use. @see TopLevelWindow */ class JUCE_API ResizableWindow : public TopLevelWindow { public: //============================================================================== /** Creates a ResizableWindow. This constructor doesn't specify a background colour, so the LookAndFeel's default background colour will be used. @param name the name to give the component @param addToDesktop if true, the window will be automatically added to the desktop; if false, you can use it as a child component */ ResizableWindow (const String& name, bool addToDesktop); /** Creates a ResizableWindow. @param name the name to give the component @param backgroundColour the colour to use for filling the window's background. @param addToDesktop if true, the window will be automatically added to the desktop; if false, you can use it as a child component */ ResizableWindow (const String& name, const Colour& backgroundColour, bool addToDesktop); /** Destructor. If a content component has been set with setContentOwned(), it will be deleted. */ ~ResizableWindow(); //============================================================================== /** Returns the colour currently being used for the window's background. As a convenience the window will fill itself with this colour, but you can override the paint() method if you need more customised behaviour. This method is the same as retrieving the colour for ResizableWindow::backgroundColourId. @see setBackgroundColour */ const Colour getBackgroundColour() const noexcept; /** Changes the colour currently being used for the window's background. As a convenience the window will fill itself with this colour, but you can override the paint() method if you need more customised behaviour. Note that the opaque state of this window is altered by this call to reflect the opacity of the colour passed-in. On window systems which can't support semi-transparent windows this might cause problems, (though it's unlikely you'll be using this class as a base for a semi-transparent component anyway). You can also use the ResizableWindow::backgroundColourId colour id to set this colour. @see getBackgroundColour */ void setBackgroundColour (const Colour& newColour); //============================================================================== /** Make the window resizable or fixed. @param shouldBeResizable whether it's resizable at all @param useBottomRightCornerResizer if true, it'll add a ResizableCornerComponent at the bottom-right; if false, it'll use a ResizableBorderComponent around the edge @see setResizeLimits, isResizable */ void setResizable (bool shouldBeResizable, bool useBottomRightCornerResizer); /** True if resizing is enabled. @see setResizable */ bool isResizable() const noexcept; /** This sets the maximum and minimum sizes for the window. If the window's current size is outside these limits, it will be resized to make sure it's within them. Calling setBounds() on the component will bypass any size checking - it's only when the window is being resized by the user that these values are enforced. @see setResizable, setFixedAspectRatio */ void setResizeLimits (int newMinimumWidth, int newMinimumHeight, int newMaximumWidth, int newMaximumHeight) noexcept; /** Returns the bounds constrainer object that this window is using. You can access this to change its properties. */ ComponentBoundsConstrainer* getConstrainer() noexcept { return constrainer; } /** Sets the bounds-constrainer object to use for resizing and dragging this window. A pointer to the object you pass in will be kept, but it won't be deleted by this object, so it's the caller's responsiblity to manage it. If you pass 0, then no contraints will be placed on the positioning of the window. */ void setConstrainer (ComponentBoundsConstrainer* newConstrainer); /** Calls the window's setBounds method, after first checking these bounds with the current constrainer. @see setConstrainer */ void setBoundsConstrained (const Rectangle<int>& bounds); //============================================================================== /** Returns true if the window is currently in full-screen mode. @see setFullScreen */ bool isFullScreen() const; /** Puts the window into full-screen mode, or restores it to its normal size. If true, the window will become full-screen; if false, it will return to the last size it was before being made full-screen. @see isFullScreen */ void setFullScreen (bool shouldBeFullScreen); /** Returns true if the window is currently minimised. @see setMinimised */ bool isMinimised() const; /** Minimises the window, or restores it to its previous position and size. When being un-minimised, it'll return to the last position and size it was in before being minimised. @see isMinimised */ void setMinimised (bool shouldMinimise); /** Adds the window to the desktop using the default flags. */ void addToDesktop(); //============================================================================== /** Returns a string which encodes the window's current size and position. This string will encapsulate the window's size, position, and whether it's in full-screen mode. It's intended for letting your application save and restore a window's position. Use the restoreWindowStateFromString() to restore from a saved state. @see restoreWindowStateFromString */ String getWindowStateAsString(); /** Restores the window to a previously-saved size and position. This restores the window's size, positon and full-screen status from an string that was previously created with the getWindowStateAsString() method. @returns false if the string wasn't a valid window state @see getWindowStateAsString */ bool restoreWindowStateFromString (const String& previousState); //============================================================================== /** Returns the current content component. This will be the component set by setContentOwned() or setContentNonOwned, or 0 if none has yet been specified. @see setContentOwned, setContentNonOwned */ Component* getContentComponent() const noexcept { return contentComponent; } /** Changes the current content component. This sets a component that will be placed in the centre of the ResizableWindow, (leaving a space around the edge for the border). You should never add components directly to a ResizableWindow (or any of its subclasses) with addChildComponent(). Instead, add them to the content component. @param newContentComponent the new component to use - this component will be deleted when it's no longer needed (i.e. when the window is deleted or a new content component is set for it). To set a component that this window will not delete, call setContentNonOwned() instead. @param resizeToFitWhenContentChangesSize if true, then the ResizableWindow will maintain its size such that it always fits around the size of the content component. If false, the new content will be resized to fit the current space available. */ void setContentOwned (Component* newContentComponent, bool resizeToFitWhenContentChangesSize); /** Changes the current content component. This sets a component that will be placed in the centre of the ResizableWindow, (leaving a space around the edge for the border). You should never add components directly to a ResizableWindow (or any of its subclasses) with addChildComponent(). Instead, add them to the content component. @param newContentComponent the new component to use - this component will NOT be deleted by this component, so it's the caller's responsibility to manage its lifetime (it's ok to delete it while this window is still using it). To set a content component that the window will delete, call setContentOwned() instead. @param resizeToFitWhenContentChangesSize if true, then the ResizableWindow will maintain its size such that it always fits around the size of the content component. If false, the new content will be resized to fit the current space available. */ void setContentNonOwned (Component* newContentComponent, bool resizeToFitWhenContentChangesSize); /** Removes the current content component. If the previous content component was added with setContentOwned(), it will also be deleted. If it was added with setContentNonOwned(), it will simply be removed from this component. */ void clearContentComponent(); /** Changes the window so that the content component ends up with the specified size. This is basically a setSize call on the window, but which adds on the borders, so you can specify the content component's target size. */ void setContentComponentSize (int width, int height); /** Returns the width of the frame to use around the window. @see getContentComponentBorder */ virtual const BorderSize<int> getBorderThickness(); /** Returns the insets to use when positioning the content component. @see getBorderThickness */ virtual const BorderSize<int> getContentComponentBorder(); //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the window. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour */ enum ColourIds { backgroundColourId = 0x1005700, /**< A colour to use to fill the window's background. */ }; //============================================================================== /** @deprecated - use setContentOwned() and setContentNonOwned() instead. */ JUCE_DEPRECATED (void setContentComponent (Component* newContentComponent, bool deleteOldOne = true, bool resizeToFit = false)); protected: //============================================================================== /** @internal */ void paint (Graphics& g); /** (if overriding this, make sure you call ResizableWindow::resized() in your subclass) */ void moved(); /** (if overriding this, make sure you call ResizableWindow::resized() in your subclass) */ void resized(); /** @internal */ void mouseDown (const MouseEvent& e); /** @internal */ void mouseDrag (const MouseEvent& e); /** @internal */ void lookAndFeelChanged(); /** @internal */ void childBoundsChanged (Component* child); /** @internal */ void parentSizeChanged(); /** @internal */ void visibilityChanged(); /** @internal */ void activeWindowStatusChanged(); /** @internal */ int getDesktopWindowStyleFlags() const; #if JUCE_DEBUG /** Overridden to warn people about adding components directly to this component instead of using setContentOwned(). If you know what you're doing and are sure you really want to add a component, specify a base-class method call to Component::addAndMakeVisible(), to side-step this warning. */ void addChildComponent (Component* child, int zOrder = -1); /** Overridden to warn people about adding components directly to this component instead of using setContentOwned(). If you know what you're doing and are sure you really want to add a component, specify a base-class method call to Component::addAndMakeVisible(), to side-step this warning. */ void addAndMakeVisible (Component* child, int zOrder = -1); #endif ScopedPointer <ResizableCornerComponent> resizableCorner; ScopedPointer <ResizableBorderComponent> resizableBorder; private: //============================================================================== Component::SafePointer <Component> contentComponent; bool ownsContentComponent, resizeToFitContent, fullscreen; ComponentDragger dragger; Rectangle<int> lastNonFullScreenPos; ComponentBoundsConstrainer defaultConstrainer; ComponentBoundsConstrainer* constrainer; #if JUCE_DEBUG bool hasBeenResized; #endif void initialise (bool addToDesktop); void updateLastPos(); void setContent (Component*, bool takeOwnership, bool resizeToFit); #if JUCE_CATCH_DEPRECATED_CODE_MISUSE // The parameters for these methods have changed - please update your code! JUCE_DEPRECATED (void getBorderThickness (int& left, int& top, int& right, int& bottom)); JUCE_DEPRECATED (void getContentComponentBorder (int& left, int& top, int& right, int& bottom)); #endif JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ResizableWindow); }; #endif // __JUCE_RESIZABLEWINDOW_JUCEHEADER__
[ "ow3nskip" ]
[ [ [ 1, 392 ] ] ]
879939844c2046d5fa52b80e8bbf77a686f58422
718dc2ad71e8b39471b5bf0c6d60cbe5f5c183e1
/soft micros/Codigo/codigo portable/Aparatos/Vista/VistaAlarmas.cpp
01123f5c55bd3f24787b7346021c9bf346875844
[]
no_license
jonyMarino/microsdhacel
affb7a6b0ea1f4fd96d79a04d1a3ec3eaa917bca
66d03c6a9d3a2d22b4d7104e2a38a2c9bb4061d3
refs/heads/master
2020-05-18T19:53:51.301695
2011-05-30T20:40:24
2011-05-30T20:40:24
34,532,512
0
0
null
null
null
null
UTF-8
C++
false
false
3,493
cpp
#include "propiedadesAlarma.hpp" #include "BoxLineal.hpp" #include "BoxSaltoCondicional.hpp" #include "BoxPropiedadEntradaCondicional.hpp" #include "BoxLinealCondicional.hpp" #include "VistaAlarmas.hpp" #include "CoordinadorLazosAlCntrRet.hpp" /***********************/ /****** BOXES *********/ bool getCondicionEntradaAl (void* alarma){ if(((CoordinadorLazosAlCntrRet*)alarma)->getLazo() != RETRANSMISION) return TRUE; else return FALSE; } bool getCondicionEntradaAlret (void* alarma){ if(((CoordinadorLazosAlCntrRet*)alarma)->getLazo() == RETRANSMISION) return TRUE; else return FALSE; } const struct ConstructorBoxPropiedadEntradaCondicional cBoxesAlarma ={ &boxPropiedadEntradaCondicionalFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadModoAlarma, getCondicionEntradaAl }; const struct ConstructorBoxPropiedadEntradaCondicional cBoxesAlarmaCtrl ={ &boxPropiedadEntradaCondicionalFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadTipoCtrlAlarma, getCondicionEntradaAl }; /*const struct ConstructorPropGetterVisual*const propsConfiguracion[]= { (const struct ConstructorPropGetterVisual*)&cPropiedadModoAlarma, (const struct ConstructorPropGetterVisual*)&cPropiedadTipoCtrlAlarma, NULL }; const struct ConstructorBoxLineal cBoxesAlarma={ &boxLinealFactory, propsConfiguracion, NULL, //Proximo box }; */ const struct ConstructorBoxPropiedadEntradaCondicional cBoxesRetLimInf ={ &boxPropiedadEntradaCondicionalFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadRetLimInf, getCondicionEntradaAlret }; const struct ConstructorBoxPropiedadEntradaCondicional cBoxesRetLimSup ={ &boxPropiedadEntradaCondicionalFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadRetLimSup, getCondicionEntradaAlret }; /*const struct ConstructorPropGetterVisual*const propsRet[]= { (const struct ConstructorPropGetterVisual*)&cPropiedadRetLimInf, (const struct ConstructorPropGetterVisual*)&cPropiedadRetLimSup, }; const struct ConstructorBoxLineal cBoxesRetransmision={ &boxLinealFactory, propsRet, NULL, };*/ const struct ConstructorBoxPropiedadEntradaCondicional cBoxesHistAlarma ={ &boxPropiedadEntradaCondicionalFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadHistAlarma, getCondicionEntradaAl }; /*const struct ConstructorBoxPropiedad cBoxesHistAlarma={ &boxPropiedadFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadHistAlarma, };*/ const struct ConstructorBoxPropiedad cBoxesTipoSalAlarma={ &boxPropiedadFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadTipoSalida }; const struct ConstructorBoxPropiedad cBoxesTipoLazo={ &boxPropiedadFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadTipoLazo }; const struct ConstructorBoxPropiedadEntradaCondicional cBoxesSetPointAlarma ={ &boxPropiedadEntradaCondicionalFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadSetPointAlarma, getCondicionEntradaAl }; /*const struct ConstructorBoxPropiedad cBoxesSetPointAlarma={ &boxPropiedadFactory, (const struct ConstructorPropGetterVisual*)&cPropiedadSetPointAlarma, }; */
[ "jonymarino@9fc3b3b2-dce3-11dd-9b7c-b771bf68b549", "nicopimen@9fc3b3b2-dce3-11dd-9b7c-b771bf68b549" ]
[ [ [ 1, 1 ], [ 7, 7 ] ], [ [ 2, 6 ], [ 8, 117 ] ] ]
815cbdfddbde407dbce95a8a5ee495c0958c27de
3c22e8879c8060942ad1ba4a28835d7963e10bce
/trunk/scintilla/src/Editor.cxx
1b5346a7187d130831678bef6c58930be9b9eeb8
[ "LicenseRef-scancode-scintilla" ]
permissive
svn2github/NotepadPlusPlus
b17f159f9fe6d8d650969b0555824d259d775d45
35b5304f02aaacfc156269c4b894159de53222ef
refs/heads/master
2021-01-22T09:05:19.267064
2011-01-31T01:46:36
2011-01-31T01:46:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
278,645
cxx
// Scintilla source code edit control /** @file Editor.cxx ** Main code for the edit control. **/ // Copyright 1998-2004 by Neil Hodgson <[email protected]> // The License.txt file describes the conditions under which this software may be distributed. #include <stdlib.h> #include <string.h> #include <stdio.h> #include <ctype.h> #include <assert.h> #include <string> #include <vector> #include <algorithm> #include <memory> // With Borland C++ 5.5, including <string> includes Windows.h leading to defining // FindText to FindTextA which makes calls here to Document::FindText fail. #ifdef __BORLANDC__ #ifdef FindText #undef FindText #endif #endif #include "Platform.h" #include "ILexer.h" #include "Scintilla.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" #include "ContractionState.h" #include "CellBuffer.h" #include "KeyMap.h" #include "Indicator.h" #include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" #include "CharClassify.h" #include "Decoration.h" #include "Document.h" #include "Selection.h" #include "PositionCache.h" #include "Editor.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif /* return whether this modification represents an operation that may reasonably be deferred (not done now OR [possibly] at all) */ static bool CanDeferToLastStep(const DocModification &mh) { if (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) return true; // CAN skip if (!(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO))) return false; // MUST do if (mh.modificationType & SC_MULTISTEPUNDOREDO) return true; // CAN skip return false; // PRESUMABLY must do } static bool CanEliminate(const DocModification &mh) { return (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) != 0; } /* return whether this modification represents the FINAL step in a [possibly lengthy] multi-step Undo/Redo sequence */ static bool IsLastStep(const DocModification &mh) { return (mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)) != 0 && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0 && (mh.modificationType & SC_LASTSTEPINUNDOREDO) != 0 && (mh.modificationType & SC_MULTILINEUNDOREDO) != 0; } Caret::Caret() : active(false), on(false), period(500) {} Timer::Timer() : ticking(false), ticksToWait(0), tickerID(0) {} Idler::Idler() : state(false), idlerID(0) {} static inline bool IsControlCharacter(int ch) { // iscntrl returns true for lots of chars > 127 which are displayable return ch >= 0 && ch < ' '; } static inline bool IsAllSpacesOrTabs(char *s, unsigned int len) { for (unsigned int i = 0; i < len; i++) { // This is safe because IsSpaceOrTab() will return false for null terminators if (!IsSpaceOrTab(s[i])) return false; } return true; } Editor::Editor() { ctrlID = 0; stylesValid = false; printMagnification = 0; printColourMode = SC_PRINT_NORMAL; printWrapState = eWrapWord; cursorMode = SC_CURSORNORMAL; controlCharSymbol = 0; /* Draw the control characters */ hasFocus = false; hideSelection = false; inOverstrike = false; errorStatus = 0; mouseDownCaptures = true; bufferedDraw = true; twoPhaseDraw = true; lastClickTime = 0; dwellDelay = SC_TIME_FOREVER; ticksToDwell = SC_TIME_FOREVER; dwelling = false; ptMouseLast.x = 0; ptMouseLast.y = 0; inDragDrop = ddNone; dropWentOutside = false; posDrag = SelectionPosition(invalidPosition); posDrop = SelectionPosition(invalidPosition); selectionType = selChar; lastXChosen = 0; lineAnchor = 0; originalAnchorPos = 0; primarySelection = true; caretXPolicy = CARET_SLOP | CARET_EVEN; caretXSlop = 50; caretYPolicy = CARET_EVEN; caretYSlop = 0; searchAnchor = 0; xOffset = 0; xCaretMargin = 50; horizontalScrollBarVisible = true; scrollWidth = 2000; trackLineWidth = false; lineWidthMaxSeen = 0; verticalScrollBarVisible = true; endAtLastLine = true; caretSticky = SC_CARETSTICKY_OFF; multipleSelection = false; additionalSelectionTyping = false; multiPasteMode = SC_MULTIPASTE_ONCE; additionalCaretsBlink = true; additionalCaretsVisible = true; virtualSpaceOptions = SCVS_NONE; pixmapLine = Surface::Allocate(); pixmapSelMargin = Surface::Allocate(); pixmapSelPattern = Surface::Allocate(); pixmapIndentGuide = Surface::Allocate(); pixmapIndentGuideHighlight = Surface::Allocate(); targetStart = 0; targetEnd = 0; searchFlags = 0; topLine = 0; posTopLine = 0; lengthForEncode = -1; needUpdateUI = true; braces[0] = invalidPosition; braces[1] = invalidPosition; bracesMatchStyle = STYLE_BRACEBAD; highlightGuideColumn = 0; theEdge = 0; paintState = notPainting; modEventMask = SC_MODEVENTMASKALL; pdoc = new Document(); pdoc->AddRef(); pdoc->AddWatcher(this, 0); recordingMacro = false; foldFlags = 0; wrapState = eWrapNone; wrapWidth = LineLayout::wrapWidthInfinite; wrapStart = wrapLineLarge; wrapEnd = wrapLineLarge; wrapVisualFlags = 0; wrapVisualFlagsLocation = 0; wrapVisualStartIndent = 0; wrapIndentMode = SC_WRAPINDENT_FIXED; wrapAddIndent = 0; convertPastes = true; hsStart = -1; hsEnd = -1; llc.SetLevel(LineLayoutCache::llcCaret); posCache.SetSize(0x400); } Editor::~Editor() { pdoc->RemoveWatcher(this, 0); pdoc->Release(); pdoc = 0; DropGraphics(); delete pixmapLine; delete pixmapSelMargin; delete pixmapSelPattern; delete pixmapIndentGuide; delete pixmapIndentGuideHighlight; } void Editor::Finalise() { SetIdle(false); CancelModes(); } void Editor::DropGraphics() { pixmapLine->Release(); pixmapSelMargin->Release(); pixmapSelPattern->Release(); pixmapIndentGuide->Release(); pixmapIndentGuideHighlight->Release(); } void Editor::InvalidateStyleData() { stylesValid = false; DropGraphics(); palette.Release(); llc.Invalidate(LineLayout::llInvalid); posCache.Clear(); } void Editor::InvalidateStyleRedraw() { NeedWrapping(); InvalidateStyleData(); Redraw(); } void Editor::RefreshColourPalette(Palette &pal, bool want) { vs.RefreshColourPalette(pal, want); } void Editor::RefreshStyleData() { if (!stylesValid) { stylesValid = true; AutoSurface surface(this); if (surface) { vs.Refresh(*surface); RefreshColourPalette(palette, true); palette.Allocate(wMain); RefreshColourPalette(palette, false); } if (wrapIndentMode == SC_WRAPINDENT_INDENT) { wrapAddIndent = pdoc->IndentSize() * vs.spaceWidth; } else if (wrapIndentMode == SC_WRAPINDENT_SAME) { wrapAddIndent = 0; } else { //SC_WRAPINDENT_FIXED wrapAddIndent = wrapVisualStartIndent * vs.aveCharWidth; if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (wrapAddIndent <= 0)) wrapAddIndent = vs.aveCharWidth; // must indent to show start visual } SetScrollBars(); SetRectangularRange(); } } PRectangle Editor::GetClientRectangle() { return wMain.GetClientPosition(); } PRectangle Editor::GetTextRectangle() { PRectangle rc = GetClientRectangle(); rc.left += vs.fixedColumnWidth; rc.right -= vs.rightMarginWidth; return rc; } int Editor::LinesOnScreen() { PRectangle rcClient = GetClientRectangle(); int htClient = rcClient.bottom - rcClient.top; //Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1); return htClient / vs.lineHeight; } int Editor::LinesToScroll() { int retVal = LinesOnScreen() - 1; if (retVal < 1) return 1; else return retVal; } int Editor::MaxScrollPos() { //Platform::DebugPrintf("Lines %d screen = %d maxScroll = %d\n", //LinesTotal(), LinesOnScreen(), LinesTotal() - LinesOnScreen() + 1); int retVal = cs.LinesDisplayed(); if (endAtLastLine) { retVal -= LinesOnScreen(); } else { retVal--; } if (retVal < 0) { return 0; } else { return retVal; } } const char *ControlCharacterString(unsigned char ch) { const char *reps[] = { "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" }; if (ch < (sizeof(reps) / sizeof(reps[0]))) { return reps[ch]; } else { return "BAD"; } } /** * Convenience class to ensure LineLayout objects are always disposed. */ class AutoLineLayout { LineLayoutCache &llc; LineLayout *ll; AutoLineLayout &operator=(const AutoLineLayout &); public: AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {} ~AutoLineLayout() { llc.Dispose(ll); ll = 0; } LineLayout *operator->() const { return ll; } operator LineLayout *() const { return ll; } void Set(LineLayout *ll_) { llc.Dispose(ll); ll = ll_; } }; SelectionPosition Editor::ClampPositionIntoDocument(SelectionPosition sp) const { if (sp.Position() < 0) { return SelectionPosition(0); } else if (sp.Position() > pdoc->Length()) { return SelectionPosition(pdoc->Length()); } else { // If not at end of line then set offset to 0 if (!pdoc->IsLineEndPosition(sp.Position())) sp.SetVirtualSpace(0); return sp; } } Point Editor::LocationFromPosition(SelectionPosition pos) { Point pt; RefreshStyleData(); if (pos.Position() == INVALID_POSITION) return pt; int line = pdoc->LineFromPosition(pos.Position()); int lineVisible = cs.DisplayFromDoc(line); //Platform::DebugPrintf("line=%d\n", line); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); if (surface && ll) { // -1 because of adding in for visible lines in following loop. pt.y = (lineVisible - topLine - 1) * vs.lineHeight; pt.x = 0; unsigned int posLineStart = pdoc->LineStart(line); LayoutLine(line, surface, vs, ll, wrapWidth); int posInLine = pos.Position() - posLineStart; // In case of very long line put x at arbitrary large position if (posInLine > ll->maxLineLength) { pt.x = ll->positions[ll->maxLineLength] - ll->positions[ll->LineStart(ll->lines)]; } for (int subLine = 0; subLine < ll->lines; subLine++) { if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) { pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart(subLine)]; if (ll->wrapIndent != 0) { int lineStart = ll->LineStart(subLine); if (lineStart != 0) // Wrapped pt.x += ll->wrapIndent; } } if (posInLine >= ll->LineStart(subLine)) { pt.y += vs.lineHeight; } } pt.x += vs.fixedColumnWidth - xOffset; } pt.x += pos.VirtualSpace() * static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth); return pt; } Point Editor::LocationFromPosition(int pos) { return LocationFromPosition(SelectionPosition(pos)); } int Editor::XFromPosition(int pos) { Point pt = LocationFromPosition(pos); return pt.x - vs.fixedColumnWidth + xOffset; } int Editor::XFromPosition(SelectionPosition sp) { Point pt = LocationFromPosition(sp); return pt.x - vs.fixedColumnWidth + xOffset; } int Editor::LineFromLocation(Point pt) { return cs.DocFromDisplay(pt.y / vs.lineHeight + topLine); } void Editor::SetTopLine(int topLineNew) { topLine = topLineNew; posTopLine = pdoc->LineStart(cs.DocFromDisplay(topLine)); } SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition, bool virtualSpace) { RefreshStyleData(); if (canReturnInvalid) { PRectangle rcClient = GetTextRectangle(); if (!rcClient.Contains(pt)) return SelectionPosition(INVALID_POSITION); if (pt.x < vs.fixedColumnWidth) return SelectionPosition(INVALID_POSITION); if (pt.y < 0) return SelectionPosition(INVALID_POSITION); } pt.x = pt.x - vs.fixedColumnWidth + xOffset; int visibleLine = pt.y / vs.lineHeight + topLine; if (pt.y < 0) { // Division rounds towards 0 visibleLine = (pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine; } if (!canReturnInvalid && (visibleLine < 0)) visibleLine = 0; int lineDoc = cs.DocFromDisplay(visibleLine); if (canReturnInvalid && (lineDoc < 0)) return SelectionPosition(INVALID_POSITION); if (lineDoc >= pdoc->LinesTotal()) return SelectionPosition(canReturnInvalid ? INVALID_POSITION : pdoc->Length()); unsigned int posLineStart = pdoc->LineStart(lineDoc); SelectionPosition retVal(canReturnInvalid ? INVALID_POSITION : static_cast<int>(posLineStart)); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); if (surface && ll) { LayoutLine(lineDoc, surface, vs, ll, wrapWidth); int lineStartSet = cs.DisplayFromDoc(lineDoc); int subLine = visibleLine - lineStartSet; if (subLine < ll->lines) { int lineStart = ll->LineStart(subLine); int lineEnd = ll->LineLastVisible(subLine); int subLineStart = ll->positions[lineStart]; if (ll->wrapIndent != 0) { if (lineStart != 0) // Wrapped pt.x -= ll->wrapIndent; } int i = ll->FindBefore(pt.x + subLineStart, lineStart, lineEnd); while (i < lineEnd) { if (charPosition) { if ((pt.x + subLineStart) < (ll->positions[i + 1])) { return SelectionPosition(pdoc->MovePositionOutsideChar(i + posLineStart, 1)); } } else { if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { return SelectionPosition(pdoc->MovePositionOutsideChar(i + posLineStart, 1)); } } i++; } if (virtualSpace) { const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth); int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth; return SelectionPosition(lineEnd + posLineStart, spaceOffset); } else if (canReturnInvalid) { if (pt.x < (ll->positions[lineEnd] - subLineStart)) { return SelectionPosition(pdoc->MovePositionOutsideChar(lineEnd + posLineStart, 1)); } } else { return SelectionPosition(lineEnd + posLineStart); } } if (!canReturnInvalid) return SelectionPosition(ll->numCharsInLine + posLineStart); } return retVal; } int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) { return SPositionFromLocation(pt, canReturnInvalid, charPosition, false).Position(); } /** * Find the document position corresponding to an x coordinate on a particular document line. * Ensure is between whole characters when document is in multi-byte or UTF-8 mode. */ int Editor::PositionFromLineX(int lineDoc, int x) { RefreshStyleData(); if (lineDoc >= pdoc->LinesTotal()) return pdoc->Length(); //Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); int retVal = 0; if (surface && ll) { unsigned int posLineStart = pdoc->LineStart(lineDoc); LayoutLine(lineDoc, surface, vs, ll, wrapWidth); retVal = ll->numCharsBeforeEOL + posLineStart; int subLine = 0; int lineStart = ll->LineStart(subLine); int lineEnd = ll->LineLastVisible(subLine); int subLineStart = ll->positions[lineStart]; if (ll->wrapIndent != 0) { if (lineStart != 0) // Wrapped x -= ll->wrapIndent; } int i = ll->FindBefore(x + subLineStart, lineStart, lineEnd); while (i < lineEnd) { if ((x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1); break; } i++; } } return retVal; } /** * Find the document position corresponding to an x coordinate on a particular document line. * Ensure is between whole characters when document is in multi-byte or UTF-8 mode. */ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) { RefreshStyleData(); if (lineDoc >= pdoc->LinesTotal()) return SelectionPosition(pdoc->Length()); //Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); int retVal = 0; if (surface && ll) { unsigned int posLineStart = pdoc->LineStart(lineDoc); LayoutLine(lineDoc, surface, vs, ll, wrapWidth); int subLine = 0; int lineStart = ll->LineStart(subLine); int lineEnd = ll->LineLastVisible(subLine); int subLineStart = ll->positions[lineStart]; if (ll->wrapIndent != 0) { if (lineStart != 0) // Wrapped x -= ll->wrapIndent; } int i = ll->FindBefore(x + subLineStart, lineStart, lineEnd); while (i < lineEnd) { if ((x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1); return SelectionPosition(retVal); } i++; } const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth); int spaceOffset = (x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth; return SelectionPosition(lineEnd + posLineStart, spaceOffset); } return SelectionPosition(retVal); } /** * If painting then abandon the painting because a wider redraw is needed. * @return true if calling code should stop drawing. */ bool Editor::AbandonPaint() { if ((paintState == painting) && !paintingAllText) { paintState = paintAbandoned; } return paintState == paintAbandoned; } void Editor::RedrawRect(PRectangle rc) { //Platform::DebugPrintf("Redraw %0d,%0d - %0d,%0d\n", rc.left, rc.top, rc.right, rc.bottom); // Clip the redraw rectangle into the client area PRectangle rcClient = GetClientRectangle(); if (rc.top < rcClient.top) rc.top = rcClient.top; if (rc.bottom > rcClient.bottom) rc.bottom = rcClient.bottom; if (rc.left < rcClient.left) rc.left = rcClient.left; if (rc.right > rcClient.right) rc.right = rcClient.right; if ((rc.bottom > rc.top) && (rc.right > rc.left)) { wMain.InvalidateRectangle(rc); } } void Editor::Redraw() { //Platform::DebugPrintf("Redraw all\n"); PRectangle rcClient = GetClientRectangle(); wMain.InvalidateRectangle(rcClient); //wMain.InvalidateAll(); } void Editor::RedrawSelMargin(int line, bool allAfter) { if (!AbandonPaint()) { if (vs.maskInLine) { Redraw(); } else { PRectangle rcSelMargin = GetClientRectangle(); rcSelMargin.right = vs.fixedColumnWidth; if (line != -1) { int position = pdoc->LineStart(line); PRectangle rcLine = RectangleFromRange(position, position); rcSelMargin.top = rcLine.top; if (!allAfter) rcSelMargin.bottom = rcLine.bottom; } wMain.InvalidateRectangle(rcSelMargin); } } } PRectangle Editor::RectangleFromRange(int start, int end) { int minPos = start; if (minPos > end) minPos = end; int maxPos = start; if (maxPos < end) maxPos = end; int minLine = cs.DisplayFromDoc(pdoc->LineFromPosition(minPos)); int lineDocMax = pdoc->LineFromPosition(maxPos); int maxLine = cs.DisplayFromDoc(lineDocMax) + cs.GetHeight(lineDocMax) - 1; PRectangle rcClient = GetTextRectangle(); PRectangle rc; rc.left = vs.fixedColumnWidth; rc.top = (minLine - topLine) * vs.lineHeight; if (rc.top < 0) rc.top = 0; rc.right = rcClient.right; rc.bottom = (maxLine - topLine + 1) * vs.lineHeight; // Ensure PRectangle is within 16 bit space rc.top = Platform::Clamp(rc.top, -32000, 32000); rc.bottom = Platform::Clamp(rc.bottom, -32000, 32000); return rc; } void Editor::InvalidateRange(int start, int end) { RedrawRect(RectangleFromRange(start, end)); } int Editor::CurrentPosition() { return sel.MainCaret(); } bool Editor::SelectionEmpty() { return sel.Empty(); } SelectionPosition Editor::SelectionStart() { return sel.RangeMain().Start(); } SelectionPosition Editor::SelectionEnd() { return sel.RangeMain().End(); } void Editor::SetRectangularRange() { if (sel.IsRectangular()) { int xAnchor = XFromPosition(sel.Rectangular().anchor); int xCaret = XFromPosition(sel.Rectangular().caret); if (sel.selType == Selection::selThin) { xCaret = xAnchor; } int lineAnchor = pdoc->LineFromPosition(sel.Rectangular().anchor.Position()); int lineCaret = pdoc->LineFromPosition(sel.Rectangular().caret.Position()); int increment = (lineCaret > lineAnchor) ? 1 : -1; for (int line=lineAnchor; line != lineCaret+increment; line += increment) { SelectionRange range(SPositionFromLineX(line, xCaret), SPositionFromLineX(line, xAnchor)); if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) == 0) range.ClearVirtualSpace(); if (line == lineAnchor) sel.SetSelection(range); else sel.AddSelection(range); } } } void Editor::ThinRectangularRange() { if (sel.IsRectangular()) { sel.selType = Selection::selThin; if (sel.Rectangular().caret < sel.Rectangular().anchor) { sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).caret, sel.Range(0).anchor); } else { sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).anchor, sel.Range(0).caret); } SetRectangularRange(); } } void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection) { if (sel.Count() > 1 || !(sel.RangeMain().anchor == newMain.anchor) || sel.IsRectangular()) { invalidateWholeSelection = true; } int firstAffected = Platform::Minimum(sel.RangeMain().Start().Position(), newMain.Start().Position()); // +1 for lastAffected ensures caret repainted int lastAffected = Platform::Maximum(newMain.caret.Position()+1, newMain.anchor.Position()); lastAffected = Platform::Maximum(lastAffected, sel.RangeMain().End().Position()); if (invalidateWholeSelection) { for (size_t r=0; r<sel.Count(); r++) { firstAffected = Platform::Minimum(firstAffected, sel.Range(r).caret.Position()); firstAffected = Platform::Minimum(firstAffected, sel.Range(r).anchor.Position()); lastAffected = Platform::Maximum(lastAffected, sel.Range(r).caret.Position()+1); lastAffected = Platform::Maximum(lastAffected, sel.Range(r).anchor.Position()); } } needUpdateUI = true; InvalidateRange(firstAffected, lastAffected); } void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) { currentPos_ = ClampPositionIntoDocument(currentPos_); anchor_ = ClampPositionIntoDocument(anchor_); /* For Line selection - ensure the anchor and caret are always at the beginning and end of the region lines. */ if (sel.selType == Selection::selLines) { if (currentPos_ > anchor_) { anchor_ = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(anchor_.Position()))); currentPos_ = SelectionPosition(pdoc->LineEnd(pdoc->LineFromPosition(currentPos_.Position()))); } else { currentPos_ = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(currentPos_.Position()))); anchor_ = SelectionPosition(pdoc->LineEnd(pdoc->LineFromPosition(anchor_.Position()))); } } SelectionRange rangeNew(currentPos_, anchor_); if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) { InvalidateSelection(rangeNew); } sel.RangeMain() = rangeNew; SetRectangularRange(); ClaimSelection(); } void Editor::SetSelection(int currentPos_, int anchor_) { SetSelection(SelectionPosition(currentPos_), SelectionPosition(anchor_)); } // Just move the caret on the main selection void Editor::SetSelection(SelectionPosition currentPos_) { currentPos_ = ClampPositionIntoDocument(currentPos_); if (sel.Count() > 1 || !(sel.RangeMain().caret == currentPos_)) { InvalidateSelection(SelectionRange(currentPos_)); } if (sel.IsRectangular()) { sel.Rectangular() = SelectionRange(SelectionPosition(currentPos_), sel.Rectangular().anchor); SetRectangularRange(); } else { sel.RangeMain() = SelectionRange(SelectionPosition(currentPos_), sel.RangeMain().anchor); } ClaimSelection(); } void Editor::SetSelection(int currentPos_) { SetSelection(SelectionPosition(currentPos_)); } void Editor::SetEmptySelection(SelectionPosition currentPos_) { SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_)); if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) { InvalidateSelection(rangeNew); } sel.Clear(); sel.RangeMain() = rangeNew; SetRectangularRange(); ClaimSelection(); } void Editor::SetEmptySelection(int currentPos_) { SetEmptySelection(SelectionPosition(currentPos_)); } bool Editor::RangeContainsProtected(int start, int end) const { if (vs.ProtectionActive()) { if (start > end) { int t = start; start = end; end = t; } int mask = pdoc->stylingBitsMask; for (int pos = start; pos < end; pos++) { if (vs.styles[pdoc->StyleAt(pos) & mask].IsProtected()) return true; } } return false; } bool Editor::SelectionContainsProtected() { for (size_t r=0; r<sel.Count(); r++) { if (RangeContainsProtected(sel.Range(r).Start().Position(), sel.Range(r).End().Position())) { return true; } } return false; } /** * Asks document to find a good position and then moves out of any invisible positions. */ int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) const { return MovePositionOutsideChar(SelectionPosition(pos), moveDir, checkLineEnd).Position(); } SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd) const { int posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd); if (posMoved != pos.Position()) pos.SetPosition(posMoved); if (vs.ProtectionActive()) { int mask = pdoc->stylingBitsMask; if (moveDir > 0) { if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected()) { while ((pos.Position() < pdoc->Length()) && (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected())) pos.Add(1); } } else if (moveDir < 0) { if (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected()) { while ((pos.Position() > 0) && (vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected())) pos.Add(-1); } } } return pos; } int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) { bool simpleCaret = (sel.Count() == 1) && sel.Empty(); SelectionPosition spCaret = sel.Last(); int delta = newPos.Position() - sel.MainCaret(); newPos = ClampPositionIntoDocument(newPos); newPos = MovePositionOutsideChar(newPos, delta); if (!multipleSelection && sel.IsRectangular() && (selt == Selection::selStream)) { // Can't turn into multiple selection so clear additional selections InvalidateSelection(SelectionRange(newPos), true); SelectionRange rangeMain = sel.RangeMain(); sel.SetSelection(rangeMain); } if (!sel.IsRectangular() && (selt == Selection::selRectangle)) { // Switching to rectangular SelectionRange rangeMain = sel.RangeMain(); sel.Clear(); sel.Rectangular() = rangeMain; } if (selt != Selection::noSel) { sel.selType = selt; } if (selt != Selection::noSel || sel.MoveExtends()) { SetSelection(newPos); } else { SetEmptySelection(newPos); } ShowCaretAtCurrentPosition(); if (ensureVisible) { XYScrollPosition newXY = XYScrollToMakeVisible(true, true, true); if (simpleCaret && (newXY.xOffset == xOffset)) { // simple vertical scroll then invalidate ScrollTo(newXY.topLine); InvalidateSelection(SelectionRange(spCaret), true); } else { SetXYScroll(newXY); } } return 0; } int Editor::MovePositionTo(int newPos, Selection::selTypes selt, bool ensureVisible) { return MovePositionTo(SelectionPosition(newPos), selt, ensureVisible); } SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveDir) { pos = ClampPositionIntoDocument(pos); pos = MovePositionOutsideChar(pos, moveDir); int lineDoc = pdoc->LineFromPosition(pos.Position()); if (cs.GetVisible(lineDoc)) { return pos; } else { int lineDisplay = cs.DisplayFromDoc(lineDoc); if (moveDir > 0) { // lineDisplay is already line before fold as lines in fold use display line of line after fold lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed()); return SelectionPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay))); } else { lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed()); return SelectionPosition(pdoc->LineEnd(cs.DocFromDisplay(lineDisplay))); } } } SelectionPosition Editor::MovePositionSoVisible(int pos, int moveDir) { return MovePositionSoVisible(SelectionPosition(pos), moveDir); } Point Editor::PointMainCaret() { return LocationFromPosition(sel.Range(sel.Main()).caret); } /** * Choose the x position that the caret will try to stick to * as it moves up and down. */ void Editor::SetLastXChosen() { Point pt = PointMainCaret(); lastXChosen = pt.x + xOffset; } void Editor::ScrollTo(int line, bool moveThumb) { int topLineNew = Platform::Clamp(line, 0, MaxScrollPos()); if (topLineNew != topLine) { // Try to optimise small scrolls int linesToMove = topLine - topLineNew; SetTopLine(topLineNew); // Optimize by styling the view as this will invalidate any needed area // which could abort the initial paint if discovered later. StyleToPositionInView(PositionAfterArea(GetClientRectangle())); #ifndef UNDER_CE // Perform redraw rather than scroll if many lines would be redrawn anyway. if ((abs(linesToMove) <= 10) && (paintState == notPainting)) { ScrollText(linesToMove); } else { Redraw(); } #else Redraw(); #endif if (moveThumb) { SetVerticalScrollPos(); } NotifyScrolled(); } } void Editor::ScrollText(int /* linesToMove */) { //Platform::DebugPrintf("Editor::ScrollText %d\n", linesToMove); Redraw(); } void Editor::HorizontalScrollTo(int xPos) { //Platform::DebugPrintf("HorizontalScroll %d\n", xPos); if (xPos < 0) xPos = 0; if ((wrapState == eWrapNone) && (xOffset != xPos)) { xOffset = xPos; SetHorizontalScrollPos(); RedrawRect(GetClientRectangle()); } NotifyScrolled(); } void Editor::MoveCaretInsideView(bool ensureVisible) { PRectangle rcClient = GetTextRectangle(); Point pt = PointMainCaret(); if (pt.y < rcClient.top) { MovePositionTo(SPositionFromLocation( Point(lastXChosen - xOffset, rcClient.top)), Selection::noSel, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight; MovePositionTo(SPositionFromLocation( Point(lastXChosen - xOffset, rcClient.top + yOfLastLineFullyDisplayed)), Selection::noSel, ensureVisible); } } int Editor::DisplayFromPosition(int pos) { int lineDoc = pdoc->LineFromPosition(pos); int lineDisplay = cs.DisplayFromDoc(lineDoc); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); if (surface && ll) { LayoutLine(lineDoc, surface, vs, ll, wrapWidth); unsigned int posLineStart = pdoc->LineStart(lineDoc); int posInLine = pos - posLineStart; lineDisplay--; // To make up for first increment ahead. for (int subLine = 0; subLine < ll->lines; subLine++) { if (posInLine >= ll->LineStart(subLine)) { lineDisplay++; } } } return lineDisplay; } /** * Ensure the caret is reasonably visible in context. * Caret policy in SciTE If slop is set, we can define a slop value. This value defines an unwanted zone (UZ) where the caret is... unwanted. This zone is defined as a number of pixels near the vertical margins, and as a number of lines near the horizontal margins. By keeping the caret away from the edges, it is seen within its context, so it is likely that the identifier that the caret is on can be completely seen, and that the current line is seen with some of the lines following it which are often dependent on that line. If strict is set, the policy is enforced... strictly. The caret is centred on the display if slop is not set, and cannot go in the UZ if slop is set. If jumps is set, the display is moved more energetically so the caret can move in the same direction longer before the policy is applied again. '3UZ' notation is used to indicate three time the size of the UZ as a distance to the margin. If even is not set, instead of having symmetrical UZs, the left and bottom UZs are extended up to right and top UZs respectively. This way, we favour the displaying of useful information: the begining of lines, where most code reside, and the lines after the caret, eg. the body of a function. | | | | | slop | strict | jumps | even | Caret can go to the margin | When reaching limit (caret going out of | | | | | visibility or going into the UZ) display is... -----+--------+-------+------+--------------------------------------------+-------------------------------------------------------------- 0 | 0 | 0 | 0 | Yes | moved to put caret on top/on right 0 | 0 | 0 | 1 | Yes | moved by one position 0 | 0 | 1 | 0 | Yes | moved to put caret on top/on right 0 | 0 | 1 | 1 | Yes | centred on the caret 0 | 1 | - | 0 | Caret is always on top/on right of display | - 0 | 1 | - | 1 | No, caret is always centred | - 1 | 0 | 0 | 0 | Yes | moved to put caret out of the asymmetrical UZ 1 | 0 | 0 | 1 | Yes | moved to put caret out of the UZ 1 | 0 | 1 | 0 | Yes | moved to put caret at 3UZ of the top or right margin 1 | 0 | 1 | 1 | Yes | moved to put caret at 3UZ of the margin 1 | 1 | - | 0 | Caret is always at UZ of top/right margin | - 1 | 1 | 0 | 1 | No, kept out of UZ | moved by one position 1 | 1 | 1 | 1 | No, kept out of UZ | moved to put caret at 3UZ of the margin */ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const bool useMargin, const bool vert, const bool horiz) { PRectangle rcClient = GetTextRectangle(); const SelectionPosition posCaret = posDrag.IsValid() ? posDrag : sel.RangeMain().caret; const Point pt = LocationFromPosition(posCaret); const Point ptBottomCaret(pt.x, pt.y + vs.lineHeight - 1); const int lineCaret = DisplayFromPosition(posCaret.Position()); XYScrollPosition newXY(xOffset, topLine); // Vertical positioning if (vert && (pt.y < rcClient.top || ptBottomCaret.y > rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) { const int linesOnScreen = LinesOnScreen(); const int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2; const bool bSlop = (caretYPolicy & CARET_SLOP) != 0; const bool bStrict = (caretYPolicy & CARET_STRICT) != 0; const bool bJump = (caretYPolicy & CARET_JUMPS) != 0; const bool bEven = (caretYPolicy & CARET_EVEN) != 0; // It should be possible to scroll the window to show the caret, // but this fails to remove the caret on GTK+ if (bSlop) { // A margin is defined int yMoveT, yMoveB; if (bStrict) { int yMarginT, yMarginB; if (!useMargin) { // In drag mode, avoid moves // otherwise, a double click will select several lines. yMarginT = yMarginB = 0; } else { // yMarginT must equal to caretYSlop, with a minimum of 1 and // a maximum of slightly less than half the heigth of the text area. yMarginT = Platform::Clamp(caretYSlop, 1, halfScreen); if (bEven) { yMarginB = yMarginT; } else { yMarginB = linesOnScreen - yMarginT - 1; } } yMoveT = yMarginT; if (bEven) { if (bJump) { yMoveT = Platform::Clamp(caretYSlop * 3, 1, halfScreen); } yMoveB = yMoveT; } else { yMoveB = linesOnScreen - yMoveT - 1; } if (lineCaret < topLine + yMarginT) { // Caret goes too high newXY.topLine = lineCaret - yMoveT; } else if (lineCaret > topLine + linesOnScreen - 1 - yMarginB) { // Caret goes too low newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB; } } else { // Not strict yMoveT = bJump ? caretYSlop * 3 : caretYSlop; yMoveT = Platform::Clamp(yMoveT, 1, halfScreen); if (bEven) { yMoveB = yMoveT; } else { yMoveB = linesOnScreen - yMoveT - 1; } if (lineCaret < topLine) { // Caret goes too high newXY.topLine = lineCaret - yMoveT; } else if (lineCaret > topLine + linesOnScreen - 1) { // Caret goes too low newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB; } } } else { // No slop if (!bStrict && !bJump) { // Minimal move if (lineCaret < topLine) { // Caret goes too high newXY.topLine = lineCaret; } else if (lineCaret > topLine + linesOnScreen - 1) { // Caret goes too low if (bEven) { newXY.topLine = lineCaret - linesOnScreen + 1; } else { newXY.topLine = lineCaret; } } } else { // Strict or going out of display if (bEven) { // Always center caret newXY.topLine = lineCaret - halfScreen; } else { // Always put caret on top of display newXY.topLine = lineCaret; } } } newXY.topLine = Platform::Clamp(newXY.topLine, 0, MaxScrollPos()); } // Horizontal positioning if (horiz && (wrapState == eWrapNone)) { const int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2; const bool bSlop = (caretXPolicy & CARET_SLOP) != 0; const bool bStrict = (caretXPolicy & CARET_STRICT) != 0; const bool bJump = (caretXPolicy & CARET_JUMPS) != 0; const bool bEven = (caretXPolicy & CARET_EVEN) != 0; if (bSlop) { // A margin is defined int xMoveL, xMoveR; if (bStrict) { int xMarginL, xMarginR; if (!useMargin) { // In drag mode, avoid moves unless very near of the margin // otherwise, a simple click will select text. xMarginL = xMarginR = 2; } else { // xMargin must equal to caretXSlop, with a minimum of 2 and // a maximum of slightly less than half the width of the text area. xMarginR = Platform::Clamp(caretXSlop, 2, halfScreen); if (bEven) { xMarginL = xMarginR; } else { xMarginL = rcClient.Width() - xMarginR - 4; } } if (bJump && bEven) { // Jump is used only in even mode xMoveL = xMoveR = Platform::Clamp(caretXSlop * 3, 1, halfScreen); } else { xMoveL = xMoveR = 0; // Not used, avoid a warning } if (pt.x < rcClient.left + xMarginL) { // Caret is on the left of the display if (bJump && bEven) { newXY.xOffset -= xMoveL; } else { // Move just enough to allow to display the caret newXY.xOffset -= (rcClient.left + xMarginL) - pt.x; } } else if (pt.x >= rcClient.right - xMarginR) { // Caret is on the right of the display if (bJump && bEven) { newXY.xOffset += xMoveR; } else { // Move just enough to allow to display the caret newXY.xOffset += pt.x - (rcClient.right - xMarginR) + 1; } } } else { // Not strict xMoveR = bJump ? caretXSlop * 3 : caretXSlop; xMoveR = Platform::Clamp(xMoveR, 1, halfScreen); if (bEven) { xMoveL = xMoveR; } else { xMoveL = rcClient.Width() - xMoveR - 4; } if (pt.x < rcClient.left) { // Caret is on the left of the display newXY.xOffset -= xMoveL; } else if (pt.x >= rcClient.right) { // Caret is on the right of the display newXY.xOffset += xMoveR; } } } else { // No slop if (bStrict || (bJump && (pt.x < rcClient.left || pt.x >= rcClient.right))) { // Strict or going out of display if (bEven) { // Center caret newXY.xOffset += pt.x - rcClient.left - halfScreen; } else { // Put caret on right newXY.xOffset += pt.x - rcClient.right + 1; } } else { // Move just enough to allow to display the caret if (pt.x < rcClient.left) { // Caret is on the left of the display if (bEven) { newXY.xOffset -= rcClient.left - pt.x; } else { newXY.xOffset += pt.x - rcClient.right + 1; } } else if (pt.x >= rcClient.right) { // Caret is on the right of the display newXY.xOffset += pt.x - rcClient.right + 1; } } } // In case of a jump (find result) largely out of display, adjust the offset to display the caret if (pt.x + xOffset < rcClient.left + newXY.xOffset) { newXY.xOffset = pt.x + xOffset - rcClient.left; } else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) { newXY.xOffset = pt.x + xOffset - rcClient.right + 1; if (vs.caretStyle == CARETSTYLE_BLOCK) { // Ensure we can see a good portion of the block caret newXY.xOffset += vs.aveCharWidth; } } if (newXY.xOffset < 0) { newXY.xOffset = 0; } } return newXY; } void Editor::SetXYScroll(XYScrollPosition newXY) { if ((newXY.topLine != topLine) || (newXY.xOffset != xOffset)) { if (newXY.topLine != topLine) { SetTopLine(newXY.topLine); SetVerticalScrollPos(); } if (newXY.xOffset != xOffset) { xOffset = newXY.xOffset; if (newXY.xOffset > 0) { PRectangle rcText = GetTextRectangle(); if (horizontalScrollBarVisible && rcText.Width() + xOffset > scrollWidth) { scrollWidth = xOffset + rcText.Width(); SetScrollBars(); } } SetHorizontalScrollPos(); } Redraw(); UpdateSystemCaret(); } } void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { SetXYScroll(XYScrollToMakeVisible(useMargin, vert, horiz)); } void Editor::ShowCaretAtCurrentPosition() { if (hasFocus) { caret.active = true; caret.on = true; SetTicking(true); } else { caret.active = false; caret.on = false; } InvalidateCaret(); } void Editor::DropCaret() { caret.active = false; InvalidateCaret(); } void Editor::InvalidateCaret() { if (posDrag.IsValid()) { InvalidateRange(posDrag.Position(), posDrag.Position() + 1); } else { for (size_t r=0; r<sel.Count(); r++) { InvalidateRange(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1); } } UpdateSystemCaret(); } void Editor::UpdateSystemCaret() { } void Editor::NeedWrapping(int docLineStart, int docLineEnd) { docLineStart = Platform::Clamp(docLineStart, 0, pdoc->LinesTotal()); if (wrapStart > docLineStart) { wrapStart = docLineStart; llc.Invalidate(LineLayout::llPositions); } if (wrapEnd < docLineEnd) { wrapEnd = docLineEnd; } wrapEnd = Platform::Clamp(wrapEnd, 0, pdoc->LinesTotal()); // Wrap lines during idle. if ((wrapState != eWrapNone) && (wrapEnd != wrapStart)) { SetIdle(true); } } bool Editor::WrapOneLine(Surface *surface, int lineToWrap) { AutoLineLayout ll(llc, RetrieveLineLayout(lineToWrap)); int linesWrapped = 1; if (ll) { LayoutLine(lineToWrap, surface, vs, ll, wrapWidth); linesWrapped = ll->lines; } return cs.SetHeight(lineToWrap, linesWrapped + (vs.annotationVisible ? pdoc->AnnotationLines(lineToWrap) : 0)); } // Check if wrapping needed and perform any needed wrapping. // fullwrap: if true, all lines which need wrapping will be done, // in this single call. // priorityWrapLineStart: If greater than or equal to zero, all lines starting from // here to 1 page + 100 lines past will be wrapped (even if there are // more lines under wrapping process in idle). // If it is neither fullwrap, nor priorityWrap, then 1 page + 100 lines will be // wrapped, if there are any wrapping going on in idle. (Generally this // condition is called only from idler). // Return true if wrapping occurred. bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) { // If there are any pending wraps, do them during idle if possible. int linesInOneCall = LinesOnScreen() + 100; if (wrapState != eWrapNone) { if (wrapStart < wrapEnd) { if (!SetIdle(true)) { // Idle processing not supported so full wrap required. fullWrap = true; } } if (!fullWrap && priorityWrapLineStart >= 0 && // .. and if the paint window is outside pending wraps (((priorityWrapLineStart + linesInOneCall) < wrapStart) || (priorityWrapLineStart > wrapEnd))) { // No priority wrap pending return false; } } int goodTopLine = topLine; bool wrapOccurred = false; if (wrapStart <= pdoc->LinesTotal()) { if (wrapState == eWrapNone) { if (wrapWidth != LineLayout::wrapWidthInfinite) { wrapWidth = LineLayout::wrapWidthInfinite; for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) { cs.SetHeight(lineDoc, 1 + (vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0)); } wrapOccurred = true; } wrapStart = wrapLineLarge; wrapEnd = wrapLineLarge; } else { if (wrapEnd >= pdoc->LinesTotal()) wrapEnd = pdoc->LinesTotal(); //ElapsedTime et; int lineDocTop = cs.DocFromDisplay(topLine); int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop); PRectangle rcTextArea = GetClientRectangle(); rcTextArea.left = vs.fixedColumnWidth; rcTextArea.right -= vs.rightMarginWidth; wrapWidth = rcTextArea.Width(); RefreshStyleData(); AutoSurface surface(this); if (surface) { bool priorityWrap = false; int lastLineToWrap = wrapEnd; int lineToWrap = wrapStart; if (!fullWrap) { if (priorityWrapLineStart >= 0) { // This is a priority wrap. lineToWrap = priorityWrapLineStart; lastLineToWrap = priorityWrapLineStart + linesInOneCall; priorityWrap = true; } else { // This is idle wrap. lastLineToWrap = wrapStart + linesInOneCall; } if (lastLineToWrap >= wrapEnd) lastLineToWrap = wrapEnd; } // else do a fullWrap. // Ensure all lines being wrapped are styled. pdoc->EnsureStyledTo(pdoc->LineEnd(lastLineToWrap)); // Platform::DebugPrintf("Wraplines: full = %d, priorityStart = %d (wrapping: %d to %d)\n", fullWrap, priorityWrapLineStart, lineToWrap, lastLineToWrap); // Platform::DebugPrintf("Pending wraps: %d to %d\n", wrapStart, wrapEnd); while (lineToWrap < lastLineToWrap) { if (WrapOneLine(surface, lineToWrap)) { wrapOccurred = true; } lineToWrap++; } if (!priorityWrap) wrapStart = lineToWrap; // If wrapping is done, bring it to resting position if (wrapStart >= wrapEnd) { wrapStart = wrapLineLarge; wrapEnd = wrapLineLarge; } } goodTopLine = cs.DisplayFromDoc(lineDocTop); if (subLineTop < cs.GetHeight(lineDocTop)) goodTopLine += subLineTop; else goodTopLine += cs.GetHeight(lineDocTop); //double durWrap = et.Duration(true); //Platform::DebugPrintf("Wrap:%9.6g \n", durWrap); } } if (wrapOccurred) { SetScrollBars(); SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos())); SetVerticalScrollPos(); } return wrapOccurred; } void Editor::LinesJoin() { if (!RangeContainsProtected(targetStart, targetEnd)) { UndoGroup ug(pdoc); bool prevNonWS = true; for (int pos = targetStart; pos < targetEnd; pos++) { if (IsEOLChar(pdoc->CharAt(pos))) { targetEnd -= pdoc->LenChar(pos); pdoc->DelChar(pos); if (prevNonWS) { // Ensure at least one space separating previous lines pdoc->InsertChar(pos, ' '); targetEnd++; } } else { prevNonWS = pdoc->CharAt(pos) != ' '; } } } } const char *Editor::StringFromEOLMode(int eolMode) { if (eolMode == SC_EOL_CRLF) { return "\r\n"; } else if (eolMode == SC_EOL_CR) { return "\r"; } else { return "\n"; } } void Editor::LinesSplit(int pixelWidth) { if (!RangeContainsProtected(targetStart, targetEnd)) { if (pixelWidth == 0) { PRectangle rcText = GetTextRectangle(); pixelWidth = rcText.Width(); } int lineStart = pdoc->LineFromPosition(targetStart); int lineEnd = pdoc->LineFromPosition(targetEnd); const char *eol = StringFromEOLMode(pdoc->eolMode); UndoGroup ug(pdoc); for (int line = lineStart; line <= lineEnd; line++) { AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); if (surface && ll) { unsigned int posLineStart = pdoc->LineStart(line); LayoutLine(line, surface, vs, ll, pixelWidth); for (int subLine = 1; subLine < ll->lines; subLine++) { pdoc->InsertCString(posLineStart + (subLine - 1) * strlen(eol) + ll->LineStart(subLine), eol); targetEnd += static_cast<int>(strlen(eol)); } } lineEnd = pdoc->LineFromPosition(targetEnd); } } } int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) { if (vs.markers[markerCheck].markType == SC_MARK_EMPTY) return markerDefault; return markerCheck; } // Avoid 64 bit compiler warnings. // Scintilla does not support text buffers larger than 2**31 static int istrlen(const char *s) { return static_cast<int>(strlen(s)); } bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) { if (st.multipleStyles) { for (size_t iStyle=0; iStyle<st.length; iStyle++) { if (!vs.ValidStyle(styleOffset + st.styles[iStyle])) return false; } } else { if (!vs.ValidStyle(styleOffset + st.style)) return false; } return true; } static int WidthStyledText(Surface *surface, ViewStyle &vs, int styleOffset, const char *text, const unsigned char *styles, size_t len) { int width = 0; size_t start = 0; while (start < len) { size_t style = styles[start]; size_t endSegment = start; while ((endSegment+1 < len) && (static_cast<size_t>(styles[endSegment+1]) == style)) endSegment++; width += surface->WidthText(vs.styles[style+styleOffset].font, text + start, endSegment - start + 1); start = endSegment + 1; } return width; } static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, const StyledText &st) { int widthMax = 0; size_t start = 0; while (start < st.length) { size_t lenLine = st.LineLength(start); int widthSubLine; if (st.multipleStyles) { widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine); } else { widthSubLine = surface->WidthText(vs.styles[styleOffset + st.style].font, st.text + start, lenLine); } if (widthSubLine > widthMax) widthMax = widthSubLine; start += lenLine + 1; } return widthMax; } void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, const StyledText &st, size_t start, size_t length) { if (st.multipleStyles) { int x = rcText.left; size_t i = 0; while (i < length) { size_t end = i; int style = st.styles[i + start]; while (end < length-1 && st.styles[start+end+1] == style) end++; style += styleOffset; int width = surface->WidthText(vs.styles[style].font, st.text + start + i, end - i + 1); PRectangle rcSegment = rcText; rcSegment.left = x; rcSegment.right = x + width + 1; surface->DrawTextNoClip(rcSegment, vs.styles[style].font, ascent, st.text + start + i, end - i + 1, vs.styles[style].fore.allocated, vs.styles[style].back.allocated); x += width; i = end + 1; } } else { int style = st.style + styleOffset; surface->DrawTextNoClip(rcText, vs.styles[style].font, rcText.top + vs.maxAscent, st.text + start, length, vs.styles[style].fore.allocated, vs.styles[style].back.allocated); } } void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { if (vs.fixedColumnWidth == 0) return; PRectangle rcMargin = GetClientRectangle(); rcMargin.right = vs.fixedColumnWidth; if (!rc.Intersects(rcMargin)) return; Surface *surface; if (bufferedDraw) { surface = pixmapSelMargin; } else { surface = surfWindow; } PRectangle rcSelMargin = rcMargin; rcSelMargin.right = rcMargin.left; for (int margin = 0; margin < vs.margins; margin++) { if (vs.ms[margin].width > 0) { rcSelMargin.left = rcSelMargin.right; rcSelMargin.right = rcSelMargin.left + vs.ms[margin].width; if (vs.ms[margin].style != SC_MARGIN_NUMBER) { /* alternate scheme: if (vs.ms[margin].mask & SC_MASK_FOLDERS) surface->FillRectangle(rcSelMargin, vs.styles[STYLE_DEFAULT].back.allocated); else // Required because of special way brush is created for selection margin surface->FillRectangle(rcSelMargin, pixmapSelPattern); */ if (vs.ms[margin].mask & SC_MASK_FOLDERS) // Required because of special way brush is created for selection margin surface->FillRectangle(rcSelMargin, *pixmapSelPattern); else { ColourAllocated colour; switch (vs.ms[margin].style) { case SC_MARGIN_BACK: colour = vs.styles[STYLE_DEFAULT].back.allocated; break; case SC_MARGIN_FORE: colour = vs.styles[STYLE_DEFAULT].fore.allocated; break; default: colour = vs.styles[STYLE_LINENUMBER].back.allocated; break; } surface->FillRectangle(rcSelMargin, colour); } } else { surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back.allocated); } int visibleLine = topLine; int yposScreen = 0; // Work out whether the top line is whitespace located after a // lessening of fold level which implies a 'fold tail' but which should not // be displayed until the last of a sequence of whitespace. bool needWhiteClosure = false; int level = pdoc->GetLevel(cs.DocFromDisplay(topLine)); if (level & SC_FOLDLEVELWHITEFLAG) { int lineBack = cs.DocFromDisplay(topLine); int levelPrev = level; while ((lineBack > 0) && (levelPrev & SC_FOLDLEVELWHITEFLAG)) { lineBack--; levelPrev = pdoc->GetLevel(lineBack); } if (!(levelPrev & SC_FOLDLEVELHEADERFLAG)) { if ((level & SC_FOLDLEVELNUMBERMASK) < (levelPrev & SC_FOLDLEVELNUMBERMASK)) needWhiteClosure = true; } } // Old code does not know about new markers needed to distinguish all cases int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID, SC_MARKNUM_FOLDEROPEN); int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND, SC_MARKNUM_FOLDER); while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) { PLATFORM_ASSERT(visibleLine < cs.LinesDisplayed()); int lineDoc = cs.DocFromDisplay(visibleLine); PLATFORM_ASSERT(cs.GetVisible(lineDoc)); bool firstSubLine = visibleLine == cs.DisplayFromDoc(lineDoc); // Decide which fold indicator should be displayed level = pdoc->GetLevel(lineDoc); int levelNext = pdoc->GetLevel(lineDoc + 1); int marks = pdoc->GetMark(lineDoc); if (!firstSubLine) marks = 0; int levelNum = level & SC_FOLDLEVELNUMBERMASK; int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK; if (level & SC_FOLDLEVELHEADERFLAG) { if (firstSubLine) { if (cs.GetExpanded(lineDoc)) { if (levelNum == SC_FOLDLEVELBASE) marks |= 1 << SC_MARKNUM_FOLDEROPEN; else marks |= 1 << folderOpenMid; } else { if (levelNum == SC_FOLDLEVELBASE) marks |= 1 << SC_MARKNUM_FOLDER; else marks |= 1 << folderEnd; } } else { marks |= 1 << SC_MARKNUM_FOLDERSUB; } needWhiteClosure = false; } else if (level & SC_FOLDLEVELWHITEFLAG) { if (needWhiteClosure) { if (levelNext & SC_FOLDLEVELWHITEFLAG) { marks |= 1 << SC_MARKNUM_FOLDERSUB; } else if (levelNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL; needWhiteClosure = false; } else { marks |= 1 << SC_MARKNUM_FOLDERTAIL; needWhiteClosure = false; } } else if (levelNum > SC_FOLDLEVELBASE) { if (levelNextNum < levelNum) { if (levelNextNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL; } else { marks |= 1 << SC_MARKNUM_FOLDERTAIL; } } else { marks |= 1 << SC_MARKNUM_FOLDERSUB; } } } else if (levelNum > SC_FOLDLEVELBASE) { if (levelNextNum < levelNum) { needWhiteClosure = false; if (levelNext & SC_FOLDLEVELWHITEFLAG) { marks |= 1 << SC_MARKNUM_FOLDERSUB; needWhiteClosure = true; } else if (levelNextNum > SC_FOLDLEVELBASE) { marks |= 1 << SC_MARKNUM_FOLDERMIDTAIL; } else { marks |= 1 << SC_MARKNUM_FOLDERTAIL; } } else { marks |= 1 << SC_MARKNUM_FOLDERSUB; } } marks &= vs.ms[margin].mask; PRectangle rcMarker = rcSelMargin; rcMarker.top = yposScreen; rcMarker.bottom = yposScreen + vs.lineHeight; if (vs.ms[margin].style == SC_MARGIN_NUMBER) { char number[100]; number[0] = '\0'; if (firstSubLine) sprintf(number, "%d", lineDoc + 1); if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS) { int lev = pdoc->GetLevel(lineDoc); sprintf(number, "%c%c %03X %03X", (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_', (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_', lev & SC_FOLDLEVELNUMBERMASK, lev >> 16 ); } PRectangle rcNumber = rcMarker; // Right justify int width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, istrlen(number)); int xpos = rcNumber.right - width - 3; rcNumber.left = xpos; surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font, rcNumber.top + vs.maxAscent, number, istrlen(number), vs.styles[STYLE_LINENUMBER].fore.allocated, vs.styles[STYLE_LINENUMBER].back.allocated); } else if (vs.ms[margin].style == SC_MARGIN_TEXT || vs.ms[margin].style == SC_MARGIN_RTEXT) { if (firstSubLine) { const StyledText stMargin = pdoc->MarginStyledText(lineDoc); if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) { surface->FillRectangle(rcMarker, vs.styles[stMargin.StyleAt(0)+vs.marginStyleOffset].back.allocated); if (vs.ms[margin].style == SC_MARGIN_RTEXT) { int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); rcMarker.left = rcMarker.right - width - 3; } DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent, stMargin, 0, stMargin.length); } } } if (marks) { for (int markBit = 0; (markBit < 32) && marks; markBit++) { if (marks & 1) { vs.markers[markBit].Draw(surface, rcMarker, vs.styles[STYLE_LINENUMBER].font); } marks >>= 1; } } visibleLine++; yposScreen += vs.lineHeight; } } } PRectangle rcBlankMargin = rcMargin; rcBlankMargin.left = rcSelMargin.right; surface->FillRectangle(rcBlankMargin, vs.styles[STYLE_DEFAULT].back.allocated); if (bufferedDraw) { surfWindow->Copy(rcMargin, Point(), *pixmapSelMargin); } } void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { int ydiff = (rcTab.bottom - rcTab.top) / 2; int xhead = rcTab.right - 1 - ydiff; if (xhead <= rcTab.left) { ydiff -= rcTab.left - xhead - 1; xhead = rcTab.left - 1; } if ((rcTab.left + 2) < (rcTab.right - 1)) surface->MoveTo(rcTab.left + 2, ymid); else surface->MoveTo(rcTab.right - 1, ymid); surface->LineTo(rcTab.right - 1, ymid); surface->LineTo(xhead, ymid - ydiff); surface->MoveTo(rcTab.right - 1, ymid); surface->LineTo(xhead, ymid + ydiff); } LineLayout *Editor::RetrieveLineLayout(int lineNumber) { int posLineStart = pdoc->LineStart(lineNumber); int posLineEnd = pdoc->LineStart(lineNumber + 1); PLATFORM_ASSERT(posLineEnd >= posLineStart); int lineCaret = pdoc->LineFromPosition(sel.MainCaret()); return llc.Retrieve(lineNumber, lineCaret, posLineEnd - posLineStart, pdoc->GetStyleClock(), LinesOnScreen() + 1, pdoc->LinesTotal()); } static bool GoodTrailByte(int v) { return (v >= 0x80) && (v < 0xc0); } bool BadUTF(const char *s, int len, int &trailBytes) { // For the rules: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 if (trailBytes) { trailBytes--; return false; } const unsigned char *us = reinterpret_cast<const unsigned char *>(s); if (*us < 0x80) { // Single bytes easy return false; } else if (*us > 0xF4) { // Characters longer than 4 bytes not possible in current UTF-8 return true; } else if (*us >= 0xF0) { // 4 bytes if (len < 4) return true; if (GoodTrailByte(us[1]) && GoodTrailByte(us[2]) && GoodTrailByte(us[3])) { if (*us == 0xf4) { // Check if encoding a value beyond the last Unicode character 10FFFF if (us[1] > 0x8f) { return true; } else if (us[1] == 0x8f) { if (us[2] > 0xbf) { return true; } else if (us[2] == 0xbf) { if (us[3] > 0xbf) { return true; } } } } else if ((*us == 0xf0) && ((us[1] & 0xf0) == 0x80)) { // Overlong return true; } trailBytes = 3; return false; } else { return true; } } else if (*us >= 0xE0) { // 3 bytes if (len < 3) return true; if (GoodTrailByte(us[1]) && GoodTrailByte(us[2])) { if ((*us == 0xe0) && ((us[1] & 0xe0) == 0x80)) { // Overlong return true; } if ((*us == 0xed) && ((us[1] & 0xe0) == 0xa0)) { // Surrogate return true; } if ((*us == 0xef) && (us[1] == 0xbf) && (us[2] == 0xbe)) { // U+FFFE return true; } if ((*us == 0xef) && (us[1] == 0xbf) && (us[2] == 0xbf)) { // U+FFFF return true; } trailBytes = 2; return false; } else { return true; } } else if (*us >= 0xC2) { // 2 bytes if (len < 2) return true; if (GoodTrailByte(us[1])) { trailBytes = 1; return false; } else { return true; } } else if (*us >= 0xC0) { // Overlong encoding return true; } else { // Trail byte return true; } } /** * Fill in the LineLayout data for the given line. * Copy the given @a line and its styles from the document into local arrays. * Also determine the x position at which each character starts. */ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) { if (!ll) return; PLATFORM_ASSERT(line < pdoc->LinesTotal()); PLATFORM_ASSERT(ll->chars != NULL); int posLineStart = pdoc->LineStart(line); int posLineEnd = pdoc->LineStart(line + 1); // If the line is very long, limit the treatment to a length that should fit in the viewport if (posLineEnd > (posLineStart + ll->maxLineLength)) { posLineEnd = posLineStart + ll->maxLineLength; } if (ll->validity == LineLayout::llCheckTextAndStyle) { int lineLength = posLineEnd - posLineStart; if (!vstyle.viewEOL) { int cid = posLineEnd - 1; while ((cid > posLineStart) && IsEOLChar(pdoc->CharAt(cid))) { cid--; lineLength--; } } if (lineLength == ll->numCharsInLine) { // See if chars, styles, indicators, are all the same bool allSame = true; const int styleMask = pdoc->stylingBitsMask; // Check base line layout char styleByte = 0; int numCharsInLine = 0; while (numCharsInLine < lineLength) { int charInDoc = numCharsInLine + posLineStart; char chDoc = pdoc->CharAt(charInDoc); styleByte = pdoc->StyleAt(charInDoc); allSame = allSame && (ll->styles[numCharsInLine] == static_cast<unsigned char>(styleByte & styleMask)); allSame = allSame && (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask)); if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseMixed) allSame = allSame && (ll->chars[numCharsInLine] == chDoc); else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) allSame = allSame && (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc))); else // Style::caseUpper allSame = allSame && (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc))); numCharsInLine++; } allSame = allSame && (ll->styles[numCharsInLine] == styleByte); // For eolFilled if (allSame) { ll->validity = LineLayout::llPositions; } else { ll->validity = LineLayout::llInvalid; } } else { ll->validity = LineLayout::llInvalid; } } if (ll->validity == LineLayout::llInvalid) { ll->widthLine = LineLayout::wrapWidthInfinite; ll->lines = 1; int numCharsInLine = 0; int numCharsBeforeEOL = 0; if (vstyle.edgeState == EDGE_BACKGROUND) { ll->edgeColumn = pdoc->FindColumn(line, theEdge); if (ll->edgeColumn >= posLineStart) { ll->edgeColumn -= posLineStart; } } else { ll->edgeColumn = -1; } char styleByte = 0; int styleMask = pdoc->stylingBitsMask; ll->styleBitsSet = 0; // Fill base line layout for (int charInDoc = posLineStart; charInDoc < posLineEnd; charInDoc++) { char chDoc = pdoc->CharAt(charInDoc); styleByte = pdoc->StyleAt(charInDoc); ll->styleBitsSet |= styleByte; if (vstyle.viewEOL || (!IsEOLChar(chDoc))) { ll->chars[numCharsInLine] = chDoc; ll->styles[numCharsInLine] = static_cast<char>(styleByte & styleMask); ll->indicators[numCharsInLine] = static_cast<char>(styleByte & ~styleMask); if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseUpper) ll->chars[numCharsInLine] = static_cast<char>(toupper(chDoc)); else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) ll->chars[numCharsInLine] = static_cast<char>(tolower(chDoc)); numCharsInLine++; if (!IsEOLChar(chDoc)) numCharsBeforeEOL++; } } ll->xHighlightGuide = 0; // Extra element at the end of the line to hold end x position and act as ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character ll->styles[numCharsInLine] = styleByte; // For eolFilled ll->indicators[numCharsInLine] = 0; // Layout the line, determining the position of each character, // with an extra element at the end for the end of the line. int startseg = 0; // Start of the current segment, in char. number int startsegx = 0; // Start of the current segment, in pixels ll->positions[0] = 0; unsigned int tabWidth = vstyle.spaceWidth * pdoc->tabInChars; bool lastSegItalics = false; Font &ctrlCharsFont = vstyle.styles[STYLE_CONTROLCHAR].font; int ctrlCharWidth[32] = {0}; bool isControlNext = IsControlCharacter(ll->chars[0]); int trailBytes = 0; bool isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars, numCharsInLine, trailBytes); for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) { bool isControl = isControlNext; isControlNext = IsControlCharacter(ll->chars[charInLine + 1]); bool isBadUTF = isBadUTFNext; isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars + charInLine + 1, numCharsInLine - charInLine - 1, trailBytes); if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) || isControl || isControlNext || isBadUTF || isBadUTFNext) { ll->positions[startseg] = 0; if (vstyle.styles[ll->styles[charInLine]].visible) { if (isControl) { if (ll->chars[charInLine] == '\t') { ll->positions[charInLine + 1] = ((((startsegx + 2) / tabWidth) + 1) * tabWidth) - startsegx; } else if (controlCharSymbol < 32) { if (ctrlCharWidth[ll->chars[charInLine]] == 0) { const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]); // +3 For a blank on front and rounded edge each side: ctrlCharWidth[ll->chars[charInLine]] = surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3; } ll->positions[charInLine + 1] = ctrlCharWidth[ll->chars[charInLine]]; } else { char cc[2] = { static_cast<char>(controlCharSymbol), '\0' }; surface->MeasureWidths(ctrlCharsFont, cc, 1, ll->positions + startseg + 1); } lastSegItalics = false; } else if (isBadUTF) { char hexits[4]; sprintf(hexits, "x%2X", ll->chars[charInLine] & 0xff); ll->positions[charInLine + 1] = surface->WidthText(ctrlCharsFont, hexits, istrlen(hexits)) + 3; } else { // Regular character int lenSeg = charInLine - startseg + 1; if ((lenSeg == 1) && (' ' == ll->chars[startseg])) { lastSegItalics = false; // Over half the segments are single characters and of these about half are space characters. ll->positions[charInLine + 1] = vstyle.styles[ll->styles[charInLine]].spaceWidth; } else { lastSegItalics = vstyle.styles[ll->styles[charInLine]].italic; posCache.MeasureWidths(surface, vstyle, ll->styles[charInLine], ll->chars + startseg, lenSeg, ll->positions + startseg + 1); } } } else { // invisible for (int posToZero = startseg; posToZero <= (charInLine + 1); posToZero++) { ll->positions[posToZero] = 0; } } for (int posToIncrease = startseg; posToIncrease <= (charInLine + 1); posToIncrease++) { ll->positions[posToIncrease] += startsegx; } startsegx = ll->positions[charInLine + 1]; startseg = charInLine + 1; } } // Small hack to make lines that end with italics not cut off the edge of the last character if ((startseg > 0) && lastSegItalics) { ll->positions[startseg] += 2; } ll->numCharsInLine = numCharsInLine; ll->numCharsBeforeEOL = numCharsBeforeEOL; ll->validity = LineLayout::llPositions; } // Hard to cope when too narrow, so just assume there is space if (width < 20) { width = 20; } if ((ll->validity == LineLayout::llPositions) || (ll->widthLine != width)) { ll->widthLine = width; if (width == LineLayout::wrapWidthInfinite) { ll->lines = 1; } else if (width > ll->positions[ll->numCharsInLine]) { // Simple common case where line does not need wrapping. ll->lines = 1; } else { if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) { width -= vstyle.aveCharWidth; // take into account the space for end wrap mark } ll->wrapIndent = wrapAddIndent; if (wrapIndentMode != SC_WRAPINDENT_FIXED) for (int i = 0; i < ll->numCharsInLine; i++) { if (!IsSpaceOrTab(ll->chars[i])) { ll->wrapIndent += ll->positions[i]; // Add line indent break; } } // Check for text width minimum if (ll->wrapIndent > width - static_cast<int>(vstyle.aveCharWidth) * 15) ll->wrapIndent = wrapAddIndent; // Check for wrapIndent minimum if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < static_cast<int>(vstyle.aveCharWidth))) ll->wrapIndent = vstyle.aveCharWidth; // Indent to show start visual ll->lines = 0; // Calculate line start positions based upon width. int lastGoodBreak = 0; int lastLineStart = 0; int startOffset = 0; int p = 0; while (p < ll->numCharsInLine) { if ((ll->positions[p + 1] - startOffset) >= width) { if (lastGoodBreak == lastLineStart) { // Try moving to start of last character if (p > 0) { lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1) - posLineStart; } if (lastGoodBreak == lastLineStart) { // Ensure at least one character on line. lastGoodBreak = pdoc->MovePositionOutsideChar(lastGoodBreak + posLineStart + 1, 1) - posLineStart; } } lastLineStart = lastGoodBreak; ll->lines++; ll->SetLineStart(ll->lines, lastGoodBreak); startOffset = ll->positions[lastGoodBreak]; // take into account the space for start wrap mark and indent startOffset -= ll->wrapIndent; p = lastGoodBreak + 1; continue; } if (p > 0) { if (wrapState == eWrapChar) { lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1) - posLineStart; p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart; continue; } else if (ll->styles[p] != ll->styles[p - 1]) { lastGoodBreak = p; } else if (IsSpaceOrTab(ll->chars[p - 1]) && !IsSpaceOrTab(ll->chars[p])) { lastGoodBreak = p; } } p++; } ll->lines++; } ll->validity = LineLayout::llLines; } } ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw, bool main) { return main ? (primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated) : vsDraw.selAdditionalBackground.allocated; } ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) { if (inSelection == 1) { if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { return SelectionBackground(vsDraw, true); } } else if (inSelection == 2) { if (vsDraw.selbackset && (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)) { return SelectionBackground(vsDraw, false); } } else { if ((vsDraw.edgeState == EDGE_BACKGROUND) && (i >= ll->edgeColumn) && !IsEOLChar(ll->chars[i])) return vsDraw.edgecolour.allocated; if (inHotspot && vsDraw.hotspotBackgroundSet) return vsDraw.hotspotBackground.allocated; if (overrideBackground && (((styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) || (vsDraw.styles[styleMain].back.allocated.AsLong() == vsDraw.styles[ll->bracePreviousStyles[0]].back.allocated.AsLong()))) return background; } return vsDraw.styles[styleMain].back.allocated; } void Editor::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight) { Point from(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0); PRectangle rcCopyArea(start + 1, rcSegment.top, start + 2, rcSegment.bottom); surface->Copy(rcCopyArea, from, highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide); } void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourAllocated wrapColour) { surface->PenColour(wrapColour); enum { xa = 1 }; // gap before start int w = rcPlace.right - rcPlace.left - xa - 1; bool xStraight = isEndMarker; // x-mirrored symbol for start marker bool yStraight = true; //bool yStraight= isEndMarker; // comment in for start marker y-mirrowed int x0 = xStraight ? rcPlace.left : rcPlace.right - 1; int y0 = yStraight ? rcPlace.top : rcPlace.bottom - 1; int dy = (rcPlace.bottom - rcPlace.top) / 5; int y = (rcPlace.bottom - rcPlace.top) / 2 + dy; struct Relative { Surface *surface; int xBase; int xDir; int yBase; int yDir; void MoveTo(int xRelative, int yRelative) { surface->MoveTo(xBase + xDir * xRelative, yBase + yDir * yRelative); } void LineTo(int xRelative, int yRelative) { surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative); } }; Relative rel = {surface, x0, xStraight ? 1 : -1, y0, yStraight ? 1 : -1}; // arrow head rel.MoveTo(xa, y); rel.LineTo(xa + 2*w / 3, y - dy); rel.MoveTo(xa, y); rel.LineTo(xa + 2*w / 3, y + dy); // arrow body rel.MoveTo(xa, y); rel.LineTo(xa + w, y); rel.LineTo(xa + w, y - 2 * dy); rel.LineTo(xa - 1, // on windows lineto is exclusive endpoint, perhaps GTK not... y - 2 * dy); } static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourAllocated fill, int alpha) { if (alpha != SC_ALPHA_NOALPHA) { surface->AlphaRectangle(rc, 0, fill, alpha, fill, alpha, 0); } } void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, const char *s, ColourAllocated textBack, ColourAllocated textFore, bool twoPhaseDraw) { if (!twoPhaseDraw) { surface->FillRectangle(rcSegment, textBack); } Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; int normalCharHeight = surface->Ascent(ctrlCharsFont) - surface->InternalLeading(ctrlCharsFont); PRectangle rcCChar = rcSegment; rcCChar.left = rcCChar.left + 1; rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1; PRectangle rcCentral = rcCChar; rcCentral.top++; rcCentral.bottom--; surface->FillRectangle(rcCentral, textFore); PRectangle rcChar = rcCChar; rcChar.left++; rcChar.right--; surface->DrawTextClipped(rcChar, ctrlCharsFont, rcSegment.top + vsDraw.maxAscent, s, istrlen(s), textBack, textFore); } void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, int line, int lineEnd, int xStart, int subLine, int subLineStart, bool overrideBackground, ColourAllocated background, bool drawWrapMarkEnd, ColourAllocated wrapColour) { const int posLineStart = pdoc->LineStart(line); const int styleMask = pdoc->stylingBitsMask; PRectangle rcSegment = rcLine; const bool lastSubLine = subLine == (ll->lines - 1); int virtualSpace = 0; if (lastSubLine) { const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth); virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * spaceWidth; } // Fill in a PRectangle representing the end of line characters int xEol = ll->positions[lineEnd] - subLineStart; // Fill the virtual space and show selections within it if (virtualSpace) { rcSegment.left = xEol + xStart; rcSegment.right = xEol + xStart + virtualSpace; surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated); if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) { SelectionSegment virtualSpaceRange(SelectionPosition(pdoc->LineEnd(line)), SelectionPosition(pdoc->LineEnd(line), sel.VirtualSpaceFor(pdoc->LineEnd(line)))); for (size_t r=0; r<sel.Count(); r++) { int alpha = (r == sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; if (alpha == SC_ALPHA_NOALPHA) { SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange); if (!portion.Empty()) { const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth); rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left); rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right); surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, r == sel.Main())); } } } } } int posAfterLineEnd = pdoc->LineStart(line + 1); int eolInSelection = (subLine == (ll->lines - 1)) ? sel.InSelectionForEOL(posAfterLineEnd) : 0; int alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; // Draw the [CR], [LF], or [CR][LF] blobs if visible line ends are on int blobsWidth = 0; if (lastSubLine) { for (int eolPos=ll->numCharsBeforeEOL; eolPos<ll->numCharsInLine; eolPos++) { rcSegment.left = xStart + ll->positions[eolPos] - subLineStart + virtualSpace; rcSegment.right = xStart + ll->positions[eolPos+1] - subLineStart + virtualSpace; blobsWidth += rcSegment.Width(); const char *ctrlChar = ControlCharacterString(ll->chars[eolPos]); int inSelection = 0; bool inHotspot = false; int styleMain = ll->styles[eolPos]; ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, eolPos, ll); ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated; if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) { if (alpha == SC_ALPHA_NOALPHA) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { surface->FillRectangle(rcSegment, textBack); SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha); } } else { surface->FillRectangle(rcSegment, textBack); } DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw); } } // Draw the eol-is-selected rectangle rcSegment.left = xEol + xStart + virtualSpace + blobsWidth; rcSegment.right = xEol + xStart + virtualSpace + blobsWidth + vsDraw.aveCharWidth; if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { if (overrideBackground) { surface->FillRectangle(rcSegment, background); } else if (line < pdoc->LinesTotal() - 1) { surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated); } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated); } else { surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated); } if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha); } } // Fill the remainder of the line rcSegment.left = xEol + xStart + virtualSpace + blobsWidth + vsDraw.aveCharWidth; if (rcSegment.left < rcLine.left) rcSegment.left = rcLine.left; rcSegment.right = rcLine.right; if (!hideSelection && vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { if (overrideBackground) { surface->FillRectangle(rcSegment, background); } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated); } else { surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated); } if (!hideSelection && vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha); } } if (drawWrapMarkEnd) { PRectangle rcPlace = rcSegment; if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) { rcPlace.left = xEol + xStart + virtualSpace; rcPlace.right = rcPlace.left + vsDraw.aveCharWidth; } else { // draw left of the right text margin, to avoid clipping by the current clip rect rcPlace.right = rcLine.right - vs.rightMarginWidth; rcPlace.left = rcPlace.right - vsDraw.aveCharWidth; } DrawWrapMarker(surface, rcPlace, true, wrapColour); } } void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under) { // Draw decorators const int posLineStart = pdoc->LineStart(line); const int lineStart = ll->LineStart(subLine); const int subLineStart = ll->positions[lineStart]; const int posLineEnd = posLineStart + lineEnd; if (!under) { // Draw indicators // foreach indicator... for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) { if (!(mask & ll->styleBitsSet)) { mask <<= 1; continue; } int startPos = -1; // foreach style pos in line... for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { // look for starts... if (startPos < 0) { // NOT in indicator run, looking for START if (indicPos < lineEnd && (ll->indicators[indicPos] & mask)) startPos = indicPos; } // ... or ends if (startPos >= 0) { // IN indicator run, looking for END if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) { // AT end of indicator run, DRAW it! PRectangle rcIndic( ll->positions[startPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent, ll->positions[indicPos] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent + 3); vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine); // RESET control var startPos = -1; } } } mask <<= 1; } } for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) { if (under == vsDraw.indicators[deco->indicator].under) { int startPos = posLineStart + lineStart; if (!deco->rs.ValueAt(startPos)) { startPos = deco->rs.EndRun(startPos); } while ((startPos < posLineEnd) && (deco->rs.ValueAt(startPos))) { int endPos = deco->rs.EndRun(startPos); if (endPos > posLineEnd) endPos = posLineEnd; PRectangle rcIndic( ll->positions[startPos - posLineStart] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent, ll->positions[endPos - posLineStart] + xStart - subLineStart, rcLine.top + vsDraw.maxAscent + 3); vsDraw.indicators[deco->indicator].Draw(surface, rcIndic, rcLine); startPos = deco->rs.EndRun(endPos); } } } } void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { int indent = pdoc->GetLineIndentation(line) * vsDraw.spaceWidth; PRectangle rcSegment = rcLine; int annotationLine = subLine - ll->lines; const StyledText stAnnotation = pdoc->AnnotationStyledText(line); if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) { surface->FillRectangle(rcSegment, vsDraw.styles[0].back.allocated); if (vs.annotationVisible == ANNOTATION_BOXED) { // Only care about calculating width if need to draw box int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation); widthAnnotation += vsDraw.spaceWidth * 2; // Margins rcSegment.left = xStart + indent; rcSegment.right = rcSegment.left + widthAnnotation; surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore.allocated); } else { rcSegment.left = xStart; } const int annotationLines = pdoc->AnnotationLines(line); size_t start = 0; size_t lengthAnnotation = stAnnotation.LineLength(start); int lineInAnnotation = 0; while ((lineInAnnotation < annotationLine) && (start < stAnnotation.length)) { start += lengthAnnotation + 1; lengthAnnotation = stAnnotation.LineLength(start); lineInAnnotation++; } PRectangle rcText = rcSegment; if (vs.annotationVisible == ANNOTATION_BOXED) { surface->FillRectangle(rcText, vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back.allocated); rcText.left += vsDraw.spaceWidth; } DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent, stAnnotation, start, lengthAnnotation); if (vs.annotationVisible == ANNOTATION_BOXED) { surface->MoveTo(rcSegment.left, rcSegment.top); surface->LineTo(rcSegment.left, rcSegment.bottom); surface->MoveTo(rcSegment.right, rcSegment.top); surface->LineTo(rcSegment.right, rcSegment.bottom); if (subLine == ll->lines) { surface->MoveTo(rcSegment.left, rcSegment.top); surface->LineTo(rcSegment.right, rcSegment.top); } if (subLine == ll->lines+annotationLines-1) { surface->MoveTo(rcSegment.left, rcSegment.bottom - 1); surface->LineTo(rcSegment.right, rcSegment.bottom - 1); } } } } void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { PRectangle rcSegment = rcLine; // Using one font for all control characters so it can be controlled independently to ensure // the box goes around the characters tightly. Seems to be no way to work out what height // is taken by an individual character - internal leading gives varying results. Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; // See if something overrides the line background color: Either if caret is on the line // and background color is set for that, or if a marker is defined that forces its background // color onto the line, or if a marker is defined but has no selection margin in which to // display itself (as long as it's not an SC_MARK_EMPTY marker). These are checked in order // with the earlier taking precedence. When multiple markers cause background override, // the color for the highest numbered one is used. bool overrideBackground = false; ColourAllocated background; if ((caret.active || vsDraw.showCaretLineBackgroundAlways) && vsDraw.showCaretLineBackground && (vsDraw.caretLineAlpha == SC_ALPHA_NOALPHA) && ll->containsCaret) { overrideBackground = true; background = vsDraw.caretLineBackground.allocated; } if (!overrideBackground) { int marks = pdoc->GetMark(line); for (int markBit = 0; (markBit < 32) && marks; markBit++) { if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) && (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { background = vsDraw.markers[markBit].back.allocated; overrideBackground = true; } marks >>= 1; } } if (!overrideBackground) { if (vsDraw.maskInLine) { int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; if (marksMasked) { for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) && (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { overrideBackground = true; background = vsDraw.markers[markBit].back.allocated; } marksMasked >>= 1; } } } } bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) && (!overrideBackground) && (vsDraw.whitespaceBackgroundSet); bool inIndentation = subLine == 0; // Do not handle indentation except on first subline. int indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth; int posLineStart = pdoc->LineStart(line); int startseg = ll->LineStart(subLine); int subLineStart = ll->positions[startseg]; if (subLine >= ll->lines) { DrawAnnotation(surface, vsDraw, line, xStart, rcLine, ll, subLine); return; // No further drawing } int lineStart = 0; int lineEnd = 0; if (subLine < ll->lines) { lineStart = ll->LineStart(subLine); lineEnd = ll->LineStart(subLine + 1); if (subLine == ll->lines - 1) { lineEnd = ll->numCharsBeforeEOL; } } ColourAllocated wrapColour = vsDraw.styles[STYLE_DEFAULT].fore.allocated; if (vsDraw.whitespaceForegroundSet) wrapColour = vsDraw.whitespaceForeground.allocated; bool drawWrapMarkEnd = false; if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) { if (subLine + 1 < ll->lines) { drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0; } } if (ll->wrapIndent != 0) { bool continuedWrapLine = false; if (subLine < ll->lines) { continuedWrapLine = ll->LineStart(subLine) != 0; } if (continuedWrapLine) { // draw continuation rect PRectangle rcPlace = rcSegment; rcPlace.left = ll->positions[startseg] + xStart - subLineStart; rcPlace.right = rcPlace.left + ll->wrapIndent; // default bgnd here.. surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[STYLE_DEFAULT].back.allocated); // main line style would be below but this would be inconsistent with end markers // also would possibly not be the style at wrap point //int styleMain = ll->styles[lineStart]; //surface->FillRectangle(rcPlace, vsDraw.styles[styleMain].back.allocated); if (wrapVisualFlags & SC_WRAPVISUALFLAG_START) { if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_START_BY_TEXT) rcPlace.left = rcPlace.right - vsDraw.aveCharWidth; else rcPlace.right = rcPlace.left + vsDraw.aveCharWidth; DrawWrapMarker(surface, rcPlace, false, wrapColour); } xStart += ll->wrapIndent; } } bool selBackDrawn = vsDraw.selbackset && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)); // Does not take margin into account but not significant int xStartVisible = subLineStart - xStart; ll->psel = &sel; BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible, selBackDrawn); int next = bfBack.First(); // Background drawing loop while (twoPhaseDraw && (next < lineEnd)) { startseg = next; next = bfBack.Next(); int i = next - 1; int iDoc = i + posLineStart; rcSegment.left = ll->positions[startseg] + xStart - subLineStart; rcSegment.right = ll->positions[i + 1] + xStart - subLineStart; // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) { // Clip to line rectangle, since may have a huge position which will not work with some platforms rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left); rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right); int styleMain = ll->styles[i]; const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc); bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll); if (ll->chars[i] == '\t') { // Tab display if (drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) textBack = vsDraw.whitespaceBackground.allocated; surface->FillRectangle(rcSegment, textBack); } else if (IsControlCharacter(ll->chars[i])) { // Control character display inIndentation = false; surface->FillRectangle(rcSegment, textBack); } else { // Normal text display surface->FillRectangle(rcSegment, textBack); if (vsDraw.viewWhitespace != wsInvisible || (inIndentation && vsDraw.viewIndentationGuides == ivReal)) { for (int cpos = 0; cpos <= i - startseg; cpos++) { if (ll->chars[cpos + startseg] == ' ') { if (drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart, rcSegment.top, ll->positions[cpos + startseg + 1] + xStart - subLineStart, rcSegment.bottom); surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground.allocated); } } else { inIndentation = false; } } } } } else if (rcSegment.left > rcLine.right) { break; } } if (twoPhaseDraw) { DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, xStart, subLine, subLineStart, overrideBackground, background, drawWrapMarkEnd, wrapColour); } DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true); if (vsDraw.edgeState == EDGE_LINE) { int edgeX = theEdge * vsDraw.spaceWidth; rcSegment.left = edgeX + xStart; rcSegment.right = rcSegment.left + 1; surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated); } // Draw underline mark as part of background if not transparent int marks = pdoc->GetMark(line); int markBit; for (markBit = 0; (markBit < 32) && marks; markBit++) { if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) && (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { PRectangle rcUnderline = rcLine; rcUnderline.top = rcUnderline.bottom - 2; surface->FillRectangle(rcUnderline, vsDraw.markers[markBit].back.allocated); } marks >>= 1; } inIndentation = subLine == 0; // Do not handle indentation except on first subline. // Foreground drawing loop BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible, ((!twoPhaseDraw && selBackDrawn) || vsDraw.selforeset)); next = bfFore.First(); while (next < lineEnd) { startseg = next; next = bfFore.Next(); int i = next - 1; int iDoc = i + posLineStart; rcSegment.left = ll->positions[startseg] + xStart - subLineStart; rcSegment.right = ll->positions[i + 1] + xStart - subLineStart; // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) { int styleMain = ll->styles[i]; ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated; Font &textFont = vsDraw.styles[styleMain].font; //hotspot foreground if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) { if (vsDraw.hotspotForegroundSet) textFore = vsDraw.hotspotForeground.allocated; } const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc); if (inSelection && (vsDraw.selforeset)) { textFore = (inSelection == 1) ? vsDraw.selforeground.allocated : vsDraw.selAdditionalForeground.allocated; } bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll); if (ll->chars[i] == '\t') { // Tab display if (!twoPhaseDraw) { if (drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) textBack = vsDraw.whitespaceBackground.allocated; surface->FillRectangle(rcSegment, textBack); } if ((vsDraw.viewWhitespace != wsInvisible) || (inIndentation && vsDraw.viewIndentationGuides != ivNone)) { if (vsDraw.whitespaceForegroundSet) textFore = vsDraw.whitespaceForeground.allocated; surface->PenColour(textFore); } if (inIndentation && vsDraw.viewIndentationGuides == ivReal) { for (int xIG = ll->positions[i] / indentWidth * indentWidth; xIG < ll->positions[i + 1]; xIG += indentWidth) { if (xIG >= ll->positions[i] && xIG > 0) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIG + xStart, rcSegment, (ll->xHighlightGuide == xIG)); } } } if (vsDraw.viewWhitespace != wsInvisible) { if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2); } } } else if (IsControlCharacter(ll->chars[i])) { // Control character display inIndentation = false; if (controlCharSymbol < 32) { // Draw the character const char *ctrlChar = ControlCharacterString(ll->chars[i]); DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw); } else { char cc[2] = { static_cast<char>(controlCharSymbol), '\0' }; surface->DrawTextNoClip(rcSegment, ctrlCharsFont, rcSegment.top + vsDraw.maxAscent, cc, 1, textBack, textFore); } } else if ((i == startseg) && (static_cast<unsigned char>(ll->chars[i]) >= 0x80) && IsUnicodeMode()) { // A single byte >= 0x80 in UTF-8 is a bad byte and is displayed as its hex value char hexits[4]; sprintf(hexits, "x%2X", ll->chars[i] & 0xff); DrawTextBlob(surface, vsDraw, rcSegment, hexits, textBack, textFore, twoPhaseDraw); } else { // Normal text display if (vsDraw.styles[styleMain].visible) { if (twoPhaseDraw) { surface->DrawTextTransparent(rcSegment, textFont, rcSegment.top + vsDraw.maxAscent, ll->chars + startseg, i - startseg + 1, textFore); } else { surface->DrawTextNoClip(rcSegment, textFont, rcSegment.top + vsDraw.maxAscent, ll->chars + startseg, i - startseg + 1, textFore, textBack); } } if (vsDraw.viewWhitespace != wsInvisible || (inIndentation && vsDraw.viewIndentationGuides != ivNone)) { for (int cpos = 0; cpos <= i - startseg; cpos++) { if (ll->chars[cpos + startseg] == ' ') { if (vsDraw.viewWhitespace != wsInvisible) { if (vsDraw.whitespaceForegroundSet) textFore = vsDraw.whitespaceForeground.allocated; if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2; if (!twoPhaseDraw && drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { textBack = vsDraw.whitespaceBackground.allocated; PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart, rcSegment.top, ll->positions[cpos + startseg + 1] + xStart - subLineStart, rcSegment.bottom); surface->FillRectangle(rcSpace, textBack); } PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0); rcDot.right = rcDot.left + vs.whitespaceSize; rcDot.bottom = rcDot.top + vs.whitespaceSize; surface->FillRectangle(rcDot, textFore); } } if (inIndentation && vsDraw.viewIndentationGuides == ivReal) { int startSpace = ll->positions[cpos + startseg]; if (startSpace > 0 && (startSpace % indentWidth == 0)) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, startSpace + xStart, rcSegment, (ll->xHighlightGuide == ll->positions[cpos + startseg])); } } } else { inIndentation = false; } } } } if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd) { PRectangle rcUL = rcSegment; rcUL.top = rcUL.top + vsDraw.maxAscent + 1; rcUL.bottom = rcUL.top + 1; if (vsDraw.hotspotForegroundSet) surface->FillRectangle(rcUL, vsDraw.hotspotForeground.allocated); else surface->FillRectangle(rcUL, textFore); } else if (vsDraw.styles[styleMain].underline) { PRectangle rcUL = rcSegment; rcUL.top = rcUL.top + vsDraw.maxAscent + 1; rcUL.bottom = rcUL.top + 1; surface->FillRectangle(rcUL, textFore); } } else if (rcSegment.left > rcLine.right) { break; } } if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth) && (subLine == 0)) { int indentSpace = pdoc->GetLineIndentation(line); int xStartText = ll->positions[pdoc->GetLineIndentPosition(line) - posLineStart]; // Find the most recent line with some text int lineLastWithText = line; while (lineLastWithText > Platform::Maximum(line-20, 0) && pdoc->IsWhiteLine(lineLastWithText)) { lineLastWithText--; } if (lineLastWithText < line) { xStartText = 100000; // Don't limit to visible indentation on empty line // This line is empty, so use indentation of last line with text int indentLastWithText = pdoc->GetLineIndentation(lineLastWithText); int isFoldHeader = pdoc->GetLevel(lineLastWithText) & SC_FOLDLEVELHEADERFLAG; if (isFoldHeader) { // Level is one more level than parent indentLastWithText += pdoc->IndentSize(); } if (vsDraw.viewIndentationGuides == ivLookForward) { // In viLookForward mode, previous line only used if it is a fold header if (isFoldHeader) { indentSpace = Platform::Maximum(indentSpace, indentLastWithText); } } else { // viLookBoth indentSpace = Platform::Maximum(indentSpace, indentLastWithText); } } int lineNextWithText = line; while (lineNextWithText < Platform::Minimum(line+20, pdoc->LinesTotal()) && pdoc->IsWhiteLine(lineNextWithText)) { lineNextWithText++; } if (lineNextWithText > line) { // This line is empty, so use indentation of last line with text indentSpace = Platform::Maximum(indentSpace, pdoc->GetLineIndentation(lineNextWithText)); } for (int indentPos = pdoc->IndentSize(); indentPos < indentSpace; indentPos += pdoc->IndentSize()) { int xIndent = indentPos * vsDraw.spaceWidth; if (xIndent < xStartText) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } } } DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, false); // End of the drawing of the current line if (!twoPhaseDraw) { DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, xStart, subLine, subLineStart, overrideBackground, background, drawWrapMarkEnd, wrapColour); } if (!hideSelection && ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha != SC_ALPHA_NOALPHA))) { // For each selection draw int virtualSpaces = 0; if (subLine == (ll->lines - 1)) { virtualSpaces = sel.VirtualSpaceFor(pdoc->LineEnd(line)); } SelectionPosition posStart(posLineStart); SelectionPosition posEnd(posLineStart + lineEnd, virtualSpaces); SelectionSegment virtualSpaceRange(posStart, posEnd); for (size_t r=0; r<sel.Count(); r++) { int alpha = (r == sel.Main()) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; if (alpha != SC_ALPHA_NOALPHA) { SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange); if (!portion.Empty()) { const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth); rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left); rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right); SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, r == sel.Main()), alpha); } } } } // Draw any translucent whole line states rcSegment.left = xStart; rcSegment.right = rcLine.right - 1; if ((caret.active || vsDraw.showCaretLineBackgroundAlways) && vsDraw.showCaretLineBackground && ll->containsCaret) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha); } marks = pdoc->GetMark(line); for (markBit = 0; (markBit < 32) && marks; markBit++) { if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); } else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) { PRectangle rcUnderline = rcSegment; rcUnderline.top = rcUnderline.bottom - 2; SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); } marks >>= 1; } if (vsDraw.maskInLine) { int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; if (marksMasked) { for (markBit = 0; (markBit < 32) && marksMasked; markBit++) { if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); } marksMasked >>= 1; } } } } void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour) { int lineStart = ll->LineStart(subLine); int posBefore = posCaret; int posAfter = MovePositionOutsideChar(posCaret + 1, 1); int numCharsToDraw = posAfter - posCaret; // Work out where the starting and ending offsets are. We need to // see if the previous character shares horizontal space, such as a // glyph / combining character. If so we'll need to draw that too. int offsetFirstChar = offset; int offsetLastChar = offset + (posAfter - posCaret); while ((offsetLastChar - numCharsToDraw) >= lineStart) { if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - numCharsToDraw]) > 0) { // The char does not share horizontal space break; } // Char shares horizontal space, update the numChars to draw // Update posBefore to point to the prev char posBefore = MovePositionOutsideChar(posBefore - 1, -1); numCharsToDraw = posAfter - posBefore; offsetFirstChar = offset - (posCaret - posBefore); } // See if the next character shares horizontal space, if so we'll // need to draw that too. numCharsToDraw = offsetLastChar - offsetFirstChar; while ((offsetLastChar < ll->LineStart(subLine + 1)) && (offsetLastChar <= ll->numCharsInLine)) { // Update posAfter to point to the 2nd next char, this is where // the next character ends, and 2nd next begins. We'll need // to compare these two posBefore = posAfter; posAfter = MovePositionOutsideChar(posAfter + 1, 1); offsetLastChar = offset + (posAfter - posCaret); if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - (posAfter - posBefore)]) > 0) { // The char does not share horizontal space break; } // Char shares horizontal space, update the numChars to draw numCharsToDraw = offsetLastChar - offsetFirstChar; } // We now know what to draw, update the caret drawing rectangle rcCaret.left = ll->positions[offsetFirstChar] - ll->positions[lineStart] + xStart; rcCaret.right = ll->positions[offsetFirstChar+numCharsToDraw] - ll->positions[lineStart] + xStart; // Adjust caret position to take into account any word wrapping symbols. if ((ll->wrapIndent != 0) && (lineStart != 0)) { int wordWrapCharWidth = ll->wrapIndent; rcCaret.left += wordWrapCharWidth; rcCaret.right += wordWrapCharWidth; } // This character is where the caret block is, we override the colours // (inversed) for drawing the caret here. int styleMain = ll->styles[offsetFirstChar]; surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font, rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar, numCharsToDraw, vsDraw.styles[styleMain].back.allocated, caretColour); } void Editor::RefreshPixMaps(Surface *surfaceWindow) { if (!pixmapSelPattern->Initialised()) { const int patternSize = 8; pixmapSelPattern->InitPixMap(patternSize, patternSize, surfaceWindow, wMain.GetID()); // This complex procedure is to reproduce the checkerboard dithered pattern used by windows // for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half // way between the chrome colour and the chrome highlight colour making a nice transition // between the window chrome and the content area. And it works in low colour depths. PRectangle rcPattern(0, 0, patternSize, patternSize); // Initialize default colours based on the chrome colour scheme. Typically the highlight is white. ColourAllocated colourFMFill = vs.selbar.allocated; ColourAllocated colourFMStripes = vs.selbarlight.allocated; if (!(vs.selbarlight.desired == ColourDesired(0xff, 0xff, 0xff))) { // User has chosen an unusual chrome colour scheme so just use the highlight edge colour. // (Typically, the highlight colour is white.) colourFMFill = vs.selbarlight.allocated; } if (vs.foldmarginColourSet) { // override default fold margin colour colourFMFill = vs.foldmarginColour.allocated; } if (vs.foldmarginHighlightColourSet) { // override default fold margin highlight colour colourFMStripes = vs.foldmarginHighlightColour.allocated; } pixmapSelPattern->FillRectangle(rcPattern, colourFMFill); pixmapSelPattern->PenColour(colourFMStripes); for (int stripe = 0; stripe < patternSize; stripe++) { // Alternating 1 pixel stripes is same as checkerboard. pixmapSelPattern->MoveTo(0, stripe * 2); pixmapSelPattern->LineTo(patternSize, stripe * 2 - patternSize); } } if (!pixmapIndentGuide->Initialised()) { // 1 extra pixel in height so can handle odd/even positions and so produce a continuous line pixmapIndentGuide->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID()); pixmapIndentGuideHighlight->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID()); PRectangle rcIG(0, 0, 1, vs.lineHeight); pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back.allocated); pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore.allocated); pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back.allocated); pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore.allocated); for (int stripe = 1; stripe < vs.lineHeight + 1; stripe += 2) { pixmapIndentGuide->MoveTo(0, stripe); pixmapIndentGuide->LineTo(2, stripe); pixmapIndentGuideHighlight->MoveTo(0, stripe); pixmapIndentGuideHighlight->LineTo(2, stripe); } } if (bufferedDraw) { if (!pixmapLine->Initialised()) { PRectangle rcClient = GetClientRectangle(); pixmapLine->InitPixMap(rcClient.Width(), vs.lineHeight, surfaceWindow, wMain.GetID()); pixmapSelMargin->InitPixMap(vs.fixedColumnWidth, rcClient.Height(), surfaceWindow, wMain.GetID()); } } } void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { // When drag is active it is the only caret drawn bool drawDrag = posDrag.IsValid(); if (hideSelection && !drawDrag) return; const int posLineStart = pdoc->LineStart(lineDoc); // For each selection draw for (size_t r=0; (r<sel.Count()) || drawDrag; r++) { const bool mainCaret = r == sel.Main(); const SelectionPosition posCaret = (drawDrag ? posDrag : sel.Range(r).caret); const int offset = posCaret.Position() - posLineStart; const int spaceWidth = static_cast<int>(vsDraw.styles[ll->EndLineStyle()].spaceWidth); const int virtualOffset = posCaret.VirtualSpace() * spaceWidth; if (ll->InLine(offset, subLine) && offset <= ll->numCharsBeforeEOL) { int xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)]; if (ll->wrapIndent != 0) { int lineStart = ll->LineStart(subLine); if (lineStart != 0) // Wrapped xposCaret += ll->wrapIndent; } bool caretBlinkState = (caret.active && caret.on) || (!additionalCaretsBlink && !mainCaret); bool caretVisibleState = additionalCaretsVisible || mainCaret; if ((xposCaret >= 0) && (vsDraw.caretWidth > 0) && (vsDraw.caretStyle != CARETSTYLE_INVISIBLE) && ((posDrag.IsValid()) || (caretBlinkState && caretVisibleState))) { bool caretAtEOF = false; bool caretAtEOL = false; bool drawBlockCaret = false; int widthOverstrikeCaret; int caretWidthOffset = 0; PRectangle rcCaret = rcLine; if (posCaret.Position() == pdoc->Length()) { // At end of document caretAtEOF = true; widthOverstrikeCaret = vsDraw.aveCharWidth; } else if ((posCaret.Position() - posLineStart) >= ll->numCharsInLine) { // At end of line caretAtEOL = true; widthOverstrikeCaret = vsDraw.aveCharWidth; } else { widthOverstrikeCaret = ll->positions[offset + 1] - ll->positions[offset]; } if (widthOverstrikeCaret < 3) // Make sure its visible widthOverstrikeCaret = 3; if (xposCaret > 0) caretWidthOffset = 1; // Move back so overlaps both character cells. xposCaret += xStart; if (posDrag.IsValid()) { /* Dragging text, use a line caret */ rcCaret.left = xposCaret - caretWidthOffset; rcCaret.right = rcCaret.left + vsDraw.caretWidth; } else if (inOverstrike) { /* Overstrike (insert mode), use a modified bar caret */ rcCaret.top = rcCaret.bottom - 2; rcCaret.left = xposCaret + 1; rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1; } else if (vsDraw.caretStyle == CARETSTYLE_BLOCK) { /* Block caret */ rcCaret.left = xposCaret; if (!caretAtEOL && !caretAtEOF && (ll->chars[offset] != '\t') && !(IsControlCharacter(ll->chars[offset]))) { drawBlockCaret = true; rcCaret.right = xposCaret + widthOverstrikeCaret; } else { rcCaret.right = xposCaret + vsDraw.aveCharWidth; } } else { /* Line caret */ rcCaret.left = xposCaret - caretWidthOffset; rcCaret.right = rcCaret.left + vsDraw.caretWidth; } ColourAllocated caretColour = mainCaret ? vsDraw.caretcolour.allocated : vsDraw.additionalCaretColour.allocated; if (drawBlockCaret) { DrawBlockCaret(surface, vsDraw, ll, subLine, xStart, offset, posCaret.Position(), rcCaret, caretColour); } else { surface->FillRectangle(rcCaret, caretColour); } } } if (drawDrag) break; } } void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n", // paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom); StyleToPositionInView(PositionAfterArea(rcArea)); pixmapLine->Release(); RefreshStyleData(); RefreshPixMaps(surfaceWindow); PRectangle rcClient = GetClientRectangle(); //Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n", // rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); surfaceWindow->SetPalette(&palette, true); pixmapLine->SetPalette(&palette, !hasFocus); int screenLinePaintFirst = rcArea.top / vs.lineHeight; int xStart = vs.fixedColumnWidth - xOffset; int ypos = 0; if (!bufferedDraw) ypos += screenLinePaintFirst * vs.lineHeight; int yposScreen = screenLinePaintFirst * vs.lineHeight; bool paintAbandonedByStyling = paintState == paintAbandoned; if (needUpdateUI) { // Deselect palette by selecting a temporary palette Palette palTemp; surfaceWindow->SetPalette(&palTemp, true); NotifyUpdateUI(); needUpdateUI = false; RefreshStyleData(); RefreshPixMaps(surfaceWindow); surfaceWindow->SetPalette(&palette, true); pixmapLine->SetPalette(&palette, !hasFocus); } // Call priority lines wrap on a window of lines which are likely // to rendered with the following paint (that is wrap the visible // lines first). int startLineToWrap = cs.DocFromDisplay(topLine) - 5; if (startLineToWrap < 0) startLineToWrap = 0; if (WrapLines(false, startLineToWrap)) { // The wrapping process has changed the height of some lines so // abandon this paint for a complete repaint. if (AbandonPaint()) { return; } RefreshPixMaps(surfaceWindow); // In case pixmaps invalidated by scrollbar change } PLATFORM_ASSERT(pixmapSelPattern->Initialised()); if (paintState != paintAbandoned) { PaintSelMargin(surfaceWindow, rcArea); PRectangle rcRightMargin = rcClient; rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth; if (rcArea.Intersects(rcRightMargin)) { surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back.allocated); } } if (paintState == paintAbandoned) { // Either styling or NotifyUpdateUI noticed that painting is needed // outside the current painting rectangle //Platform::DebugPrintf("Abandoning paint\n"); if (wrapState != eWrapNone) { if (paintAbandonedByStyling) { // Styling has spilled over a line end, such as occurs by starting a multiline // comment. The width of subsequent text may have changed, so rewrap. NeedWrapping(cs.DocFromDisplay(topLine)); } } return; } //Platform::DebugPrintf("start display %d, offset = %d\n", pdoc->Length(), xOffset); // Do the painting if (rcArea.right > vs.fixedColumnWidth) { Surface *surface = surfaceWindow; if (bufferedDraw) { surface = pixmapLine; PLATFORM_ASSERT(pixmapLine->Initialised()); } surface->SetUnicodeMode(IsUnicodeMode()); surface->SetDBCSMode(CodePage()); int visibleLine = topLine + screenLinePaintFirst; SelectionPosition posCaret = sel.RangeMain().caret; if (posDrag.IsValid()) posCaret = posDrag; int lineCaret = pdoc->LineFromPosition(posCaret.Position()); // Remove selection margin from drawing area so text will not be drawn // on it in unbuffered mode. PRectangle rcTextArea = rcClient; rcTextArea.left = vs.fixedColumnWidth; rcTextArea.right -= vs.rightMarginWidth; surfaceWindow->SetClip(rcTextArea); // Loop on visible lines //double durLayout = 0.0; //double durPaint = 0.0; //double durCopy = 0.0; //ElapsedTime etWhole; int lineDocPrevious = -1; // Used to avoid laying out one document line multiple times AutoLineLayout ll(llc, 0); while (visibleLine < cs.LinesDisplayed() && yposScreen < rcArea.bottom) { int lineDoc = cs.DocFromDisplay(visibleLine); // Only visible lines should be handled by the code within the loop PLATFORM_ASSERT(cs.GetVisible(lineDoc)); int lineStartSet = cs.DisplayFromDoc(lineDoc); int subLine = visibleLine - lineStartSet; // Copy this line and its styles from the document into local arrays // and determine the x position at which each character starts. //ElapsedTime et; if (lineDoc != lineDocPrevious) { ll.Set(0); ll.Set(RetrieveLineLayout(lineDoc)); LayoutLine(lineDoc, surface, vs, ll, wrapWidth); lineDocPrevious = lineDoc; } //durLayout += et.Duration(true); if (ll) { ll->containsCaret = lineDoc == lineCaret; if (hideSelection) { ll->containsCaret = false; } GetHotSpotRange(ll->hsStart, ll->hsEnd); PRectangle rcLine = rcClient; rcLine.top = ypos; rcLine.bottom = ypos + vs.lineHeight; Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1)); // Highlight the current braces if any ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle), highlightGuideColumn * vs.spaceWidth); // Draw the line DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine); //durPaint += et.Duration(true); // Restore the previous styles for the brace highlights in case layout is in cache. ll->RestoreBracesHighlight(rangeLine, braces); bool expanded = cs.GetExpanded(lineDoc); // Paint the line above the fold if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) || (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { PRectangle rcFoldLine = rcLine; rcFoldLine.bottom = rcFoldLine.top + 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); } } // Paint the line below the fold if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED)) || (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { PRectangle rcFoldLine = rcLine; rcFoldLine.top = rcFoldLine.bottom - 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); } } DrawCarets(surface, vs, lineDoc, xStart, rcLine, ll, subLine); if (bufferedDraw) { Point from(vs.fixedColumnWidth, 0); PRectangle rcCopyArea(vs.fixedColumnWidth, yposScreen, rcClient.right, yposScreen + vs.lineHeight); surfaceWindow->Copy(rcCopyArea, from, *pixmapLine); } lineWidthMaxSeen = Platform::Maximum( lineWidthMaxSeen, ll->positions[ll->numCharsInLine]); //durCopy += et.Duration(true); } if (!bufferedDraw) { ypos += vs.lineHeight; } yposScreen += vs.lineHeight; visibleLine++; //gdk_flush(); } ll.Set(0); //if (durPaint < 0.00000001) // durPaint = 0.00000001; // Right column limit indicator PRectangle rcBeyondEOF = rcClient; rcBeyondEOF.left = vs.fixedColumnWidth; rcBeyondEOF.right = rcBeyondEOF.right; rcBeyondEOF.top = (cs.LinesDisplayed() - topLine) * vs.lineHeight; if (rcBeyondEOF.top < rcBeyondEOF.bottom) { surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back.allocated); if (vs.edgeState == EDGE_LINE) { int edgeX = theEdge * vs.spaceWidth; rcBeyondEOF.left = edgeX + xStart; rcBeyondEOF.right = rcBeyondEOF.left + 1; surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour.allocated); } } //Platform::DebugPrintf( //"Layout:%9.6g Paint:%9.6g Ratio:%9.6g Copy:%9.6g Total:%9.6g\n", //durLayout, durPaint, durLayout / durPaint, durCopy, etWhole.Duration()); NotifyPainted(); } } // Space (3 space characters) between line numbers and text when printing. #define lineNumberPrintSpace " " ColourDesired InvertedLight(ColourDesired orig) { unsigned int r = orig.GetRed(); unsigned int g = orig.GetGreen(); unsigned int b = orig.GetBlue(); unsigned int l = (r + g + b) / 3; // There is a better calculation for this that matches human eye unsigned int il = 0xff - l; if (l == 0) return ColourDesired(0xff, 0xff, 0xff); r = r * il / l; g = g * il / l; b = b * il / l; return ColourDesired(Platform::Minimum(r, 0xff), Platform::Minimum(g, 0xff), Platform::Minimum(b, 0xff)); } // This is mostly copied from the Paint method but with some things omitted // such as the margin markers, line numbers, selection and caret // Should be merged back into a combined Draw method. long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { if (!pfr) return 0; AutoSurface surface(pfr->hdc, this); if (!surface) return 0; AutoSurface surfaceMeasure(pfr->hdcTarget, this); if (!surfaceMeasure) { return 0; } // Can't use measurements cached for screen posCache.Clear(); ViewStyle vsPrint(vs); // Modify the view style for printing as do not normally want any of the transient features to be printed // Printing supports only the line number margin. int lineNumberIndex = -1; for (int margin = 0; margin < ViewStyle::margins; margin++) { if ((vsPrint.ms[margin].style == SC_MARGIN_NUMBER) && (vsPrint.ms[margin].width > 0)) { lineNumberIndex = margin; } else { vsPrint.ms[margin].width = 0; } } vsPrint.showMarkedLines = false; vsPrint.fixedColumnWidth = 0; vsPrint.zoomLevel = printMagnification; vsPrint.viewIndentationGuides = ivNone; // Don't show the selection when printing vsPrint.selbackset = false; vsPrint.selforeset = false; vsPrint.selAlpha = SC_ALPHA_NOALPHA; vsPrint.selAdditionalAlpha = SC_ALPHA_NOALPHA; vsPrint.whitespaceBackgroundSet = false; vsPrint.whitespaceForegroundSet = false; vsPrint.showCaretLineBackground = false; vsPrint.showCaretLineBackgroundAlways = false; // Set colours for printing according to users settings for (size_t sty = 0; sty < vsPrint.stylesSize; sty++) { if (printColourMode == SC_PRINT_INVERTLIGHT) { vsPrint.styles[sty].fore.desired = InvertedLight(vsPrint.styles[sty].fore.desired); vsPrint.styles[sty].back.desired = InvertedLight(vsPrint.styles[sty].back.desired); } else if (printColourMode == SC_PRINT_BLACKONWHITE) { vsPrint.styles[sty].fore.desired = ColourDesired(0, 0, 0); vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff); } else if (printColourMode == SC_PRINT_COLOURONWHITE) { vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff); } else if (printColourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) { if (sty <= STYLE_DEFAULT) { vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff); } } } // White background for the line numbers vsPrint.styles[STYLE_LINENUMBER].back.desired = ColourDesired(0xff, 0xff, 0xff); vsPrint.Refresh(*surfaceMeasure); // Determining width must hapen after fonts have been realised in Refresh int lineNumberWidth = 0; if (lineNumberIndex >= 0) { lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace)); vsPrint.ms[lineNumberIndex].width = lineNumberWidth; vsPrint.Refresh(*surfaceMeasure); // Recalculate fixedColumnWidth } // Ensure colours are set up vsPrint.RefreshColourPalette(palette, true); vsPrint.RefreshColourPalette(palette, false); int linePrintStart = pdoc->LineFromPosition(pfr->chrg.cpMin); int linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1; if (linePrintLast < linePrintStart) linePrintLast = linePrintStart; int linePrintMax = pdoc->LineFromPosition(pfr->chrg.cpMax); if (linePrintLast > linePrintMax) linePrintLast = linePrintMax; //Platform::DebugPrintf("Formatting lines=[%0d,%0d,%0d] top=%0d bottom=%0d line=%0d %0d\n", // linePrintStart, linePrintLast, linePrintMax, pfr->rc.top, pfr->rc.bottom, vsPrint.lineHeight, // surfaceMeasure->Height(vsPrint.styles[STYLE_LINENUMBER].font)); int endPosPrint = pdoc->Length(); if (linePrintLast < pdoc->LinesTotal()) endPosPrint = pdoc->LineStart(linePrintLast + 1); // Ensure we are styled to where we are formatting. pdoc->EnsureStyledTo(endPosPrint); int xStart = vsPrint.fixedColumnWidth + pfr->rc.left; int ypos = pfr->rc.top; int lineDoc = linePrintStart; int nPrintPos = pfr->chrg.cpMin; int visibleLine = 0; int widthPrint = pfr->rc.right - pfr->rc.left - vsPrint.fixedColumnWidth; if (printWrapState == eWrapNone) widthPrint = LineLayout::wrapWidthInfinite; while (lineDoc <= linePrintLast && ypos < pfr->rc.bottom) { // When printing, the hdc and hdcTarget may be the same, so // changing the state of surfaceMeasure may change the underlying // state of surface. Therefore, any cached state is discarded before // using each surface. surfaceMeasure->FlushCachedState(); // Copy this line and its styles from the document into local arrays // and determine the x position at which each character starts. LineLayout ll(8000); LayoutLine(lineDoc, surfaceMeasure, vsPrint, &ll, widthPrint); ll.containsCaret = false; PRectangle rcLine; rcLine.left = pfr->rc.left; rcLine.top = ypos; rcLine.right = pfr->rc.right - 1; rcLine.bottom = ypos + vsPrint.lineHeight; // When document line is wrapped over multiple display lines, find where // to start printing from to ensure a particular position is on the first // line of the page. if (visibleLine == 0) { int startWithinLine = nPrintPos - pdoc->LineStart(lineDoc); for (int iwl = 0; iwl < ll.lines - 1; iwl++) { if (ll.LineStart(iwl) <= startWithinLine && ll.LineStart(iwl + 1) >= startWithinLine) { visibleLine = -iwl; } } if (ll.lines > 1 && startWithinLine >= ll.LineStart(ll.lines - 1)) { visibleLine = -(ll.lines - 1); } } if (draw && lineNumberWidth && (ypos + vsPrint.lineHeight <= pfr->rc.bottom) && (visibleLine >= 0)) { char number[100]; sprintf(number, "%d" lineNumberPrintSpace, lineDoc + 1); PRectangle rcNumber = rcLine; rcNumber.right = rcNumber.left + lineNumberWidth; // Right justify rcNumber.left = rcNumber.right - surfaceMeasure->WidthText( vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number)); surface->FlushCachedState(); surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font, ypos + vsPrint.maxAscent, number, istrlen(number), vsPrint.styles[STYLE_LINENUMBER].fore.allocated, vsPrint.styles[STYLE_LINENUMBER].back.allocated); } // Draw the line surface->FlushCachedState(); for (int iwl = 0; iwl < ll.lines; iwl++) { if (ypos + vsPrint.lineHeight <= pfr->rc.bottom) { if (visibleLine >= 0) { if (draw) { rcLine.top = ypos; rcLine.bottom = ypos + vsPrint.lineHeight; DrawLine(surface, vsPrint, lineDoc, visibleLine, xStart, rcLine, &ll, iwl); } ypos += vsPrint.lineHeight; } visibleLine++; if (iwl == ll.lines - 1) nPrintPos = pdoc->LineStart(lineDoc + 1); else nPrintPos += ll.LineStart(iwl + 1) - ll.LineStart(iwl); } } ++lineDoc; } // Clear cache so measurements are not used for screen posCache.Clear(); return nPrintPos; } int Editor::TextWidth(int style, const char *text) { RefreshStyleData(); AutoSurface surface(this); if (surface) { return surface->WidthText(vs.styles[style].font, text, istrlen(text)); } else { return 1; } } // Empty method is overridden on GTK+ to show / hide scrollbars void Editor::ReconfigureScrollBars() {} void Editor::SetScrollBars() { RefreshStyleData(); int nMax = MaxScrollPos(); int nPage = LinesOnScreen(); bool modified = ModifyScrollBars(nMax + nPage - 1, nPage); if (modified) { DwellEnd(true); } // TODO: ensure always showing as many lines as possible // May not be, if, for example, window made larger if (topLine > MaxScrollPos()) { SetTopLine(Platform::Clamp(topLine, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } if (modified) { if (!AbandonPaint()) Redraw(); } //Platform::DebugPrintf("end max = %d page = %d\n", nMax, nPage); } void Editor::ChangeSize() { DropGraphics(); SetScrollBars(); if (wrapState != eWrapNone) { PRectangle rcTextArea = GetClientRectangle(); rcTextArea.left = vs.fixedColumnWidth; rcTextArea.right -= vs.rightMarginWidth; if (wrapWidth != rcTextArea.Width()) { NeedWrapping(); Redraw(); } } } int Editor::InsertSpace(int position, unsigned int spaces) { if (spaces > 0) { std::string spaceText(spaces, ' '); pdoc->InsertString(position, spaceText.c_str(), spaces); position += spaces; } return position; } void Editor::AddChar(char ch) { char s[2]; s[0] = ch; s[1] = '\0'; AddCharUTF(s, 1); } void Editor::FilterSelections() { if (!additionalSelectionTyping && (sel.Count() > 1)) { SelectionRange rangeOnly = sel.RangeMain(); InvalidateSelection(rangeOnly, true); sel.SetSelection(rangeOnly); } } // AddCharUTF inserts an array of bytes which may or may not be in UTF-8. void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { FilterSelections(); { UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike); for (size_t r=0; r<sel.Count(); r++) { if (!RangeContainsProtected(sel.Range(r).Start().Position(), sel.Range(r).End().Position())) { int positionInsert = sel.Range(r).Start().Position(); if (!sel.Range(r).Empty()) { if (sel.Range(r).Length()) { pdoc->DeleteChars(positionInsert, sel.Range(r).Length()); sel.Range(r).ClearVirtualSpace(); } else { // Range is all virtual so collapse to start of virtual space sel.Range(r).MinimizeVirtualSpace(); } } else if (inOverstrike) { if (positionInsert < pdoc->Length()) { if (!IsEOLChar(pdoc->CharAt(positionInsert))) { pdoc->DelChar(positionInsert); sel.Range(r).ClearVirtualSpace(); } } } positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); if (pdoc->InsertString(positionInsert, s, len)) { sel.Range(r).caret.SetPosition(positionInsert + len); sel.Range(r).anchor.SetPosition(positionInsert + len); } sel.Range(r).ClearVirtualSpace(); // If in wrap mode rewrap current line so EnsureCaretVisible has accurate information if (wrapState != eWrapNone) { AutoSurface surface(this); if (surface) { if (WrapOneLine(surface, pdoc->LineFromPosition(positionInsert))) { SetScrollBars(); SetVerticalScrollPos(); Redraw(); } } } } } } if (wrapState != eWrapNone) { SetScrollBars(); } ThinRectangularRange(); // If in wrap mode rewrap current line so EnsureCaretVisible has accurate information EnsureCaretVisible(); // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); if ((caretSticky == SC_CARETSTICKY_OFF) || ((caretSticky == SC_CARETSTICKY_WHITESPACE) && !IsAllSpacesOrTabs(s, len))) { SetLastXChosen(); } if (treatAsDBCS) { NotifyChar((static_cast<unsigned char>(s[0]) << 8) | static_cast<unsigned char>(s[1])); } else { int byte = static_cast<unsigned char>(s[0]); if ((byte < 0xC0) || (1 == len)) { // Handles UTF-8 characters between 0x01 and 0x7F and single byte // characters when not in UTF-8 mode. // Also treats \0 and naked trail bytes 0x80 to 0xBF as valid // characters representing themselves. } else { // Unroll 1 to 3 byte UTF-8 sequences. See reference data at: // http://www.cl.cam.ac.uk/~mgk25/unicode.html // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt if (byte < 0xE0) { int byte2 = static_cast<unsigned char>(s[1]); if ((byte2 & 0xC0) == 0x80) { // Two-byte-character lead-byte followed by a trail-byte. byte = (((byte & 0x1F) << 6) | (byte2 & 0x3F)); } // A two-byte-character lead-byte not followed by trail-byte // represents itself. } else if (byte < 0xF0) { int byte2 = static_cast<unsigned char>(s[1]); int byte3 = static_cast<unsigned char>(s[2]); if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) { // Three-byte-character lead byte followed by two trail bytes. byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) | (byte3 & 0x3F)); } // A three-byte-character lead-byte not followed by two trail-bytes // represents itself. } } NotifyChar(byte); } if (recordingMacro) { NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(s)); } } void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len) { if (multiPasteMode == SC_MULTIPASTE_ONCE) { selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace())); if (pdoc->InsertString(selStart.Position(), text, len)) { SetEmptySelection(selStart.Position() + len); } } else { // SC_MULTIPASTE_EACH for (size_t r=0; r<sel.Count(); r++) { if (!RangeContainsProtected(sel.Range(r).Start().Position(), sel.Range(r).End().Position())) { int positionInsert = sel.Range(r).Start().Position(); if (!sel.Range(r).Empty()) { if (sel.Range(r).Length()) { pdoc->DeleteChars(positionInsert, sel.Range(r).Length()); sel.Range(r).ClearVirtualSpace(); } else { // Range is all virtual so collapse to start of virtual space sel.Range(r).MinimizeVirtualSpace(); } } positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); if (pdoc->InsertString(positionInsert, text, len)) { sel.Range(r).caret.SetPosition(positionInsert + len); sel.Range(r).anchor.SetPosition(positionInsert + len); } sel.Range(r).ClearVirtualSpace(); } } } } void Editor::ClearSelection() { if (!sel.IsRectangular()) FilterSelections(); UndoGroup ug(pdoc); for (size_t r=0; r<sel.Count(); r++) { if (!sel.Range(r).Empty()) { if (!RangeContainsProtected(sel.Range(r).Start().Position(), sel.Range(r).End().Position())) { pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); sel.Range(r) = sel.Range(r).Start(); } } } ThinRectangularRange(); sel.RemoveDuplicates(); ClaimSelection(); } void Editor::ClearAll() { { UndoGroup ug(pdoc); if (0 != pdoc->Length()) { pdoc->DeleteChars(0, pdoc->Length()); } if (!pdoc->IsReadOnly()) { cs.Clear(); pdoc->AnnotationClearAll(); pdoc->MarginClearAll(); } } sel.Clear(); SetTopLine(0); SetVerticalScrollPos(); InvalidateStyleRedraw(); } void Editor::ClearDocumentStyle() { Decoration *deco = pdoc->decorations.root; while (deco) { // Save next in case deco deleted Decoration *decoNext = deco->next; if (deco->indicator < INDIC_CONTAINER) { pdoc->decorations.SetCurrentIndicator(deco->indicator); pdoc->DecorationFillRange(0, 0, pdoc->Length()); } deco = decoNext; } pdoc->StartStyling(0, '\377'); pdoc->SetStyleFor(pdoc->Length(), 0); cs.ShowAll(); pdoc->ClearLevels(); } void Editor::CopyAllowLine() { SelectionText selectedText; CopySelectionRange(&selectedText, true); CopyToClipboard(selectedText); } void Editor::Cut() { pdoc->CheckReadOnly(); if (!pdoc->IsReadOnly() && !SelectionContainsProtected()) { Copy(); ClearSelection(); } } void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) { if (pdoc->IsReadOnly() || SelectionContainsProtected()) { return; } sel.Clear(); sel.RangeMain() = SelectionRange(pos); int line = pdoc->LineFromPosition(sel.MainCaret()); UndoGroup ug(pdoc); sel.RangeMain().caret = SelectionPosition( InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); int xInsert = XFromPosition(sel.RangeMain().caret); bool prevCr = false; while ((len > 0) && IsEOLChar(ptr[len-1])) len--; for (int i = 0; i < len; i++) { if (IsEOLChar(ptr[i])) { if ((ptr[i] == '\r') || (!prevCr)) line++; if (line >= pdoc->LinesTotal()) { if (pdoc->eolMode != SC_EOL_LF) pdoc->InsertChar(pdoc->Length(), '\r'); if (pdoc->eolMode != SC_EOL_CR) pdoc->InsertChar(pdoc->Length(), '\n'); } // Pad the end of lines with spaces if required sel.RangeMain().caret.SetPosition(PositionFromLineX(line, xInsert)); if ((XFromPosition(sel.MainCaret()) < xInsert) && (i + 1 < len)) { while (XFromPosition(sel.MainCaret()) < xInsert) { pdoc->InsertChar(sel.MainCaret(), ' '); sel.RangeMain().caret.Add(1); } } prevCr = ptr[i] == '\r'; } else { pdoc->InsertString(sel.MainCaret(), ptr + i, 1); sel.RangeMain().caret.Add(1); prevCr = false; } } SetEmptySelection(pos); } bool Editor::CanPaste() { return !pdoc->IsReadOnly() && !SelectionContainsProtected(); } void Editor::Clear() { // If multiple selections, don't delete EOLS if (sel.Empty()) { UndoGroup ug(pdoc, sel.Count() > 1); for (size_t r=0; r<sel.Count(); r++) { if (!RangeContainsProtected(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1)) { if (sel.Range(r).Start().VirtualSpace()) { if (sel.Range(r).anchor < sel.Range(r).caret) sel.Range(r) = SelectionPosition(InsertSpace(sel.Range(r).anchor.Position(), sel.Range(r).anchor.VirtualSpace())); else sel.Range(r) = SelectionPosition(InsertSpace(sel.Range(r).caret.Position(), sel.Range(r).caret.VirtualSpace())); } if ((sel.Count() == 1) || !IsEOLChar(pdoc->CharAt(sel.Range(r).caret.Position()))) { pdoc->DelChar(sel.Range(r).caret.Position()); sel.Range(r).ClearVirtualSpace(); } // else multiple selection so don't eat line ends } else { sel.Range(r).ClearVirtualSpace(); } } } else { ClearSelection(); } sel.RemoveDuplicates(); } void Editor::SelectAll() { sel.Clear(); SetSelection(0, pdoc->Length()); Redraw(); } void Editor::Undo() { if (pdoc->CanUndo()) { InvalidateCaret(); int newPos = pdoc->Undo(); if (newPos >= 0) SetEmptySelection(newPos); EnsureCaretVisible(); } } void Editor::Redo() { if (pdoc->CanRedo()) { int newPos = pdoc->Redo(); if (newPos >= 0) SetEmptySelection(newPos); EnsureCaretVisible(); } } void Editor::DelChar() { if (!RangeContainsProtected(sel.MainCaret(), sel.MainCaret() + 1)) { pdoc->DelChar(sel.MainCaret()); } // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); } void Editor::DelCharBack(bool allowLineStartDeletion) { if (!sel.IsRectangular()) FilterSelections(); if (sel.IsRectangular()) allowLineStartDeletion = false; UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty()); if (sel.Empty()) { for (size_t r=0; r<sel.Count(); r++) { if (!RangeContainsProtected(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1)) { if (sel.Range(r).caret.VirtualSpace()) { sel.Range(r).caret.SetVirtualSpace(sel.Range(r).caret.VirtualSpace() - 1); sel.Range(r).anchor.SetVirtualSpace(sel.Range(r).caret.VirtualSpace()); } else { int lineCurrentPos = pdoc->LineFromPosition(sel.Range(r).caret.Position()); if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != sel.Range(r).caret.Position())) { if (pdoc->GetColumn(sel.Range(r).caret.Position()) <= pdoc->GetLineIndentation(lineCurrentPos) && pdoc->GetColumn(sel.Range(r).caret.Position()) > 0 && pdoc->backspaceUnindents) { UndoGroup ugInner(pdoc, !ug.Needed()); int indentation = pdoc->GetLineIndentation(lineCurrentPos); int indentationStep = pdoc->IndentSize(); if (indentation % indentationStep == 0) { pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); } else { pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep)); } // SetEmptySelection sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos), pdoc->GetLineIndentPosition(lineCurrentPos)); } else { pdoc->DelCharBack(sel.Range(r).caret.Position()); } } } } else { sel.Range(r).ClearVirtualSpace(); } } } else { ClearSelection(); } sel.RemoveDuplicates(); // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); } void Editor::NotifyFocus(bool) {} void Editor::NotifyStyleToNeeded(int endStyleNeeded) { SCNotification scn = {0}; scn.nmhdr.code = SCN_STYLENEEDED; scn.position = endStyleNeeded; NotifyParent(scn); } void Editor::NotifyStyleNeeded(Document *, void *, int endStyleNeeded) { NotifyStyleToNeeded(endStyleNeeded); } void Editor::NotifyLexerChanged(Document *, void *) { } void Editor::NotifyErrorOccurred(Document *, void *, int status) { errorStatus = status; } void Editor::NotifyChar(int ch) { SCNotification scn = {0}; scn.nmhdr.code = SCN_CHARADDED; scn.ch = ch; NotifyParent(scn); } void Editor::NotifySavePoint(bool isSavePoint) { SCNotification scn = {0}; if (isSavePoint) { scn.nmhdr.code = SCN_SAVEPOINTREACHED; } else { scn.nmhdr.code = SCN_SAVEPOINTLEFT; } NotifyParent(scn); } void Editor::NotifyModifyAttempt() { SCNotification scn = {0}; scn.nmhdr.code = SCN_MODIFYATTEMPTRO; NotifyParent(scn); } void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) { SCNotification scn = {0}; scn.nmhdr.code = SCN_DOUBLECLICK; scn.line = LineFromLocation(pt); scn.position = PositionFromLocation(pt, true); scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); NotifyParent(scn); } void Editor::NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt) { SCNotification scn = {0}; scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK; scn.position = position; scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); NotifyParent(scn); } void Editor::NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt) { SCNotification scn = {0}; scn.nmhdr.code = SCN_HOTSPOTCLICK; scn.position = position; scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); NotifyParent(scn); } void Editor::NotifyUpdateUI() { SCNotification scn = {0}; scn.nmhdr.code = SCN_UPDATEUI; NotifyParent(scn); } void Editor::NotifyPainted() { SCNotification scn = {0}; scn.nmhdr.code = SCN_PAINTED; NotifyParent(scn); } void Editor::NotifyScrolled() { SCNotification scn = {0}; scn.nmhdr.code = SCN_SCROLLED; NotifyParent(scn); } void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) { int mask = pdoc->decorations.AllOnFor(position); if ((click && mask) || pdoc->decorations.clickNotified) { SCNotification scn = {0}; pdoc->decorations.clickNotified = click; scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE; scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); scn.position = position; NotifyParent(scn); } } bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { int marginClicked = -1; int x = 0; for (int margin = 0; margin < ViewStyle::margins; margin++) { if ((pt.x > x) && (pt.x < x + vs.ms[margin].width)) marginClicked = margin; x += vs.ms[margin].width; } if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) { SCNotification scn = {0}; scn.nmhdr.code = SCN_MARGINCLICK; scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); scn.position = pdoc->LineStart(LineFromLocation(pt)); scn.margin = marginClicked; NotifyParent(scn); return true; } else { return false; } } void Editor::NotifyNeedShown(int pos, int len) { SCNotification scn = {0}; scn.nmhdr.code = SCN_NEEDSHOWN; scn.position = pos; scn.length = len; NotifyParent(scn); } void Editor::NotifyDwelling(Point pt, bool state) { SCNotification scn = {0}; scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND; scn.position = PositionFromLocation(pt, true); scn.x = pt.x; scn.y = pt.y; NotifyParent(scn); } void Editor::NotifyZoom() { SCNotification scn = {0}; scn.nmhdr.code = SCN_ZOOM; NotifyParent(scn); } // Notifications from document void Editor::NotifyModifyAttempt(Document *, void *) { //Platform::DebugPrintf("** Modify Attempt\n"); NotifyModifyAttempt(); } void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) { //Platform::DebugPrintf("** Save Point %s\n", atSavePoint ? "On" : "Off"); NotifySavePoint(atSavePoint); } void Editor::CheckModificationForWrap(DocModification mh) { if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) { llc.Invalidate(LineLayout::llCheckTextAndStyle); if (wrapState != eWrapNone) { int lineDoc = pdoc->LineFromPosition(mh.position); int lines = Platform::Maximum(0, mh.linesAdded); NeedWrapping(lineDoc, lineDoc + lines + 1); } // Fix up annotation heights int lineDoc = pdoc->LineFromPosition(mh.position); int lines = Platform::Maximum(0, mh.linesAdded); SetAnnotationHeights(lineDoc, lineDoc + lines + 2); } } // Move a position so it is still after the same character as before the insertion. static inline int MovePositionForInsertion(int position, int startInsertion, int length) { if (position > startInsertion) { return position + length; } return position; } // Move a position so it is still after the same character as before the deletion if that // character is still present else after the previous surviving character. static inline int MovePositionForDeletion(int position, int startDeletion, int length) { if (position > startDeletion) { int endDeletion = startDeletion + length; if (position > endDeletion) { return position - length; } else { return startDeletion; } } else { return position; } } void Editor::NotifyModified(Document *, DocModification mh, void *) { needUpdateUI = true; if (paintState == painting) { CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length)); } if (mh.modificationType & SC_MOD_CHANGELINESTATE) { if (paintState == painting) { CheckForChangeOutsidePaint( Range(pdoc->LineStart(mh.line), pdoc->LineStart(mh.line + 1))); } else { // Could check that change is before last visible line. Redraw(); } } if (mh.modificationType & SC_MOD_LEXERSTATE) { if (paintState == painting) { CheckForChangeOutsidePaint( Range(mh.position, mh.position + mh.length)); } else { Redraw(); } } if (mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) { if (mh.modificationType & SC_MOD_CHANGESTYLE) { pdoc->IncrementStyleClock(); } if (paintState == notPainting) { if (mh.position < pdoc->LineStart(topLine)) { // Styling performed before this view Redraw(); } else { InvalidateRange(mh.position, mh.position + mh.length); } } if (mh.modificationType & SC_MOD_CHANGESTYLE) { llc.Invalidate(LineLayout::llCheckTextAndStyle); } } else { // Move selection and brace highlights if (mh.modificationType & SC_MOD_INSERTTEXT) { sel.MovePositions(true, mh.position, mh.length); braces[0] = MovePositionForInsertion(braces[0], mh.position, mh.length); braces[1] = MovePositionForInsertion(braces[1], mh.position, mh.length); } else if (mh.modificationType & SC_MOD_DELETETEXT) { sel.MovePositions(false, mh.position, mh.length); braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length); braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length); } if (cs.LinesDisplayed() < cs.LinesInDoc()) { // Some lines are hidden so may need shown. // TODO: check if the modified area is hidden. if (mh.modificationType & SC_MOD_BEFOREINSERT) { int lineOfPos = pdoc->LineFromPosition(mh.position); bool insertingNewLine = false; for (int i=0; i < mh.length; i++) { if ((mh.text[i] == '\n') || (mh.text[i] == '\r')) insertingNewLine = true; } if (insertingNewLine && (mh.position != pdoc->LineStart(lineOfPos))) NotifyNeedShown(mh.position, pdoc->LineStart(lineOfPos+1) - mh.position); else NotifyNeedShown(mh.position, 0); } else if (mh.modificationType & SC_MOD_BEFOREDELETE) { NotifyNeedShown(mh.position, mh.length); } } if (mh.linesAdded != 0) { // Update contraction state for inserted and removed lines // lineOfPos should be calculated in context of state before modification, shouldn't it int lineOfPos = pdoc->LineFromPosition(mh.position); if (mh.linesAdded > 0) { cs.InsertLines(lineOfPos, mh.linesAdded); } else { cs.DeleteLines(lineOfPos, -mh.linesAdded); } } if (mh.modificationType & SC_MOD_CHANGEANNOTATION) { int lineDoc = pdoc->LineFromPosition(mh.position); if (vs.annotationVisible) { cs.SetHeight(lineDoc, cs.GetHeight(lineDoc) + mh.annotationLinesAdded); Redraw(); } } CheckModificationForWrap(mh); if (mh.linesAdded != 0) { // Avoid scrolling of display if change before current display if (mh.position < posTopLine && !CanDeferToLastStep(mh)) { int newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos()); if (newTop != topLine) { SetTopLine(newTop); SetVerticalScrollPos(); } } //Platform::DebugPrintf("** %x Doc Changed\n", this); // TODO: could invalidate from mh.startModification to end of screen //InvalidateRange(mh.position, mh.position + mh.length); if (paintState == notPainting && !CanDeferToLastStep(mh)) { QueueStyling(pdoc->Length()); Redraw(); } } else { //Platform::DebugPrintf("** %x Line Changed %d .. %d\n", this, // mh.position, mh.position + mh.length); if (paintState == notPainting && mh.length && !CanEliminate(mh)) { QueueStyling(mh.position + mh.length); InvalidateRange(mh.position, mh.position + mh.length); } } } if (mh.linesAdded != 0 && !CanDeferToLastStep(mh)) { SetScrollBars(); } if ((mh.modificationType & SC_MOD_CHANGEMARKER) || (mh.modificationType & SC_MOD_CHANGEMARGIN)) { if ((paintState == notPainting) || !PaintContainsMargin()) { if (mh.modificationType & SC_MOD_CHANGEFOLD) { // Fold changes can affect the drawing of following lines so redraw whole margin RedrawSelMargin(mh.line-1, true); } else { RedrawSelMargin(mh.line); } } } // NOW pay the piper WRT "deferred" visual updates if (IsLastStep(mh)) { SetScrollBars(); Redraw(); } // If client wants to see this modification if (mh.modificationType & modEventMask) { if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) { // Real modification made to text of document. NotifyChange(); // Send EN_CHANGE } SCNotification scn = {0}; scn.nmhdr.code = SCN_MODIFIED; scn.position = mh.position; scn.modificationType = mh.modificationType; scn.text = mh.text; scn.length = mh.length; scn.linesAdded = mh.linesAdded; scn.line = mh.line; scn.foldLevelNow = mh.foldLevelNow; scn.foldLevelPrev = mh.foldLevelPrev; scn.token = mh.token; scn.annotationLinesAdded = mh.annotationLinesAdded; NotifyParent(scn); } } void Editor::NotifyDeleted(Document *, void *) { /* Do nothing */ } void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { // Enumerates all macroable messages switch (iMessage) { case SCI_CUT: case SCI_COPY: case SCI_PASTE: case SCI_CLEAR: case SCI_REPLACESEL: case SCI_ADDTEXT: case SCI_INSERTTEXT: case SCI_APPENDTEXT: case SCI_CLEARALL: case SCI_SELECTALL: case SCI_GOTOLINE: case SCI_GOTOPOS: case SCI_SEARCHANCHOR: case SCI_SEARCHNEXT: case SCI_SEARCHPREV: case SCI_LINEDOWN: case SCI_LINEDOWNEXTEND: case SCI_PARADOWN: case SCI_PARADOWNEXTEND: case SCI_LINEUP: case SCI_LINEUPEXTEND: case SCI_PARAUP: case SCI_PARAUPEXTEND: case SCI_CHARLEFT: case SCI_CHARLEFTEXTEND: case SCI_CHARRIGHT: case SCI_CHARRIGHTEXTEND: case SCI_WORDLEFT: case SCI_WORDLEFTEXTEND: case SCI_WORDRIGHT: case SCI_WORDRIGHTEXTEND: case SCI_WORDPARTLEFT: case SCI_WORDPARTLEFTEXTEND: case SCI_WORDPARTRIGHT: case SCI_WORDPARTRIGHTEXTEND: case SCI_WORDLEFTEND: case SCI_WORDLEFTENDEXTEND: case SCI_WORDRIGHTEND: case SCI_WORDRIGHTENDEXTEND: case SCI_HOME: case SCI_HOMEEXTEND: case SCI_LINEEND: case SCI_LINEENDEXTEND: case SCI_HOMEWRAP: case SCI_HOMEWRAPEXTEND: case SCI_LINEENDWRAP: case SCI_LINEENDWRAPEXTEND: case SCI_DOCUMENTSTART: case SCI_DOCUMENTSTARTEXTEND: case SCI_DOCUMENTEND: case SCI_DOCUMENTENDEXTEND: case SCI_STUTTEREDPAGEUP: case SCI_STUTTEREDPAGEUPEXTEND: case SCI_STUTTEREDPAGEDOWN: case SCI_STUTTEREDPAGEDOWNEXTEND: case SCI_PAGEUP: case SCI_PAGEUPEXTEND: case SCI_PAGEDOWN: case SCI_PAGEDOWNEXTEND: case SCI_EDITTOGGLEOVERTYPE: case SCI_CANCEL: case SCI_DELETEBACK: case SCI_TAB: case SCI_BACKTAB: case SCI_FORMFEED: case SCI_VCHOME: case SCI_VCHOMEEXTEND: case SCI_VCHOMEWRAP: case SCI_VCHOMEWRAPEXTEND: case SCI_DELWORDLEFT: case SCI_DELWORDRIGHT: case SCI_DELWORDRIGHTEND: case SCI_DELLINELEFT: case SCI_DELLINERIGHT: case SCI_LINECOPY: case SCI_LINECUT: case SCI_LINEDELETE: case SCI_LINETRANSPOSE: case SCI_LINEDUPLICATE: case SCI_LOWERCASE: case SCI_UPPERCASE: case SCI_LINESCROLLDOWN: case SCI_LINESCROLLUP: case SCI_DELETEBACKNOTLINE: case SCI_HOMEDISPLAY: case SCI_HOMEDISPLAYEXTEND: case SCI_LINEENDDISPLAY: case SCI_LINEENDDISPLAYEXTEND: case SCI_SETSELECTIONMODE: case SCI_LINEDOWNRECTEXTEND: case SCI_LINEUPRECTEXTEND: case SCI_CHARLEFTRECTEXTEND: case SCI_CHARRIGHTRECTEXTEND: case SCI_HOMERECTEXTEND: case SCI_VCHOMERECTEXTEND: case SCI_LINEENDRECTEXTEND: case SCI_PAGEUPRECTEXTEND: case SCI_PAGEDOWNRECTEXTEND: case SCI_SELECTIONDUPLICATE: case SCI_COPYALLOWLINE: break; // Filter out all others like display changes. Also, newlines are redundant // with char insert messages. case SCI_NEWLINE: default: // printf("Filtered out %ld of macro recording\n", iMessage); return ; } // Send notification SCNotification scn = {0}; scn.nmhdr.code = SCN_MACRORECORD; scn.message = iMessage; scn.wParam = wParam; scn.lParam = lParam; NotifyParent(scn); } /** * Force scroll and keep position relative to top of window. * * If stuttered = true and not already at first/last row, move to first/last row of window. * If stuttered = true and already at first/last row, scroll as normal. */ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) { int topLineNew, newPos; // I consider only the caretYSlop, and ignore the caretYPolicy-- is that a problem? int currentLine = pdoc->LineFromPosition(sel.MainCaret()); int topStutterLine = topLine + caretYSlop; int bottomStutterLine = pdoc->LineFromPosition(PositionFromLocation( Point(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll()))) - caretYSlop - 1; if (stuttered && (direction < 0 && currentLine > topStutterLine)) { topLineNew = topLine; newPos = PositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * caretYSlop)); } else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) { topLineNew = topLine; newPos = PositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop))); } else { Point pt = LocationFromPosition(sel.MainCaret()); topLineNew = Platform::Clamp( topLine + direction * LinesToScroll(), 0, MaxScrollPos()); newPos = PositionFromLocation( Point(lastXChosen - xOffset, pt.y + direction * (vs.lineHeight * LinesToScroll()))); } if (topLineNew != topLine) { SetTopLine(topLineNew); MovePositionTo(SelectionPosition(newPos), selt); Redraw(); SetVerticalScrollPos(); } else { MovePositionTo(SelectionPosition(newPos), selt); } } void Editor::ChangeCaseOfSelection(int caseMapping) { UndoGroup ug(pdoc); for (size_t r=0; r<sel.Count(); r++) { SelectionRange current = sel.Range(r); SelectionRange currentNoVS = current; currentNoVS.ClearVirtualSpace(); char *text = CopyRange(currentNoVS.Start().Position(), currentNoVS.End().Position()); size_t rangeBytes = currentNoVS.Length(); if (rangeBytes > 0) { std::string sText(text, rangeBytes); std::string sMapped = CaseMapString(sText, caseMapping); if (sMapped != sText) { size_t firstDifference = 0; while (sMapped[firstDifference] == sText[firstDifference]) firstDifference++; size_t lastDifference = sMapped.size() - 1; while (sMapped[lastDifference] == sText[lastDifference]) lastDifference--; size_t endSame = sMapped.size() - 1 - lastDifference; pdoc->DeleteChars(currentNoVS.Start().Position() + firstDifference, rangeBytes - firstDifference - endSame); pdoc->InsertString(currentNoVS.Start().Position() + firstDifference, sMapped.c_str() + firstDifference, lastDifference - firstDifference + 1); // Automatic movement changes selection so reset to exactly the same as it was. sel.Range(r) = current; } } delete []text; } } void Editor::LineTranspose() { int line = pdoc->LineFromPosition(sel.MainCaret()); if (line > 0) { UndoGroup ug(pdoc); int startPrev = pdoc->LineStart(line - 1); int endPrev = pdoc->LineEnd(line - 1); int start = pdoc->LineStart(line); int end = pdoc->LineEnd(line); char *line1 = CopyRange(startPrev, endPrev); int len1 = endPrev - startPrev; char *line2 = CopyRange(start, end); int len2 = end - start; pdoc->DeleteChars(start, len2); pdoc->DeleteChars(startPrev, len1); pdoc->InsertString(startPrev, line2, len2); pdoc->InsertString(start - len1 + len2, line1, len1); MovePositionTo(SelectionPosition(start - len1 + len2)); delete []line1; delete []line2; } } void Editor::Duplicate(bool forLine) { if (sel.Empty()) { forLine = true; } UndoGroup ug(pdoc, sel.Count() > 1); SelectionPosition last; const char *eol = ""; int eolLen = 0; if (forLine) { eol = StringFromEOLMode(pdoc->eolMode); eolLen = istrlen(eol); } for (size_t r=0; r<sel.Count(); r++) { SelectionPosition start = sel.Range(r).Start(); SelectionPosition end = sel.Range(r).End(); if (forLine) { int line = pdoc->LineFromPosition(sel.Range(r).caret.Position()); start = SelectionPosition(pdoc->LineStart(line)); end = SelectionPosition(pdoc->LineEnd(line)); } char *text = CopyRange(start.Position(), end.Position()); if (forLine) pdoc->InsertString(end.Position(), eol, eolLen); pdoc->InsertString(end.Position() + eolLen, text, SelectionRange(end, start).Length()); delete []text; } if (sel.Count() && sel.IsRectangular()) { SelectionPosition last = sel.Last(); if (forLine) { int line = pdoc->LineFromPosition(last.Position()); last = SelectionPosition(last.Position() + pdoc->LineStart(line+1) - pdoc->LineStart(line)); } if (sel.Rectangular().anchor > sel.Rectangular().caret) sel.Rectangular().anchor = last; else sel.Rectangular().caret = last; SetRectangularRange(); } } void Editor::CancelModes() { sel.SetMoveExtends(false); } void Editor::NewLine() { ClearSelection(); const char *eol = "\n"; if (pdoc->eolMode == SC_EOL_CRLF) { eol = "\r\n"; } else if (pdoc->eolMode == SC_EOL_CR) { eol = "\r"; } // else SC_EOL_LF -> "\n" already set if (pdoc->InsertCString(sel.MainCaret(), eol)) { SetEmptySelection(sel.MainCaret() + istrlen(eol)); while (*eol) { NotifyChar(*eol); if (recordingMacro) { char txt[2]; txt[0] = *eol; txt[1] = '\0'; NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast<sptr_t>(txt)); } eol++; } } SetLastXChosen(); SetScrollBars(); EnsureCaretVisible(); // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); } void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { SelectionPosition caretToUse = sel.Range(sel.Main()).caret; if (sel.IsRectangular()) { if (selt == Selection::noSel) { caretToUse = (direction > 0) ? sel.Limits().end : sel.Limits().start; } else { caretToUse = sel.Rectangular().caret; } } Point pt = LocationFromPosition(caretToUse); int lineDoc = pdoc->LineFromPosition(caretToUse.Position()); Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc)); int subLine = (pt.y - ptStartLine.y) / vs.lineHeight; int commentLines = vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0; SelectionPosition posNew = SPositionFromLocation( Point(lastXChosen - xOffset, pt.y + direction * vs.lineHeight), false, false, UserVirtualSpace()); if ((direction > 0) && (subLine >= (cs.GetHeight(lineDoc) - 1 - commentLines))) { posNew = SPositionFromLocation( Point(lastXChosen - xOffset, pt.y + (commentLines + 1) * vs.lineHeight), false, false, UserVirtualSpace()); } if (direction < 0) { // Line wrapping may lead to a location on the same line, so // seek back if that is the case. // There is an equivalent case when moving down which skips // over a line but as that does not trap the user it is fine. Point ptNew = LocationFromPosition(posNew.Position()); while ((posNew.Position() > 0) && (pt.y == ptNew.y)) { posNew.Add(- 1); posNew.SetVirtualSpace(0); ptNew = LocationFromPosition(posNew.Position()); } } MovePositionTo(posNew, selt); } void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) { int lineDoc, savedPos = sel.MainCaret(); do { MovePositionTo(SelectionPosition(direction > 0 ? pdoc->ParaDown(sel.MainCaret()) : pdoc->ParaUp(sel.MainCaret())), selt); lineDoc = pdoc->LineFromPosition(sel.MainCaret()); if (direction > 0) { if (sel.MainCaret() >= pdoc->Length() && !cs.GetVisible(lineDoc)) { if (selt == Selection::noSel) { MovePositionTo(SelectionPosition(pdoc->LineEndPosition(savedPos))); } break; } } } while (!cs.GetVisible(lineDoc)); } int Editor::StartEndDisplayLine(int pos, bool start) { RefreshStyleData(); int line = pdoc->LineFromPosition(pos); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); int posRet = INVALID_POSITION; if (surface && ll) { unsigned int posLineStart = pdoc->LineStart(line); LayoutLine(line, surface, vs, ll, wrapWidth); int posInLine = pos - posLineStart; if (posInLine <= ll->maxLineLength) { for (int subLine = 0; subLine < ll->lines; subLine++) { if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) { if (start) { posRet = ll->LineStart(subLine) + posLineStart; } else { if (subLine == ll->lines - 1) posRet = ll->LineStart(subLine + 1) + posLineStart; else posRet = ll->LineStart(subLine + 1) + posLineStart - 1; } } } } } if (posRet == INVALID_POSITION) { return pos; } else { return posRet; } } int Editor::KeyCommand(unsigned int iMessage) { switch (iMessage) { case SCI_LINEDOWN: CursorUpOrDown(1); break; case SCI_LINEDOWNEXTEND: CursorUpOrDown(1, Selection::selStream); break; case SCI_LINEDOWNRECTEXTEND: CursorUpOrDown(1, Selection::selRectangle); break; case SCI_PARADOWN: ParaUpOrDown(1); break; case SCI_PARADOWNEXTEND: ParaUpOrDown(1, Selection::selStream); break; case SCI_LINESCROLLDOWN: ScrollTo(topLine + 1); MoveCaretInsideView(false); break; case SCI_LINEUP: CursorUpOrDown(-1); break; case SCI_LINEUPEXTEND: CursorUpOrDown(-1, Selection::selStream); break; case SCI_LINEUPRECTEXTEND: CursorUpOrDown(-1, Selection::selRectangle); break; case SCI_PARAUP: ParaUpOrDown(-1); break; case SCI_PARAUPEXTEND: ParaUpOrDown(-1, Selection::selStream); break; case SCI_LINESCROLLUP: ScrollTo(topLine - 1); MoveCaretInsideView(false); break; case SCI_CHARLEFT: if (SelectionEmpty() || sel.MoveExtends()) { if ((sel.Count() == 1) && pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); MovePositionTo(spCaret); } else { MovePositionTo(MovePositionSoVisible( SelectionPosition((sel.LimitsForRectangularElseMain().start).Position() - 1), -1)); } } else { MovePositionTo(sel.LimitsForRectangularElseMain().start); } SetLastXChosen(); break; case SCI_CHARLEFTEXTEND: if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); MovePositionTo(spCaret, Selection::selStream); } else { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selStream); } SetLastXChosen(); break; case SCI_CHARLEFTRECTEXTEND: if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); MovePositionTo(spCaret, Selection::selRectangle); } else { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selRectangle); } SetLastXChosen(); break; case SCI_CHARRIGHT: if (SelectionEmpty() || sel.MoveExtends()) { if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); MovePositionTo(spCaret); } else { MovePositionTo(MovePositionSoVisible( SelectionPosition((sel.LimitsForRectangularElseMain().end).Position() + 1), 1)); } } else { MovePositionTo(sel.LimitsForRectangularElseMain().end); } SetLastXChosen(); break; case SCI_CHARRIGHTEXTEND: if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); MovePositionTo(spCaret, Selection::selStream); } else { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selStream); } SetLastXChosen(); break; case SCI_CHARRIGHTRECTEXTEND: if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) && pdoc->IsLineEndPosition(sel.MainCaret())) { SelectionPosition spCaret = sel.RangeMain().caret; spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); MovePositionTo(spCaret, Selection::selRectangle); } else { MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selRectangle); } SetLastXChosen(); break; case SCI_WORDLEFT: MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1)); SetLastXChosen(); break; case SCI_WORDLEFTEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDRIGHT: MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1)); SetLastXChosen(); break; case SCI_WORDRIGHTEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDLEFTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1)); SetLastXChosen(); break; case SCI_WORDLEFTENDEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDRIGHTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1)); SetLastXChosen(); break; case SCI_WORDRIGHTENDEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1), Selection::selStream); SetLastXChosen(); break; case SCI_HOME: MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()))); SetLastXChosen(); break; case SCI_HOMEEXTEND: MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selStream); SetLastXChosen(); break; case SCI_HOMERECTEXTEND: MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selRectangle); SetLastXChosen(); break; case SCI_LINEEND: MovePositionTo(pdoc->LineEndPosition(sel.MainCaret())); SetLastXChosen(); break; case SCI_LINEENDEXTEND: MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selStream); SetLastXChosen(); break; case SCI_LINEENDRECTEXTEND: MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selRectangle); SetLastXChosen(); break; case SCI_HOMEWRAP: { SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); if (sel.RangeMain().caret <= homePos) homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()))); MovePositionTo(homePos); SetLastXChosen(); } break; case SCI_HOMEWRAPEXTEND: { SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); if (sel.RangeMain().caret <= homePos) homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()))); MovePositionTo(homePos, Selection::selStream); SetLastXChosen(); } break; case SCI_LINEENDWRAP: { SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1); SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret())); if (endPos > realEndPos // if moved past visible EOLs || sel.RangeMain().caret >= endPos) // if at end of display line already endPos = realEndPos; MovePositionTo(endPos); SetLastXChosen(); } break; case SCI_LINEENDWRAPEXTEND: { SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1); SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret())); if (endPos > realEndPos // if moved past visible EOLs || sel.RangeMain().caret >= endPos) // if at end of display line already endPos = realEndPos; MovePositionTo(endPos, Selection::selStream); SetLastXChosen(); } break; case SCI_DOCUMENTSTART: MovePositionTo(0); SetLastXChosen(); break; case SCI_DOCUMENTSTARTEXTEND: MovePositionTo(0, Selection::selStream); SetLastXChosen(); break; case SCI_DOCUMENTEND: MovePositionTo(pdoc->Length()); SetLastXChosen(); break; case SCI_DOCUMENTENDEXTEND: MovePositionTo(pdoc->Length(), Selection::selStream); SetLastXChosen(); break; case SCI_STUTTEREDPAGEUP: PageMove(-1, Selection::noSel, true); break; case SCI_STUTTEREDPAGEUPEXTEND: PageMove(-1, Selection::selStream, true); break; case SCI_STUTTEREDPAGEDOWN: PageMove(1, Selection::noSel, true); break; case SCI_STUTTEREDPAGEDOWNEXTEND: PageMove(1, Selection::selStream, true); break; case SCI_PAGEUP: PageMove(-1); break; case SCI_PAGEUPEXTEND: PageMove(-1, Selection::selStream); break; case SCI_PAGEUPRECTEXTEND: PageMove(-1, Selection::selRectangle); break; case SCI_PAGEDOWN: PageMove(1); break; case SCI_PAGEDOWNEXTEND: PageMove(1, Selection::selStream); break; case SCI_PAGEDOWNRECTEXTEND: PageMove(1, Selection::selRectangle); break; case SCI_EDITTOGGLEOVERTYPE: inOverstrike = !inOverstrike; DropCaret(); ShowCaretAtCurrentPosition(); NotifyUpdateUI(); break; case SCI_CANCEL: // Cancel any modes - handled in subclass // Also unselect text CancelModes(); break; case SCI_DELETEBACK: DelCharBack(true); if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) { SetLastXChosen(); } EnsureCaretVisible(); break; case SCI_DELETEBACKNOTLINE: DelCharBack(false); if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) { SetLastXChosen(); } EnsureCaretVisible(); break; case SCI_TAB: Indent(true); if (caretSticky == SC_CARETSTICKY_OFF) { SetLastXChosen(); } EnsureCaretVisible(); ShowCaretAtCurrentPosition(); // Avoid blinking break; case SCI_BACKTAB: Indent(false); if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) { SetLastXChosen(); } EnsureCaretVisible(); ShowCaretAtCurrentPosition(); // Avoid blinking break; case SCI_NEWLINE: NewLine(); break; case SCI_FORMFEED: AddChar('\f'); break; case SCI_VCHOME: MovePositionTo(pdoc->VCHomePosition(sel.MainCaret())); SetLastXChosen(); break; case SCI_VCHOMEEXTEND: MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selStream); SetLastXChosen(); break; case SCI_VCHOMERECTEXTEND: MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selRectangle); SetLastXChosen(); break; case SCI_VCHOMEWRAP: { SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret())); SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos)) homePos = viewLineStart; MovePositionTo(homePos); SetLastXChosen(); } break; case SCI_VCHOMEWRAPEXTEND: { SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret())); SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos)) homePos = viewLineStart; MovePositionTo(homePos, Selection::selStream); SetLastXChosen(); } break; case SCI_ZOOMIN: if (vs.zoomLevel < 20) { vs.zoomLevel++; InvalidateStyleRedraw(); NotifyZoom(); } break; case SCI_ZOOMOUT: if (vs.zoomLevel > -10) { vs.zoomLevel--; InvalidateStyleRedraw(); NotifyZoom(); } break; case SCI_DELWORDLEFT: { int startWord = pdoc->NextWordStart(sel.MainCaret(), -1); pdoc->DeleteChars(startWord, sel.MainCaret() - startWord); sel.RangeMain().ClearVirtualSpace(); SetLastXChosen(); } break; case SCI_DELWORDRIGHT: { UndoGroup ug(pdoc); sel.RangeMain().caret = SelectionPosition( InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); int endWord = pdoc->NextWordStart(sel.MainCaret(), 1); pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret()); } break; case SCI_DELWORDRIGHTEND: { UndoGroup ug(pdoc); sel.RangeMain().caret = SelectionPosition( InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); int endWord = pdoc->NextWordEnd(sel.MainCaret(), 1); pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret()); } break; case SCI_DELLINELEFT: { int line = pdoc->LineFromPosition(sel.MainCaret()); int start = pdoc->LineStart(line); pdoc->DeleteChars(start, sel.MainCaret() - start); sel.RangeMain().ClearVirtualSpace(); SetLastXChosen(); } break; case SCI_DELLINERIGHT: { int line = pdoc->LineFromPosition(sel.MainCaret()); int end = pdoc->LineEnd(line); pdoc->DeleteChars(sel.MainCaret(), end - sel.MainCaret()); } break; case SCI_LINECOPY: { int lineStart = pdoc->LineFromPosition(SelectionStart().Position()); int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position()); CopyRangeToClipboard(pdoc->LineStart(lineStart), pdoc->LineStart(lineEnd + 1)); } break; case SCI_LINECUT: { int lineStart = pdoc->LineFromPosition(SelectionStart().Position()); int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position()); int start = pdoc->LineStart(lineStart); int end = pdoc->LineStart(lineEnd + 1); SetSelection(start, end); Cut(); SetLastXChosen(); } break; case SCI_LINEDELETE: { int line = pdoc->LineFromPosition(sel.MainCaret()); int start = pdoc->LineStart(line); int end = pdoc->LineStart(line + 1); pdoc->DeleteChars(start, end - start); } break; case SCI_LINETRANSPOSE: LineTranspose(); break; case SCI_LINEDUPLICATE: Duplicate(true); break; case SCI_SELECTIONDUPLICATE: Duplicate(false); break; case SCI_LOWERCASE: ChangeCaseOfSelection(cmLower); break; case SCI_UPPERCASE: ChangeCaseOfSelection(cmUpper); break; case SCI_WORDPARTLEFT: MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1)); SetLastXChosen(); break; case SCI_WORDPARTLEFTEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDPARTRIGHT: MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1)); SetLastXChosen(); break; case SCI_WORDPARTRIGHTEXTEND: MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1), Selection::selStream); SetLastXChosen(); break; case SCI_HOMEDISPLAY: MovePositionTo(MovePositionSoVisible( StartEndDisplayLine(sel.MainCaret(), true), -1)); SetLastXChosen(); break; case SCI_HOMEDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( StartEndDisplayLine(sel.MainCaret(), true), -1), Selection::selStream); SetLastXChosen(); break; case SCI_LINEENDDISPLAY: MovePositionTo(MovePositionSoVisible( StartEndDisplayLine(sel.MainCaret(), false), 1)); SetLastXChosen(); break; case SCI_LINEENDDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( StartEndDisplayLine(sel.MainCaret(), false), 1), Selection::selStream); SetLastXChosen(); break; } return 0; } int Editor::KeyDefault(int, int) { return 0; } int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) { DwellEnd(false); int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); int msg = kmap.Find(key, modifiers); if (msg) { if (consumed) *consumed = true; return WndProc(msg, 0, 0); } else { if (consumed) *consumed = false; return KeyDefault(key, modifiers); } } void Editor::SetWhitespaceVisible(int view) { vs.viewWhitespace = static_cast<WhiteSpaceVisibility>(view); } int Editor::GetWhitespaceVisible() { return vs.viewWhitespace; } void Editor::Indent(bool forwards) { for (size_t r=0; r<sel.Count(); r++) { int lineOfAnchor = pdoc->LineFromPosition(sel.Range(r).anchor.Position()); int caretPosition = sel.Range(r).caret.Position(); int lineCurrentPos = pdoc->LineFromPosition(caretPosition); if (lineOfAnchor == lineCurrentPos) { if (forwards) { UndoGroup ug(pdoc); pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); caretPosition = sel.Range(r).caret.Position(); if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) && pdoc->tabIndents) { int indentation = pdoc->GetLineIndentation(lineCurrentPos); int indentationStep = pdoc->IndentSize(); pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep - indentation % indentationStep); sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos)); } else { if (pdoc->useTabs) { pdoc->InsertChar(caretPosition, '\t'); sel.Range(r) = SelectionRange(caretPosition+1); } else { int numSpaces = (pdoc->tabInChars) - (pdoc->GetColumn(caretPosition) % (pdoc->tabInChars)); if (numSpaces < 1) numSpaces = pdoc->tabInChars; for (int i = 0; i < numSpaces; i++) { pdoc->InsertChar(caretPosition + i, ' '); } sel.Range(r) = SelectionRange(caretPosition+numSpaces); } } } else { if (pdoc->GetColumn(caretPosition) <= pdoc->GetLineIndentation(lineCurrentPos) && pdoc->tabIndents) { UndoGroup ug(pdoc); int indentation = pdoc->GetLineIndentation(lineCurrentPos); int indentationStep = pdoc->IndentSize(); pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos)); } else { int newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) * pdoc->tabInChars; if (newColumn < 0) newColumn = 0; int newPos = caretPosition; while (pdoc->GetColumn(newPos) > newColumn) newPos--; sel.Range(r) = SelectionRange(newPos); } } } else { // Multiline int anchorPosOnLine = sel.Range(r).anchor.Position() - pdoc->LineStart(lineOfAnchor); int currentPosPosOnLine = caretPosition - pdoc->LineStart(lineCurrentPos); // Multiple lines selected so indent / dedent int lineTopSel = Platform::Minimum(lineOfAnchor, lineCurrentPos); int lineBottomSel = Platform::Maximum(lineOfAnchor, lineCurrentPos); if (pdoc->LineStart(lineBottomSel) == sel.Range(r).anchor.Position() || pdoc->LineStart(lineBottomSel) == caretPosition) lineBottomSel--; // If not selecting any characters on a line, do not indent { UndoGroup ug(pdoc); pdoc->Indent(forwards, lineBottomSel, lineTopSel); } if (lineOfAnchor < lineCurrentPos) { if (currentPosPosOnLine == 0) sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); else sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos + 1), pdoc->LineStart(lineOfAnchor)); } else { if (anchorPosOnLine == 0) sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); else sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor + 1)); } } } } class CaseFolderASCII : public CaseFolderTable { public: CaseFolderASCII() { StandardASCII(); } ~CaseFolderASCII() { } virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) { if (lenMixed > sizeFolded) { return 0; } else { for (size_t i=0; i<lenMixed; i++) { folded[i] = mapping[static_cast<unsigned char>(mixed[i])]; } return lenMixed; } } }; CaseFolder *Editor::CaseFolderForEncoding() { // Simple default that only maps ASCII upper case to lower case. return new CaseFolderASCII(); } /** * Search of a text in the document, in the given range. * @return The position of the found text, -1 if not found. */ long Editor::FindText( uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. Sci_TextToFind *ft = reinterpret_cast<Sci_TextToFind *>(lParam); int lengthFound = istrlen(ft->lpstrText); std::auto_ptr<CaseFolder> pcf(CaseFolderForEncoding()); int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText, (wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, wParam, &lengthFound, pcf.get()); if (pos != -1) { ft->chrgText.cpMin = pos; ft->chrgText.cpMax = pos + lengthFound; } return pos; } /** * Relocatable search support : Searches relative to current selection * point and sets the selection to the found text range with * each search. */ /** * Anchor following searches at current selection start: This allows * multiple incremental interactive searches to be macro recorded * while still setting the selection to found text so the find/select * operation is self-contained. */ void Editor::SearchAnchor() { searchAnchor = SelectionStart().Position(); } /** * Find text from current search anchor: Must call @c SearchAnchor first. * Used for next text and previous text requests. * @return The position of the found text, -1 if not found. */ long Editor::SearchText( unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. sptr_t lParam) { ///< The text to search for. const char *txt = reinterpret_cast<char *>(lParam); int pos; int lengthFound = istrlen(txt); std::auto_ptr<CaseFolder> pcf(CaseFolderForEncoding()); if (iMessage == SCI_SEARCHNEXT) { pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt, (wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, wParam, &lengthFound, pcf.get()); } else { pos = pdoc->FindText(searchAnchor, 0, txt, (wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, wParam, &lengthFound, pcf.get()); } if (pos != -1) { SetSelection(pos, pos + lengthFound); } return pos; } std::string Editor::CaseMapString(const std::string &s, int caseMapping) { std::string ret(s); for (size_t i=0; i<ret.size(); i++) { switch (caseMapping) { case cmUpper: if (ret[i] >= 'a' && ret[i] <= 'z') ret[i] = static_cast<char>(ret[i] - 'a' + 'A'); break; case cmLower: if (ret[i] >= 'A' && ret[i] <= 'Z') ret[i] = static_cast<char>(ret[i] - 'A' + 'a'); break; } } return ret; } /** * Search for text in the target range of the document. * @return The position of the found text, -1 if not found. */ long Editor::SearchInTarget(const char *text, int length) { int lengthFound = length; std::auto_ptr<CaseFolder> pcf(CaseFolderForEncoding()); int pos = pdoc->FindText(targetStart, targetEnd, text, (searchFlags & SCFIND_MATCHCASE) != 0, (searchFlags & SCFIND_WHOLEWORD) != 0, (searchFlags & SCFIND_WORDSTART) != 0, (searchFlags & SCFIND_REGEXP) != 0, searchFlags, &lengthFound, pcf.get()); if (pos != -1) { targetStart = pos; targetEnd = pos + lengthFound; } return pos; } void Editor::GoToLine(int lineNo) { if (lineNo > pdoc->LinesTotal()) lineNo = pdoc->LinesTotal(); if (lineNo < 0) lineNo = 0; SetEmptySelection(pdoc->LineStart(lineNo)); ShowCaretAtCurrentPosition(); EnsureCaretVisible(); } static bool Close(Point pt1, Point pt2) { if (abs(pt1.x - pt2.x) > 3) return false; if (abs(pt1.y - pt2.y) > 3) return false; return true; } char *Editor::CopyRange(int start, int end) { char *text = 0; if (start < end) { int len = end - start; text = new char[len + 1]; for (int i = 0; i < len; i++) { text[i] = pdoc->CharAt(start + i); } text[len] = '\0'; } return text; } void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) { if (sel.Empty()) { if (allowLineCopy) { int currentLine = pdoc->LineFromPosition(sel.MainCaret()); int start = pdoc->LineStart(currentLine); int end = pdoc->LineEnd(currentLine); char *text = CopyRange(start, end); int textLen = text ? strlen(text) : 0; // include room for \r\n\0 textLen += 3; char *textWithEndl = new char[textLen]; textWithEndl[0] = '\0'; if (text) strncat(textWithEndl, text, textLen); if (pdoc->eolMode != SC_EOL_LF) strncat(textWithEndl, "\r", textLen); if (pdoc->eolMode != SC_EOL_CR) strncat(textWithEndl, "\n", textLen); ss->Set(textWithEndl, strlen(textWithEndl) + 1, pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, true); delete []text; } } else { int delimiterLength = 0; if (sel.selType == Selection::selRectangle) { if (pdoc->eolMode == SC_EOL_CRLF) { delimiterLength = 2; } else { delimiterLength = 1; } } int size = sel.Length() + delimiterLength * sel.Count(); char *text = new char[size + 1]; int j = 0; std::vector<SelectionRange> rangesInOrder = sel.RangesCopy(); if (sel.selType == Selection::selRectangle) std::sort(rangesInOrder.begin(), rangesInOrder.end()); for (size_t r=0; r<rangesInOrder.size(); r++) { SelectionRange current = rangesInOrder[r]; for (int i = current.Start().Position(); i < current.End().Position(); i++) { text[j++] = pdoc->CharAt(i); } if (sel.selType == Selection::selRectangle) { if (pdoc->eolMode != SC_EOL_LF) { text[j++] = '\r'; } if (pdoc->eolMode != SC_EOL_CR) { text[j++] = '\n'; } } } text[size] = '\0'; ss->Set(text, size + 1, pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, sel.IsRectangular(), sel.selType == Selection::selLines); } } void Editor::CopyRangeToClipboard(int start, int end) { start = pdoc->ClampPositionIntoDocument(start); end = pdoc->ClampPositionIntoDocument(end); SelectionText selectedText; selectedText.Set(CopyRange(start, end), end - start + 1, pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false); CopyToClipboard(selectedText); } void Editor::CopyText(int length, const char *text) { SelectionText selectedText; selectedText.Copy(text, length + 1, pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false); CopyToClipboard(selectedText); } void Editor::SetDragPosition(SelectionPosition newPos) { if (newPos.Position() >= 0) { newPos = MovePositionOutsideChar(newPos, 1); posDrop = newPos; } if (!(posDrag == newPos)) { caret.on = true; SetTicking(true); InvalidateCaret(); posDrag = newPos; InvalidateCaret(); } } void Editor::DisplayCursor(Window::Cursor c) { if (cursorMode == SC_CURSORNORMAL) wMain.SetCursor(c); else wMain.SetCursor(static_cast<Window::Cursor>(cursorMode)); } bool Editor::DragThreshold(Point ptStart, Point ptNow) { int xMove = ptStart.x - ptNow.x; int yMove = ptStart.y - ptNow.y; int distanceSquared = xMove * xMove + yMove * yMove; return distanceSquared > 16; } void Editor::StartDrag() { // Always handled by subclasses //SetMouseCapture(true); //DisplayCursor(Window::cursorArrow); } void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) { //Platform::DebugPrintf("DropAt %d %d\n", inDragDrop, position); if (inDragDrop == ddDragging) dropWentOutside = false; bool positionWasInSelection = PositionInSelection(position.Position()); bool positionOnEdgeOfSelection = (position == SelectionStart()) || (position == SelectionEnd()); if ((inDragDrop != ddDragging) || !(positionWasInSelection) || (positionOnEdgeOfSelection && !moving)) { SelectionPosition selStart = SelectionStart(); SelectionPosition selEnd = SelectionEnd(); UndoGroup ug(pdoc); SelectionPosition positionAfterDeletion = position; if ((inDragDrop == ddDragging) && moving) { // Remove dragged out text if (rectangular || sel.selType == Selection::selLines) { for (size_t r=0; r<sel.Count(); r++) { if (position >= sel.Range(r).Start()) { if (position > sel.Range(r).End()) { positionAfterDeletion.Add(-sel.Range(r).Length()); } else { positionAfterDeletion.Add(-SelectionRange(position, sel.Range(r).Start()).Length()); } } } } else { if (position > selStart) { positionAfterDeletion.Add(-SelectionRange(selEnd, selStart).Length()); } } ClearSelection(); } position = positionAfterDeletion; if (rectangular) { PasteRectangular(position, value, istrlen(value)); // Should try to select new rectangle but it may not be a rectangle now so just select the drop position SetEmptySelection(position); } else { position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position()); position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace())); if (pdoc->InsertCString(position.Position(), value)) { SelectionPosition posAfterInsertion = position; posAfterInsertion.Add(istrlen(value)); SetSelection(posAfterInsertion, position); } } } else if (inDragDrop == ddDragging) { SetEmptySelection(position); } } /** * @return true if given position is inside the selection, */ bool Editor::PositionInSelection(int pos) { pos = MovePositionOutsideChar(pos, sel.MainCaret() - pos); for (size_t r=0; r<sel.Count(); r++) { if (sel.Range(r).Contains(pos)) return true; } return false; } bool Editor::PointInSelection(Point pt) { SelectionPosition pos = SPositionFromLocation(pt); int xPos = XFromPosition(pos); for (size_t r=0; r<sel.Count(); r++) { SelectionRange range = sel.Range(r); if (range.Contains(pos)) { bool hit = true; if (pos == range.Start()) { // see if just before selection if (pt.x < xPos) { hit = false; } } if (pos == range.End()) { // see if just after selection if (pt.x > xPos) { hit = false; } } if (hit) return true; } } return false; } bool Editor::PointInSelMargin(Point pt) { // Really means: "Point in a margin" if (vs.fixedColumnWidth > 0) { // There is a margin PRectangle rcSelMargin = GetClientRectangle(); rcSelMargin.right = vs.fixedColumnWidth - vs.leftMarginWidth; return rcSelMargin.Contains(pt); } else { return false; } } void Editor::LineSelection(int lineCurrent_, int lineAnchor_) { if (lineAnchor_ < lineCurrent_) { SetSelection(pdoc->LineStart(lineCurrent_ + 1), pdoc->LineStart(lineAnchor_)); } else if (lineAnchor_ > lineCurrent_) { SetSelection(pdoc->LineStart(lineCurrent_), pdoc->LineStart(lineAnchor_ + 1)); } else { // Same line, select it SetSelection(pdoc->LineStart(lineAnchor_ + 1), pdoc->LineStart(lineAnchor_)); } } void Editor::DwellEnd(bool mouseMoved) { if (mouseMoved) ticksToDwell = dwellDelay; else ticksToDwell = SC_TIME_FOREVER; if (dwelling && (dwellDelay < SC_TIME_FOREVER)) { dwelling = false; NotifyDwelling(ptMouseLast, dwelling); } } void Editor::MouseLeave() { SetHotSpotRange(NULL); } static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) { return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0) || (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0)); } void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { //Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop); ptMouseLast = pt; SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, alt)); newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position()); inDragDrop = ddNone; sel.SetMoveExtends(false); bool processed = NotifyMarginClick(pt, shift, ctrl, alt); if (processed) return; NotifyIndicatorClick(true, newPos.Position(), shift, ctrl, alt); bool inSelMargin = PointInSelMargin(pt); if (shift & !inSelMargin) { SetSelection(newPos.Position()); } if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick)) { //Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime); SetMouseCapture(true); SetEmptySelection(newPos.Position()); bool doubleClick = false; // Stop mouse button bounce changing selection type if (!Platform::MouseButtonBounce() || curTime != lastClickTime) { if (selectionType == selChar) { selectionType = selWord; doubleClick = true; } else if (selectionType == selWord) { selectionType = selLine; } else { selectionType = selChar; originalAnchorPos = sel.MainCaret(); } } if (selectionType == selWord) { if (sel.MainCaret() >= originalAnchorPos) { // Moved forward SetSelection(pdoc->ExtendWordSelect(sel.MainCaret(), 1), pdoc->ExtendWordSelect(originalAnchorPos, -1)); } else { // Moved backward SetSelection(pdoc->ExtendWordSelect(sel.MainCaret(), -1), pdoc->ExtendWordSelect(originalAnchorPos, 1)); } } else if (selectionType == selLine) { lineAnchor = LineFromLocation(pt); SetSelection(pdoc->LineStart(lineAnchor + 1), pdoc->LineStart(lineAnchor)); //Platform::DebugPrintf("Triple click: %d - %d\n", anchor, currentPos); } else { SetEmptySelection(sel.MainCaret()); } //Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos); if (doubleClick) { NotifyDoubleClick(pt, shift, ctrl, alt); if (PositionIsHotspot(newPos.Position())) NotifyHotSpotDoubleClicked(newPos.Position(), shift, ctrl, alt); } } else { // Single click if (inSelMargin) { sel.selType = Selection::selStream; if (ctrl) { SelectAll(); lastClickTime = curTime; return; } if (!shift) { lineAnchor = LineFromLocation(pt); // Single click in margin: select whole line LineSelection(lineAnchor, lineAnchor); SetSelection(pdoc->LineStart(lineAnchor + 1), pdoc->LineStart(lineAnchor)); } else { // Single shift+click in margin: select from line anchor to clicked line if (sel.MainAnchor() > sel.MainCaret()) lineAnchor = pdoc->LineFromPosition(sel.MainAnchor() - 1); else lineAnchor = pdoc->LineFromPosition(sel.MainAnchor()); int lineStart = LineFromLocation(pt); LineSelection(lineStart, lineAnchor); //lineAnchor = lineStart; // Keep the same anchor for ButtonMove } SetDragPosition(SelectionPosition(invalidPosition)); SetMouseCapture(true); selectionType = selLine; } else { if (PointIsHotspot(pt)) { NotifyHotSpotClicked(newPos.Position(), shift, ctrl, alt); } if (!shift) { if (PointInSelection(pt) && !SelectionEmpty()) inDragDrop = ddInitial; else inDragDrop = ddNone; } SetMouseCapture(true); if (inDragDrop != ddInitial) { SetDragPosition(SelectionPosition(invalidPosition)); if (!shift) { if (ctrl && multipleSelection) { SelectionRange range(newPos); sel.TentativeSelection(range); InvalidateSelection(range, true); } else { InvalidateSelection(SelectionRange(newPos), true); if (sel.Count() > 1) Redraw(); sel.Clear(); sel.selType = alt ? Selection::selRectangle : Selection::selStream; SetSelection(newPos, newPos); } } SelectionPosition anchorCurrent = newPos; if (shift) anchorCurrent = sel.IsRectangular() ? sel.Rectangular().anchor : sel.RangeMain().anchor; sel.selType = alt ? Selection::selRectangle : Selection::selStream; selectionType = selChar; originalAnchorPos = sel.MainCaret(); sel.Rectangular() = SelectionRange(newPos, anchorCurrent); SetRectangularRange(); } } } lastClickTime = curTime; lastXChosen = pt.x + xOffset; ShowCaretAtCurrentPosition(); } bool Editor::PositionIsHotspot(int position) { return vs.styles[pdoc->StyleAt(position) & pdoc->stylingBitsMask].hotspot; } bool Editor::PointIsHotspot(Point pt) { int pos = PositionFromLocation(pt, true); if (pos == INVALID_POSITION) return false; return PositionIsHotspot(pos); } void Editor::SetHotSpotRange(Point *pt) { if (pt) { int pos = PositionFromLocation(*pt); // If we don't limit this to word characters then the // range can encompass more than the run range and then // the underline will not be drawn properly. int hsStart_ = pdoc->ExtendStyleRange(pos, -1, vs.hotspotSingleLine); int hsEnd_ = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine); // Only invalidate the range if the hotspot range has changed... if (hsStart_ != hsStart || hsEnd_ != hsEnd) { if (hsStart != -1) { InvalidateRange(hsStart, hsEnd); } hsStart = hsStart_; hsEnd = hsEnd_; InvalidateRange(hsStart, hsEnd); } } else { if (hsStart != -1) { int hsStart_ = hsStart; int hsEnd_ = hsEnd; hsStart = -1; hsEnd = -1; InvalidateRange(hsStart_, hsEnd_); } else { hsStart = -1; hsEnd = -1; } } } void Editor::GetHotSpotRange(int &hsStart_, int &hsEnd_) { hsStart_ = hsStart; hsEnd_ = hsEnd; } void Editor::ButtonMove(Point pt) { if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) { DwellEnd(true); } SelectionPosition movePos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); movePos = MovePositionOutsideChar(movePos, sel.MainCaret() - movePos.Position()); if (inDragDrop == ddInitial) { if (DragThreshold(ptMouseLast, pt)) { SetMouseCapture(false); SetDragPosition(movePos); CopySelectionRange(&drag); StartDrag(); } return; } ptMouseLast = pt; //Platform::DebugPrintf("Move %d %d\n", pt.x, pt.y); if (HaveMouseCapture()) { // Slow down autoscrolling/selection autoScrollTimer.ticksToWait -= timer.tickSize; if (autoScrollTimer.ticksToWait > 0) return; autoScrollTimer.ticksToWait = autoScrollDelay; // Adjust selection if (posDrag.IsValid()) { SetDragPosition(movePos); } else { if (selectionType == selChar) { if (sel.IsRectangular()) { sel.Rectangular() = SelectionRange(movePos, sel.Rectangular().anchor); SetSelection(movePos, sel.RangeMain().anchor); } else if (sel.Count() > 1) { SelectionRange range(movePos, sel.RangeMain().anchor); sel.TentativeSelection(range); InvalidateSelection(range, true); } else { SetSelection(movePos, sel.RangeMain().anchor); } } else if (selectionType == selWord) { // Continue selecting by word if (movePos.Position() == originalAnchorPos) { // Didn't move // No need to do anything. Previously this case was lumped // in with "Moved forward", but that can be harmful in this // case: a handler for the NotifyDoubleClick re-adjusts // the selection for a fancier definition of "word" (for // example, in Perl it is useful to include the leading // '$', '%' or '@' on variables for word selection). In this // the ButtonMove() called via Tick() for auto-scrolling // could result in the fancier word selection adjustment // being unmade. } else if (movePos.Position() > originalAnchorPos) { // Moved forward SetSelection(pdoc->ExtendWordSelect(movePos.Position(), 1), pdoc->ExtendWordSelect(originalAnchorPos, -1)); } else { // Moved backward SetSelection(pdoc->ExtendWordSelect(movePos.Position(), -1), pdoc->ExtendWordSelect(originalAnchorPos, 1)); } } else { // Continue selecting by line int lineMove = LineFromLocation(pt); LineSelection(lineMove, lineAnchor); } } // Autoscroll PRectangle rcClient = GetClientRectangle(); if (pt.y > rcClient.bottom) { int lineMove = cs.DisplayFromDoc(LineFromLocation(pt)); if (lineMove < 0) { lineMove = cs.DisplayFromDoc(pdoc->LinesTotal() - 1); } ScrollTo(lineMove - LinesOnScreen() + 5); Redraw(); } else if (pt.y < rcClient.top) { int lineMove = cs.DisplayFromDoc(LineFromLocation(pt)); ScrollTo(lineMove - 2); Redraw(); } EnsureCaretVisible(false, false, true); if (hsStart != -1 && !PositionIsHotspot(movePos.Position())) SetHotSpotRange(NULL); } else { if (vs.fixedColumnWidth > 0) { // There is a margin if (PointInSelMargin(pt)) { DisplayCursor(Window::cursorReverseArrow); SetHotSpotRange(NULL); return; // No need to test for selection } } // Display regular (drag) cursor over selection if (PointInSelection(pt) && !SelectionEmpty()) { DisplayCursor(Window::cursorArrow); } else if (PointIsHotspot(pt)) { DisplayCursor(Window::cursorHand); SetHotSpotRange(&pt); } else { DisplayCursor(Window::cursorText); SetHotSpotRange(NULL); } } } void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { //Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop); SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position()); if (inDragDrop == ddInitial) { inDragDrop = ddNone; SetEmptySelection(newPos.Position()); } if (HaveMouseCapture()) { if (PointInSelMargin(pt)) { DisplayCursor(Window::cursorReverseArrow); } else { DisplayCursor(Window::cursorText); SetHotSpotRange(NULL); } ptMouseLast = pt; SetMouseCapture(false); NotifyIndicatorClick(false, newPos.Position(), false, false, false); if (inDragDrop == ddDragging) { SelectionPosition selStart = SelectionStart(); SelectionPosition selEnd = SelectionEnd(); if (selStart < selEnd) { if (drag.len) { if (ctrl) { if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) { SetSelection(newPos.Position(), newPos.Position() + drag.len); } } else if (newPos < selStart) { pdoc->DeleteChars(selStart.Position(), drag.len); if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) { SetSelection(newPos.Position(), newPos.Position() + drag.len); } } else if (newPos > selEnd) { pdoc->DeleteChars(selStart.Position(), drag.len); newPos.Add(-drag.len); if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) { SetSelection(newPos.Position(), newPos.Position() + drag.len); } } else { SetEmptySelection(newPos.Position()); } drag.Free(); } selectionType = selChar; } } else { if (selectionType == selChar) { if (sel.Count() > 1) { sel.RangeMain() = SelectionRange(newPos, sel.Range(sel.Count() - 1).anchor); InvalidateSelection(sel.RangeMain(), true); } else { SetSelection(newPos, sel.RangeMain().anchor); } } sel.CommitTentative(); } SetRectangularRange(); lastClickTime = curTime; lastClick = pt; lastXChosen = pt.x + xOffset; if (sel.selType == Selection::selStream) { SetLastXChosen(); } inDragDrop = ddNone; EnsureCaretVisible(false); } } // Called frequently to perform background UI including // caret blinking and automatic scrolling. void Editor::Tick() { if (HaveMouseCapture()) { // Auto scroll ButtonMove(ptMouseLast); } if (caret.period > 0) { timer.ticksToWait -= timer.tickSize; if (timer.ticksToWait <= 0) { caret.on = !caret.on; timer.ticksToWait = caret.period; if (caret.active) { InvalidateCaret(); } } } if (horizontalScrollBarVisible && trackLineWidth && (lineWidthMaxSeen > scrollWidth)) { scrollWidth = lineWidthMaxSeen; SetScrollBars(); } if ((dwellDelay < SC_TIME_FOREVER) && (ticksToDwell > 0) && (!HaveMouseCapture())) { ticksToDwell -= timer.tickSize; if (ticksToDwell <= 0) { dwelling = true; NotifyDwelling(ptMouseLast, dwelling); } } } bool Editor::Idle() { bool idleDone; bool wrappingDone = wrapState == eWrapNone; if (!wrappingDone) { // Wrap lines during idle. WrapLines(false, -1); // No more wrapping if (wrapStart == wrapEnd) wrappingDone = true; } // Add more idle things to do here, but make sure idleDone is // set correctly before the function returns. returning // false will stop calling this idle funtion until SetIdle() is // called again. idleDone = wrappingDone; // && thatDone && theOtherThingDone... return !idleDone; } void Editor::SetFocusState(bool focusState) { hasFocus = focusState; NotifyFocus(hasFocus); if (hasFocus) { ShowCaretAtCurrentPosition(); } else { CancelModes(); DropCaret(); } } int Editor::PositionAfterArea(PRectangle rcArea) { // The start of the document line after the display line after the area // This often means that the line after a modification is restyled which helps // detect multiline comment additions and heals single line comments int lineAfter = topLine + (rcArea.bottom - 1) / vs.lineHeight + 1; if (lineAfter < cs.LinesDisplayed()) return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1); else return pdoc->Length(); } // Style to a position within the view. If this causes a change at end of last line then // affects later lines so style all the viewed text. void Editor::StyleToPositionInView(Position pos) { int endWindow = PositionAfterArea(GetClientRectangle()); if (pos > endWindow) pos = endWindow; int styleAtEnd = pdoc->StyleAt(pos-1); pdoc->EnsureStyledTo(pos); if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) { // Style at end of line changed so is multi-line change like starting a comment // so require rest of window to be styled. pdoc->EnsureStyledTo(endWindow); } } void Editor::IdleStyling() { // Style the line after the modification as this allows modifications that change just the // line of the modification to heal instead of propagating to the rest of the window. StyleToPositionInView(pdoc->LineStart(pdoc->LineFromPosition(styleNeeded.upTo) + 2)); if (needUpdateUI) { NotifyUpdateUI(); needUpdateUI = false; } styleNeeded.Reset(); } void Editor::QueueStyling(int upTo) { styleNeeded.NeedUpTo(upTo); } bool Editor::PaintContains(PRectangle rc) { if (rc.Empty()) { return true; } else { return rcPaint.Contains(rc); } } bool Editor::PaintContainsMargin() { PRectangle rcSelMargin = GetClientRectangle(); rcSelMargin.right = vs.fixedColumnWidth; return PaintContains(rcSelMargin); } void Editor::CheckForChangeOutsidePaint(Range r) { if (paintState == painting && !paintingAllText) { //Platform::DebugPrintf("Checking range in paint %d-%d\n", r.start, r.end); if (!r.Valid()) return; PRectangle rcRange = RectangleFromRange(r.start, r.end); PRectangle rcText = GetTextRectangle(); if (rcRange.top < rcText.top) { rcRange.top = rcText.top; } if (rcRange.bottom > rcText.bottom) { rcRange.bottom = rcText.bottom; } if (!PaintContains(rcRange)) { AbandonPaint(); } } } void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) { if ((pos0 != braces[0]) || (pos1 != braces[1]) || (matchStyle != bracesMatchStyle)) { if ((braces[0] != pos0) || (matchStyle != bracesMatchStyle)) { CheckForChangeOutsidePaint(Range(braces[0])); CheckForChangeOutsidePaint(Range(pos0)); braces[0] = pos0; } if ((braces[1] != pos1) || (matchStyle != bracesMatchStyle)) { CheckForChangeOutsidePaint(Range(braces[1])); CheckForChangeOutsidePaint(Range(pos1)); braces[1] = pos1; } bracesMatchStyle = matchStyle; if (paintState == notPainting) { Redraw(); } } } void Editor::SetAnnotationHeights(int start, int end) { if (vs.annotationVisible) { for (int line=start; line<end; line++) { cs.SetHeight(line, pdoc->AnnotationLines(line) + 1); } } } void Editor::SetDocPointer(Document *document) { //Platform::DebugPrintf("** %x setdoc to %x\n", pdoc, document); pdoc->RemoveWatcher(this, 0); pdoc->Release(); if (document == NULL) { pdoc = new Document(); } else { pdoc = document; } pdoc->AddRef(); // Ensure all positions within document sel.Clear(); targetStart = 0; targetEnd = 0; braces[0] = invalidPosition; braces[1] = invalidPosition; // Reset the contraction state to fully shown. cs.Clear(); cs.InsertLines(0, pdoc->LinesTotal() - 1); SetAnnotationHeights(0, pdoc->LinesTotal()); llc.Deallocate(); NeedWrapping(); pdoc->AddWatcher(this, 0); SetScrollBars(); Redraw(); } void Editor::SetAnnotationVisible(int visible) { if (vs.annotationVisible != visible) { bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0)); vs.annotationVisible = visible; if (changedFromOrToHidden) { int dir = vs.annotationVisible ? 1 : -1; for (int line=0; line<pdoc->LinesTotal(); line++) { int annotationLines = pdoc->AnnotationLines(line); if (annotationLines > 0) { cs.SetHeight(line, cs.GetHeight(line) + annotationLines * dir); } } } Redraw(); } } /** * Recursively expand a fold, making lines visible except where they have an unexpanded parent. */ void Editor::Expand(int &line, bool doExpand) { int lineMaxSubord = pdoc->GetLastChild(line); line++; while (line <= lineMaxSubord) { if (doExpand) cs.SetVisible(line, line, true); int level = pdoc->GetLevel(line); if (level & SC_FOLDLEVELHEADERFLAG) { if (doExpand && cs.GetExpanded(line)) { Expand(line, true); } else { Expand(line, false); } } else { line++; } } } void Editor::ToggleContraction(int line) { if (line >= 0) { if ((pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) == 0) { line = pdoc->GetFoldParent(line); if (line < 0) return; } if (cs.GetExpanded(line)) { int lineMaxSubord = pdoc->GetLastChild(line); cs.SetExpanded(line, 0); if (lineMaxSubord > line) { cs.SetVisible(line + 1, lineMaxSubord, false); int lineCurrent = pdoc->LineFromPosition(sel.MainCaret()); if (lineCurrent > line && lineCurrent <= lineMaxSubord) { // This does not re-expand the fold EnsureCaretVisible(); } SetScrollBars(); Redraw(); } } else { if (!(cs.GetVisible(line))) { EnsureLineVisible(line, false); GoToLine(line); } cs.SetExpanded(line, 1); Expand(line, true); SetScrollBars(); Redraw(); } } } /** * Recurse up from this line to find any folds that prevent this line from being visible * and unfold them all. */ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { // In case in need of wrapping to ensure DisplayFromDoc works. WrapLines(true, -1); if (!cs.GetVisible(lineDoc)) { int lineParent = pdoc->GetFoldParent(lineDoc); if (lineParent >= 0) { if (lineDoc != lineParent) EnsureLineVisible(lineParent, enforcePolicy); if (!cs.GetExpanded(lineParent)) { cs.SetExpanded(lineParent, 1); Expand(lineParent, true); } } SetScrollBars(); Redraw(); } if (enforcePolicy) { int lineDisplay = cs.DisplayFromDoc(lineDoc); if (visiblePolicy & VISIBLE_SLOP) { if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) { SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } else if ((lineDisplay > topLine + LinesOnScreen() - 1) || ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) { SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } } else { if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) { SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); } } } } int Editor::GetTag(char *tagValue, int tagNumber) { char name[3] = "\\?"; const char *text = 0; int length = 0; if ((tagNumber >= 1) && (tagNumber <= 9)) { name[1] = static_cast<char>(tagNumber + '0'); length = 2; text = pdoc->SubstituteByPosition(name, &length); } if (tagValue) { if (text) memcpy(tagValue, text, length + 1); else *tagValue = '\0'; } return length; } int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) { UndoGroup ug(pdoc); if (length == -1) length = istrlen(text); if (replacePatterns) { text = pdoc->SubstituteByPosition(text, &length); if (!text) { return 0; } } if (targetStart != targetEnd) pdoc->DeleteChars(targetStart, targetEnd - targetStart); targetEnd = targetStart; pdoc->InsertString(targetStart, text, length); targetEnd = targetStart + length; return length; } bool Editor::IsUnicodeMode() const { return pdoc && (SC_CP_UTF8 == pdoc->dbcsCodePage); } int Editor::CodePage() const { if (pdoc) return pdoc->dbcsCodePage; else return 0; } int Editor::WrapCount(int line) { AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); if (surface && ll) { LayoutLine(line, surface, vs, ll, wrapWidth); return ll->lines; } else { return 1; } } void Editor::AddStyledText(char *buffer, int appendLength) { // The buffer consists of alternating character bytes and style bytes size_t textLength = appendLength / 2; char *text = new char[textLength]; size_t i; for (i = 0; i < textLength; i++) { text[i] = buffer[i*2]; } pdoc->InsertString(CurrentPosition(), text, textLength); for (i = 0; i < textLength; i++) { text[i] = buffer[i*2+1]; } pdoc->StartStyling(CurrentPosition(), static_cast<char>(0xff)); pdoc->SetStyles(textLength, text); delete []text; SetEmptySelection(sel.MainCaret() + textLength); } static bool ValidMargin(unsigned long wParam) { return wParam < ViewStyle::margins; } static char *CharPtrFromSPtr(sptr_t lParam) { return reinterpret_cast<char *>(lParam); } void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLESETFORE: vs.styles[wParam].fore.desired = ColourDesired(lParam); break; case SCI_STYLESETBACK: vs.styles[wParam].back.desired = ColourDesired(lParam); break; case SCI_STYLESETBOLD: vs.styles[wParam].bold = lParam != 0; break; case SCI_STYLESETITALIC: vs.styles[wParam].italic = lParam != 0; break; case SCI_STYLESETEOLFILLED: vs.styles[wParam].eolFilled = lParam != 0; break; case SCI_STYLESETSIZE: vs.styles[wParam].size = lParam; break; case SCI_STYLESETFONT: if (lParam != 0) { vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam)); } break; case SCI_STYLESETUNDERLINE: vs.styles[wParam].underline = lParam != 0; break; case SCI_STYLESETCASE: vs.styles[wParam].caseForce = static_cast<Style::ecaseForced>(lParam); break; case SCI_STYLESETCHARACTERSET: vs.styles[wParam].characterSet = lParam; break; case SCI_STYLESETVISIBLE: vs.styles[wParam].visible = lParam != 0; break; case SCI_STYLESETCHANGEABLE: vs.styles[wParam].changeable = lParam != 0; break; case SCI_STYLESETHOTSPOT: vs.styles[wParam].hotspot = lParam != 0; break; } InvalidateStyleRedraw(); } sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLEGETFORE: return vs.styles[wParam].fore.desired.AsLong(); case SCI_STYLEGETBACK: return vs.styles[wParam].back.desired.AsLong(); case SCI_STYLEGETBOLD: return vs.styles[wParam].bold ? 1 : 0; case SCI_STYLEGETITALIC: return vs.styles[wParam].italic ? 1 : 0; case SCI_STYLEGETEOLFILLED: return vs.styles[wParam].eolFilled ? 1 : 0; case SCI_STYLEGETSIZE: return vs.styles[wParam].size; case SCI_STYLEGETFONT: if (!vs.styles[wParam].fontName) return 0; if (lParam != 0) strcpy(CharPtrFromSPtr(lParam), vs.styles[wParam].fontName); return strlen(vs.styles[wParam].fontName); case SCI_STYLEGETUNDERLINE: return vs.styles[wParam].underline ? 1 : 0; case SCI_STYLEGETCASE: return static_cast<int>(vs.styles[wParam].caseForce); case SCI_STYLEGETCHARACTERSET: return vs.styles[wParam].characterSet; case SCI_STYLEGETVISIBLE: return vs.styles[wParam].visible ? 1 : 0; case SCI_STYLEGETCHANGEABLE: return vs.styles[wParam].changeable ? 1 : 0; case SCI_STYLEGETHOTSPOT: return vs.styles[wParam].hotspot ? 1 : 0; } return 0; } sptr_t Editor::StringResult(sptr_t lParam, const char *val) { const int n = strlen(val); if (lParam != 0) { char *ptr = reinterpret_cast<char *>(lParam); strcpy(ptr, val); } return n; // Not including NUL } sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { //Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam); // Optional macro recording hook if (recordingMacro) NotifyMacroRecord(iMessage, wParam, lParam); switch (iMessage) { case SCI_GETTEXT: { if (lParam == 0) return pdoc->Length() + 1; if (wParam == 0) return 0; char *ptr = CharPtrFromSPtr(lParam); unsigned int iChar = 0; for (; iChar < wParam - 1; iChar++) ptr[iChar] = pdoc->CharAt(iChar); ptr[iChar] = '\0'; return iChar; } case SCI_SETTEXT: { if (lParam == 0) return 0; UndoGroup ug(pdoc); pdoc->DeleteChars(0, pdoc->Length()); SetEmptySelection(0); pdoc->InsertCString(0, CharPtrFromSPtr(lParam)); return 1; } case SCI_GETTEXTLENGTH: return pdoc->Length(); case SCI_CUT: Cut(); SetLastXChosen(); break; case SCI_COPY: Copy(); break; case SCI_COPYALLOWLINE: CopyAllowLine(); break; case SCI_COPYRANGE: CopyRangeToClipboard(wParam, lParam); break; case SCI_COPYTEXT: CopyText(wParam, CharPtrFromSPtr(lParam)); break; case SCI_PASTE: Paste(); if ((caretSticky == SC_CARETSTICKY_OFF) || (caretSticky == SC_CARETSTICKY_WHITESPACE)) { SetLastXChosen(); } EnsureCaretVisible(); break; case SCI_CLEAR: Clear(); SetLastXChosen(); EnsureCaretVisible(); break; case SCI_UNDO: Undo(); SetLastXChosen(); break; case SCI_CANUNDO: return (pdoc->CanUndo() && !pdoc->IsReadOnly()) ? 1 : 0; case SCI_EMPTYUNDOBUFFER: pdoc->DeleteUndoHistory(); return 0; case SCI_GETFIRSTVISIBLELINE: return topLine; case SCI_SETFIRSTVISIBLELINE: ScrollTo(wParam); break; case SCI_GETLINE: { // Risk of overwriting the end of the buffer int lineStart = pdoc->LineStart(wParam); int lineEnd = pdoc->LineStart(wParam + 1); if (lParam == 0) { return lineEnd - lineStart; } char *ptr = CharPtrFromSPtr(lParam); int iPlace = 0; for (int iChar = lineStart; iChar < lineEnd; iChar++) { ptr[iPlace++] = pdoc->CharAt(iChar); } return iPlace; } case SCI_GETLINECOUNT: if (pdoc->LinesTotal() == 0) return 1; else return pdoc->LinesTotal(); case SCI_GETMODIFY: return !pdoc->IsSavePoint(); case SCI_SETSEL: { int nStart = static_cast<int>(wParam); int nEnd = static_cast<int>(lParam); if (nEnd < 0) nEnd = pdoc->Length(); if (nStart < 0) nStart = nEnd; // Remove selection InvalidateSelection(SelectionRange(nStart, nEnd)); sel.Clear(); sel.selType = Selection::selStream; SetSelection(nEnd, nStart); EnsureCaretVisible(); } break; case SCI_GETSELTEXT: { SelectionText selectedText; CopySelectionRange(&selectedText); if (lParam == 0) { return selectedText.len ? selectedText.len : 1; } else { char *ptr = CharPtrFromSPtr(lParam); int iChar = 0; if (selectedText.len) { for (; iChar < selectedText.len; iChar++) ptr[iChar] = selectedText.s[iChar]; } else { ptr[0] = '\0'; } return iChar; } } case SCI_LINEFROMPOSITION: if (static_cast<int>(wParam) < 0) return 0; return pdoc->LineFromPosition(wParam); case SCI_POSITIONFROMLINE: if (static_cast<int>(wParam) < 0) wParam = pdoc->LineFromPosition(SelectionStart().Position()); if (wParam == 0) return 0; // Even if there is no text, there is a first line that starts at 0 if (static_cast<int>(wParam) > pdoc->LinesTotal()) return -1; //if (wParam > pdoc->LineFromPosition(pdoc->Length())) // Useful test, anyway... // return -1; return pdoc->LineStart(wParam); // Replacement of the old Scintilla interpretation of EM_LINELENGTH case SCI_LINELENGTH: if ((static_cast<int>(wParam) < 0) || (static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length()))) return 0; return pdoc->LineStart(wParam + 1) - pdoc->LineStart(wParam); case SCI_REPLACESEL: { if (lParam == 0) return 0; UndoGroup ug(pdoc); ClearSelection(); char *replacement = CharPtrFromSPtr(lParam); pdoc->InsertCString(sel.MainCaret(), replacement); SetEmptySelection(sel.MainCaret() + istrlen(replacement)); EnsureCaretVisible(); } break; case SCI_SETTARGETSTART: targetStart = wParam; break; case SCI_GETTARGETSTART: return targetStart; case SCI_SETTARGETEND: targetEnd = wParam; break; case SCI_GETTARGETEND: return targetEnd; case SCI_TARGETFROMSELECTION: if (sel.MainCaret() < sel.MainAnchor()) { targetStart = sel.MainCaret(); targetEnd = sel.MainAnchor(); } else { targetStart = sel.MainAnchor(); targetEnd = sel.MainCaret(); } break; case SCI_REPLACETARGET: PLATFORM_ASSERT(lParam); return ReplaceTarget(false, CharPtrFromSPtr(lParam), wParam); case SCI_REPLACETARGETRE: PLATFORM_ASSERT(lParam); return ReplaceTarget(true, CharPtrFromSPtr(lParam), wParam); case SCI_SEARCHINTARGET: PLATFORM_ASSERT(lParam); return SearchInTarget(CharPtrFromSPtr(lParam), wParam); case SCI_SETSEARCHFLAGS: searchFlags = wParam; break; case SCI_GETSEARCHFLAGS: return searchFlags; case SCI_GETTAG: return GetTag(CharPtrFromSPtr(lParam), wParam); case SCI_POSITIONBEFORE: return pdoc->MovePositionOutsideChar(wParam - 1, -1, true); case SCI_POSITIONAFTER: return pdoc->MovePositionOutsideChar(wParam + 1, 1, true); case SCI_LINESCROLL: ScrollTo(topLine + lParam); HorizontalScrollTo(xOffset + wParam * vs.spaceWidth); return 1; case SCI_SETXOFFSET: xOffset = wParam; SetHorizontalScrollPos(); Redraw(); break; case SCI_GETXOFFSET: return xOffset; case SCI_CHOOSECARETX: SetLastXChosen(); break; case SCI_SCROLLCARET: EnsureCaretVisible(); break; case SCI_SETREADONLY: pdoc->SetReadOnly(wParam != 0); return 1; case SCI_GETREADONLY: return pdoc->IsReadOnly(); case SCI_CANPASTE: return CanPaste(); case SCI_POINTXFROMPOSITION: if (lParam < 0) { return 0; } else { Point pt = LocationFromPosition(lParam); return pt.x; } case SCI_POINTYFROMPOSITION: if (lParam < 0) { return 0; } else { Point pt = LocationFromPosition(lParam); return pt.y; } case SCI_FINDTEXT: return FindText(wParam, lParam); case SCI_GETTEXTRANGE: { if (lParam == 0) return 0; Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam); int cpMax = tr->chrg.cpMax; if (cpMax == -1) cpMax = pdoc->Length(); PLATFORM_ASSERT(cpMax <= pdoc->Length()); int len = cpMax - tr->chrg.cpMin; // No -1 as cpMin and cpMax are referring to inter character positions pdoc->GetCharRange(tr->lpstrText, tr->chrg.cpMin, len); // Spec says copied text is terminated with a NUL tr->lpstrText[len] = '\0'; return len; // Not including NUL } case SCI_HIDESELECTION: hideSelection = wParam != 0; Redraw(); break; case SCI_FORMATRANGE: return FormatRange(wParam != 0, reinterpret_cast<Sci_RangeToFormat *>(lParam)); case SCI_GETMARGINLEFT: return vs.leftMarginWidth; case SCI_GETMARGINRIGHT: return vs.rightMarginWidth; case SCI_SETMARGINLEFT: vs.leftMarginWidth = lParam; InvalidateStyleRedraw(); break; case SCI_SETMARGINRIGHT: vs.rightMarginWidth = lParam; InvalidateStyleRedraw(); break; // Control specific mesages case SCI_ADDTEXT: { if (lParam == 0) return 0; pdoc->InsertString(CurrentPosition(), CharPtrFromSPtr(lParam), wParam); SetEmptySelection(sel.MainCaret() + wParam); return 0; } case SCI_ADDSTYLEDTEXT: if (lParam) AddStyledText(CharPtrFromSPtr(lParam), wParam); return 0; case SCI_INSERTTEXT: { if (lParam == 0) return 0; int insertPos = wParam; if (static_cast<int>(wParam) == -1) insertPos = CurrentPosition(); int newCurrent = CurrentPosition(); char *sz = CharPtrFromSPtr(lParam); pdoc->InsertCString(insertPos, sz); if (newCurrent > insertPos) newCurrent += istrlen(sz); SetEmptySelection(newCurrent); return 0; } case SCI_APPENDTEXT: pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), wParam); return 0; case SCI_CLEARALL: ClearAll(); return 0; case SCI_CLEARDOCUMENTSTYLE: ClearDocumentStyle(); return 0; case SCI_SETUNDOCOLLECTION: pdoc->SetUndoCollection(wParam != 0); return 0; case SCI_GETUNDOCOLLECTION: return pdoc->IsCollectingUndo(); case SCI_BEGINUNDOACTION: pdoc->BeginUndoAction(); return 0; case SCI_ENDUNDOACTION: pdoc->EndUndoAction(); return 0; case SCI_GETCARETPERIOD: return caret.period; case SCI_SETCARETPERIOD: caret.period = wParam; break; case SCI_SETWORDCHARS: { pdoc->SetDefaultCharClasses(false); if (lParam == 0) return 0; pdoc->SetCharClasses(reinterpret_cast<unsigned char *>(lParam), CharClassify::ccWord); } break; case SCI_SETWHITESPACECHARS: { if (lParam == 0) return 0; pdoc->SetCharClasses(reinterpret_cast<unsigned char *>(lParam), CharClassify::ccSpace); } break; case SCI_SETCHARSDEFAULT: pdoc->SetDefaultCharClasses(true); break; case SCI_GETLENGTH: return pdoc->Length(); case SCI_ALLOCATE: pdoc->Allocate(wParam); break; case SCI_GETCHARAT: return pdoc->CharAt(wParam); case SCI_SETCURRENTPOS: if (sel.IsRectangular()) { sel.Rectangular().caret.SetPosition(wParam); SetRectangularRange(); Redraw(); } else { SetSelection(wParam, sel.MainAnchor()); } break; case SCI_GETCURRENTPOS: return sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret(); case SCI_SETANCHOR: if (sel.IsRectangular()) { sel.Rectangular().anchor.SetPosition(wParam); SetRectangularRange(); Redraw(); } else { SetSelection(sel.MainCaret(), wParam); } break; case SCI_GETANCHOR: return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor(); case SCI_SETSELECTIONSTART: SetSelection(Platform::Maximum(sel.MainCaret(), wParam), wParam); break; case SCI_GETSELECTIONSTART: return sel.LimitsForRectangularElseMain().start.Position(); case SCI_SETSELECTIONEND: SetSelection(wParam, Platform::Minimum(sel.MainAnchor(), wParam)); break; case SCI_GETSELECTIONEND: return sel.LimitsForRectangularElseMain().end.Position(); case SCI_SETPRINTMAGNIFICATION: printMagnification = wParam; break; case SCI_GETPRINTMAGNIFICATION: return printMagnification; case SCI_SETPRINTCOLOURMODE: printColourMode = wParam; break; case SCI_GETPRINTCOLOURMODE: return printColourMode; case SCI_SETPRINTWRAPMODE: printWrapState = (wParam == SC_WRAP_WORD) ? eWrapWord : eWrapNone; break; case SCI_GETPRINTWRAPMODE: return printWrapState; case SCI_GETSTYLEAT: if (static_cast<int>(wParam) >= pdoc->Length()) return 0; else return pdoc->StyleAt(wParam); case SCI_REDO: Redo(); break; case SCI_SELECTALL: SelectAll(); break; case SCI_SETSAVEPOINT: pdoc->SetSavePoint(); break; case SCI_GETSTYLEDTEXT: { if (lParam == 0) return 0; Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam); int iPlace = 0; for (int iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) { tr->lpstrText[iPlace++] = pdoc->CharAt(iChar); tr->lpstrText[iPlace++] = pdoc->StyleAt(iChar); } tr->lpstrText[iPlace] = '\0'; tr->lpstrText[iPlace + 1] = '\0'; return iPlace; } case SCI_CANREDO: return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0; case SCI_MARKERLINEFROMHANDLE: return pdoc->LineFromHandle(wParam); case SCI_MARKERDELETEHANDLE: pdoc->DeleteMarkFromHandle(wParam); break; case SCI_GETVIEWWS: return vs.viewWhitespace; case SCI_SETVIEWWS: vs.viewWhitespace = static_cast<WhiteSpaceVisibility>(wParam); Redraw(); break; case SCI_GETWHITESPACESIZE: return vs.whitespaceSize; case SCI_SETWHITESPACESIZE: vs.whitespaceSize = static_cast<int>(wParam); Redraw(); break; case SCI_POSITIONFROMPOINT: return PositionFromLocation(Point(wParam, lParam), false, false); case SCI_POSITIONFROMPOINTCLOSE: return PositionFromLocation(Point(wParam, lParam), true, false); case SCI_CHARPOSITIONFROMPOINT: return PositionFromLocation(Point(wParam, lParam), false, true); case SCI_CHARPOSITIONFROMPOINTCLOSE: return PositionFromLocation(Point(wParam, lParam), true, true); case SCI_GOTOLINE: GoToLine(wParam); break; case SCI_GOTOPOS: SetEmptySelection(wParam); EnsureCaretVisible(); Redraw(); break; case SCI_GETCURLINE: { int lineCurrentPos = pdoc->LineFromPosition(sel.MainCaret()); int lineStart = pdoc->LineStart(lineCurrentPos); unsigned int lineEnd = pdoc->LineStart(lineCurrentPos + 1); if (lParam == 0) { return 1 + lineEnd - lineStart; } PLATFORM_ASSERT(wParam > 0); char *ptr = CharPtrFromSPtr(lParam); unsigned int iPlace = 0; for (unsigned int iChar = lineStart; iChar < lineEnd && iPlace < wParam - 1; iChar++) { ptr[iPlace++] = pdoc->CharAt(iChar); } ptr[iPlace] = '\0'; return sel.MainCaret() - lineStart; } case SCI_GETENDSTYLED: return pdoc->GetEndStyled(); case SCI_GETEOLMODE: return pdoc->eolMode; case SCI_SETEOLMODE: pdoc->eolMode = wParam; break; case SCI_STARTSTYLING: pdoc->StartStyling(wParam, static_cast<char>(lParam)); break; case SCI_SETSTYLING: pdoc->SetStyleFor(wParam, static_cast<char>(lParam)); break; case SCI_SETSTYLINGEX: // Specify a complete styling buffer if (lParam == 0) return 0; pdoc->SetStyles(wParam, CharPtrFromSPtr(lParam)); break; case SCI_SETBUFFEREDDRAW: bufferedDraw = wParam != 0; break; case SCI_GETBUFFEREDDRAW: return bufferedDraw; case SCI_GETTWOPHASEDRAW: return twoPhaseDraw; case SCI_SETTWOPHASEDRAW: twoPhaseDraw = wParam != 0; InvalidateStyleRedraw(); break; case SCI_SETFONTQUALITY: vs.extraFontFlag &= ~SC_EFF_QUALITY_MASK; vs.extraFontFlag |= (wParam & SC_EFF_QUALITY_MASK); InvalidateStyleRedraw(); break; case SCI_GETFONTQUALITY: return (vs.extraFontFlag & SC_EFF_QUALITY_MASK); case SCI_SETTABWIDTH: if (wParam > 0) { pdoc->tabInChars = wParam; if (pdoc->indentInChars == 0) pdoc->actualIndentInChars = pdoc->tabInChars; } InvalidateStyleRedraw(); break; case SCI_GETTABWIDTH: return pdoc->tabInChars; case SCI_SETINDENT: pdoc->indentInChars = wParam; if (pdoc->indentInChars != 0) pdoc->actualIndentInChars = pdoc->indentInChars; else pdoc->actualIndentInChars = pdoc->tabInChars; InvalidateStyleRedraw(); break; case SCI_GETINDENT: return pdoc->indentInChars; case SCI_SETUSETABS: pdoc->useTabs = wParam != 0; InvalidateStyleRedraw(); break; case SCI_GETUSETABS: return pdoc->useTabs; case SCI_SETLINEINDENTATION: pdoc->SetLineIndentation(wParam, lParam); break; case SCI_GETLINEINDENTATION: return pdoc->GetLineIndentation(wParam); case SCI_GETLINEINDENTPOSITION: return pdoc->GetLineIndentPosition(wParam); case SCI_SETTABINDENTS: pdoc->tabIndents = wParam != 0; break; case SCI_GETTABINDENTS: return pdoc->tabIndents; case SCI_SETBACKSPACEUNINDENTS: pdoc->backspaceUnindents = wParam != 0; break; case SCI_GETBACKSPACEUNINDENTS: return pdoc->backspaceUnindents; case SCI_SETMOUSEDWELLTIME: dwellDelay = wParam; ticksToDwell = dwellDelay; break; case SCI_GETMOUSEDWELLTIME: return dwellDelay; case SCI_WORDSTARTPOSITION: return pdoc->ExtendWordSelect(wParam, -1, lParam != 0); case SCI_WORDENDPOSITION: return pdoc->ExtendWordSelect(wParam, 1, lParam != 0); case SCI_SETWRAPMODE: switch (wParam) { case SC_WRAP_WORD: wrapState = eWrapWord; break; case SC_WRAP_CHAR: wrapState = eWrapChar; break; default: wrapState = eWrapNone; break; } xOffset = 0; InvalidateStyleRedraw(); ReconfigureScrollBars(); break; case SCI_GETWRAPMODE: return wrapState; case SCI_SETWRAPVISUALFLAGS: if (wrapVisualFlags != static_cast<int>(wParam)) { wrapVisualFlags = wParam; InvalidateStyleRedraw(); ReconfigureScrollBars(); } break; case SCI_GETWRAPVISUALFLAGS: return wrapVisualFlags; case SCI_SETWRAPVISUALFLAGSLOCATION: wrapVisualFlagsLocation = wParam; InvalidateStyleRedraw(); break; case SCI_GETWRAPVISUALFLAGSLOCATION: return wrapVisualFlagsLocation; case SCI_SETWRAPSTARTINDENT: if (wrapVisualStartIndent != static_cast<int>(wParam)) { wrapVisualStartIndent = wParam; InvalidateStyleRedraw(); ReconfigureScrollBars(); } break; case SCI_GETWRAPSTARTINDENT: return wrapVisualStartIndent; case SCI_SETWRAPINDENTMODE: if (wrapIndentMode != static_cast<int>(wParam)) { wrapIndentMode = wParam; InvalidateStyleRedraw(); ReconfigureScrollBars(); } break; case SCI_GETWRAPINDENTMODE: return wrapIndentMode; case SCI_SETLAYOUTCACHE: llc.SetLevel(wParam); break; case SCI_GETLAYOUTCACHE: return llc.GetLevel(); case SCI_SETPOSITIONCACHE: posCache.SetSize(wParam); break; case SCI_GETPOSITIONCACHE: return posCache.GetSize(); case SCI_SETSCROLLWIDTH: PLATFORM_ASSERT(wParam > 0); if ((wParam > 0) && (wParam != static_cast<unsigned int >(scrollWidth))) { lineWidthMaxSeen = 0; scrollWidth = wParam; SetScrollBars(); } break; case SCI_GETSCROLLWIDTH: return scrollWidth; case SCI_SETSCROLLWIDTHTRACKING: trackLineWidth = wParam != 0; break; case SCI_GETSCROLLWIDTHTRACKING: return trackLineWidth; case SCI_LINESJOIN: LinesJoin(); break; case SCI_LINESSPLIT: LinesSplit(wParam); break; case SCI_TEXTWIDTH: PLATFORM_ASSERT(wParam < vs.stylesSize); PLATFORM_ASSERT(lParam); return TextWidth(wParam, CharPtrFromSPtr(lParam)); case SCI_TEXTHEIGHT: return vs.lineHeight; case SCI_SETENDATLASTLINE: PLATFORM_ASSERT((wParam == 0) || (wParam == 1)); if (endAtLastLine != (wParam != 0)) { endAtLastLine = wParam != 0; SetScrollBars(); } break; case SCI_GETENDATLASTLINE: return endAtLastLine; case SCI_SETCARETSTICKY: PLATFORM_ASSERT((wParam >= SC_CARETSTICKY_OFF) && (wParam <= SC_CARETSTICKY_WHITESPACE)); if ((wParam >= SC_CARETSTICKY_OFF) && (wParam <= SC_CARETSTICKY_WHITESPACE)) { caretSticky = wParam; } break; case SCI_GETCARETSTICKY: return caretSticky; case SCI_TOGGLECARETSTICKY: caretSticky = !caretSticky; break; case SCI_GETCOLUMN: return pdoc->GetColumn(wParam); case SCI_FINDCOLUMN: return pdoc->FindColumn(wParam, lParam); case SCI_SETHSCROLLBAR : if (horizontalScrollBarVisible != (wParam != 0)) { horizontalScrollBarVisible = wParam != 0; SetScrollBars(); ReconfigureScrollBars(); } break; case SCI_GETHSCROLLBAR: return horizontalScrollBarVisible; case SCI_SETVSCROLLBAR: if (verticalScrollBarVisible != (wParam != 0)) { verticalScrollBarVisible = wParam != 0; SetScrollBars(); ReconfigureScrollBars(); } break; case SCI_GETVSCROLLBAR: return verticalScrollBarVisible; case SCI_SETINDENTATIONGUIDES: vs.viewIndentationGuides = IndentView(wParam); Redraw(); break; case SCI_GETINDENTATIONGUIDES: return vs.viewIndentationGuides; case SCI_SETHIGHLIGHTGUIDE: if ((highlightGuideColumn != static_cast<int>(wParam)) || (wParam > 0)) { highlightGuideColumn = wParam; Redraw(); } break; case SCI_GETHIGHLIGHTGUIDE: return highlightGuideColumn; case SCI_GETLINEENDPOSITION: return pdoc->LineEnd(wParam); case SCI_SETCODEPAGE: if (ValidCodePage(wParam)) { pdoc->dbcsCodePage = wParam; InvalidateStyleRedraw(); } break; case SCI_GETCODEPAGE: return pdoc->dbcsCodePage; case SCI_SETUSEPALETTE: palette.allowRealization = wParam != 0; InvalidateStyleRedraw(); break; case SCI_GETUSEPALETTE: return palette.allowRealization; // Marker definition and setting case SCI_MARKERDEFINE: if (wParam <= MARKER_MAX) vs.markers[wParam].markType = lParam; InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSYMBOLDEFINED: if (wParam <= MARKER_MAX) return vs.markers[wParam].markType; else return 0; case SCI_MARKERSETFORE: if (wParam <= MARKER_MAX) vs.markers[wParam].fore.desired = ColourDesired(lParam); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSETBACK: if (wParam <= MARKER_MAX) vs.markers[wParam].back.desired = ColourDesired(lParam); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSETALPHA: if (wParam <= MARKER_MAX) vs.markers[wParam].alpha = lParam; InvalidateStyleRedraw(); break; case SCI_MARKERADD: { int markerID = pdoc->AddMark(wParam, lParam); return markerID; } case SCI_MARKERADDSET: if (lParam != 0) pdoc->AddMarkSet(wParam, lParam); break; case SCI_MARKERDELETE: pdoc->DeleteMark(wParam, lParam); break; case SCI_MARKERDELETEALL: pdoc->DeleteAllMarks(static_cast<int>(wParam)); break; case SCI_MARKERGET: return pdoc->GetMark(wParam); case SCI_MARKERNEXT: { int lt = pdoc->LinesTotal(); for (int iLine = wParam; iLine < lt; iLine++) { if ((pdoc->GetMark(iLine) & lParam) != 0) return iLine; } } return -1; case SCI_MARKERPREVIOUS: { for (int iLine = wParam; iLine >= 0; iLine--) { if ((pdoc->GetMark(iLine) & lParam) != 0) return iLine; } } return -1; case SCI_MARKERDEFINEPIXMAP: if (wParam <= MARKER_MAX) { vs.markers[wParam].SetXPM(CharPtrFromSPtr(lParam)); }; InvalidateStyleData(); RedrawSelMargin(); break; case SCI_SETMARGINTYPEN: if (ValidMargin(wParam)) { vs.ms[wParam].style = lParam; InvalidateStyleRedraw(); } break; case SCI_GETMARGINTYPEN: if (ValidMargin(wParam)) return vs.ms[wParam].style; else return 0; case SCI_SETMARGINWIDTHN: if (ValidMargin(wParam)) { // Short-circuit if the width is unchanged, to avoid unnecessary redraw. if (vs.ms[wParam].width != lParam) { vs.ms[wParam].width = lParam; InvalidateStyleRedraw(); } } break; case SCI_GETMARGINWIDTHN: if (ValidMargin(wParam)) return vs.ms[wParam].width; else return 0; case SCI_SETMARGINMASKN: if (ValidMargin(wParam)) { vs.ms[wParam].mask = lParam; InvalidateStyleRedraw(); } break; case SCI_GETMARGINMASKN: if (ValidMargin(wParam)) return vs.ms[wParam].mask; else return 0; case SCI_SETMARGINSENSITIVEN: if (ValidMargin(wParam)) { vs.ms[wParam].sensitive = lParam != 0; InvalidateStyleRedraw(); } break; case SCI_GETMARGINSENSITIVEN: if (ValidMargin(wParam)) return vs.ms[wParam].sensitive ? 1 : 0; else return 0; case SCI_STYLECLEARALL: vs.ClearStyles(); InvalidateStyleRedraw(); break; case SCI_STYLESETFORE: case SCI_STYLESETBACK: case SCI_STYLESETBOLD: case SCI_STYLESETITALIC: case SCI_STYLESETEOLFILLED: case SCI_STYLESETSIZE: case SCI_STYLESETFONT: case SCI_STYLESETUNDERLINE: case SCI_STYLESETCASE: case SCI_STYLESETCHARACTERSET: case SCI_STYLESETVISIBLE: case SCI_STYLESETCHANGEABLE: case SCI_STYLESETHOTSPOT: StyleSetMessage(iMessage, wParam, lParam); break; case SCI_STYLEGETFORE: case SCI_STYLEGETBACK: case SCI_STYLEGETBOLD: case SCI_STYLEGETITALIC: case SCI_STYLEGETEOLFILLED: case SCI_STYLEGETSIZE: case SCI_STYLEGETFONT: case SCI_STYLEGETUNDERLINE: case SCI_STYLEGETCASE: case SCI_STYLEGETCHARACTERSET: case SCI_STYLEGETVISIBLE: case SCI_STYLEGETCHANGEABLE: case SCI_STYLEGETHOTSPOT: return StyleGetMessage(iMessage, wParam, lParam); case SCI_STYLERESETDEFAULT: vs.ResetDefaultStyle(); InvalidateStyleRedraw(); break; case SCI_SETSTYLEBITS: vs.EnsureStyle((1 << wParam) - 1); pdoc->SetStylingBits(wParam); break; case SCI_GETSTYLEBITS: return pdoc->stylingBits; case SCI_SETLINESTATE: return pdoc->SetLineState(wParam, lParam); case SCI_GETLINESTATE: return pdoc->GetLineState(wParam); case SCI_GETMAXLINESTATE: return pdoc->GetMaxLineState(); case SCI_GETCARETLINEVISIBLE: return vs.showCaretLineBackground; case SCI_SETCARETLINEVISIBLE: vs.showCaretLineBackground = wParam != 0; InvalidateStyleRedraw(); break; case SCI_GETCARETLINEVISIBLEALWAYS: return vs.showCaretLineBackgroundAlways; case SCI_SETCARETLINEVISIBLEALWAYS: vs.showCaretLineBackgroundAlways = wParam != 0; InvalidateStyleRedraw(); break; case SCI_GETCARETLINEBACK: return vs.caretLineBackground.desired.AsLong(); case SCI_SETCARETLINEBACK: vs.caretLineBackground.desired = wParam; InvalidateStyleRedraw(); break; case SCI_GETCARETLINEBACKALPHA: return vs.caretLineAlpha; case SCI_SETCARETLINEBACKALPHA: vs.caretLineAlpha = wParam; InvalidateStyleRedraw(); break; // Folding messages case SCI_VISIBLEFROMDOCLINE: return cs.DisplayFromDoc(wParam); case SCI_DOCLINEFROMVISIBLE: return cs.DocFromDisplay(wParam); case SCI_WRAPCOUNT: return WrapCount(wParam); case SCI_SETFOLDLEVEL: { int prev = pdoc->SetLevel(wParam, lParam); if (prev != lParam) RedrawSelMargin(); return prev; } case SCI_GETFOLDLEVEL: return pdoc->GetLevel(wParam); case SCI_GETLASTCHILD: return pdoc->GetLastChild(wParam, lParam); case SCI_GETFOLDPARENT: return pdoc->GetFoldParent(wParam); case SCI_SHOWLINES: cs.SetVisible(wParam, lParam, true); SetScrollBars(); Redraw(); break; case SCI_HIDELINES: if (wParam > 0) cs.SetVisible(wParam, lParam, false); SetScrollBars(); Redraw(); break; case SCI_GETLINEVISIBLE: return cs.GetVisible(wParam); case SCI_SETFOLDEXPANDED: if (cs.SetExpanded(wParam, lParam != 0)) { RedrawSelMargin(); } break; case SCI_GETFOLDEXPANDED: return cs.GetExpanded(wParam); case SCI_SETFOLDFLAGS: foldFlags = wParam; Redraw(); break; case SCI_TOGGLEFOLD: ToggleContraction(wParam); break; case SCI_ENSUREVISIBLE: EnsureLineVisible(wParam, false); break; case SCI_ENSUREVISIBLEENFORCEPOLICY: EnsureLineVisible(wParam, true); break; case SCI_SEARCHANCHOR: SearchAnchor(); break; case SCI_SEARCHNEXT: case SCI_SEARCHPREV: return SearchText(iMessage, wParam, lParam); case SCI_SETXCARETPOLICY: caretXPolicy = wParam; caretXSlop = lParam; break; case SCI_SETYCARETPOLICY: caretYPolicy = wParam; caretYSlop = lParam; break; case SCI_SETVISIBLEPOLICY: visiblePolicy = wParam; visibleSlop = lParam; break; case SCI_LINESONSCREEN: return LinesOnScreen(); case SCI_SETSELFORE: vs.selforeset = wParam != 0; vs.selforeground.desired = ColourDesired(lParam); vs.selAdditionalForeground.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETSELBACK: vs.selbackset = wParam != 0; vs.selbackground.desired = ColourDesired(lParam); vs.selAdditionalBackground.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETSELALPHA: vs.selAlpha = wParam; vs.selAdditionalAlpha = wParam; InvalidateStyleRedraw(); break; case SCI_GETSELALPHA: return vs.selAlpha; case SCI_GETSELEOLFILLED: return vs.selEOLFilled; case SCI_SETSELEOLFILLED: vs.selEOLFilled = wParam != 0; InvalidateStyleRedraw(); break; case SCI_SETWHITESPACEFORE: vs.whitespaceForegroundSet = wParam != 0; vs.whitespaceForeground.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETWHITESPACEBACK: vs.whitespaceBackgroundSet = wParam != 0; vs.whitespaceBackground.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETCARETFORE: vs.caretcolour.desired = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_GETCARETFORE: return vs.caretcolour.desired.AsLong(); case SCI_SETCARETSTYLE: if (wParam >= CARETSTYLE_INVISIBLE && wParam <= CARETSTYLE_BLOCK) vs.caretStyle = wParam; else /* Default to the line caret */ vs.caretStyle = CARETSTYLE_LINE; InvalidateStyleRedraw(); break; case SCI_GETCARETSTYLE: return vs.caretStyle; case SCI_SETCARETWIDTH: if (wParam <= 0) vs.caretWidth = 0; else if (wParam >= 3) vs.caretWidth = 3; else vs.caretWidth = wParam; InvalidateStyleRedraw(); break; case SCI_GETCARETWIDTH: return vs.caretWidth; case SCI_ASSIGNCMDKEY: kmap.AssignCmdKey(Platform::LowShortFromLong(wParam), Platform::HighShortFromLong(wParam), lParam); break; case SCI_CLEARCMDKEY: kmap.AssignCmdKey(Platform::LowShortFromLong(wParam), Platform::HighShortFromLong(wParam), SCI_NULL); break; case SCI_CLEARALLCMDKEYS: kmap.Clear(); break; case SCI_INDICSETSTYLE: if (wParam <= INDIC_MAX) { vs.indicators[wParam].style = lParam; InvalidateStyleRedraw(); } break; case SCI_INDICGETSTYLE: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].style : 0; case SCI_INDICSETFORE: if (wParam <= INDIC_MAX) { vs.indicators[wParam].fore.desired = ColourDesired(lParam); InvalidateStyleRedraw(); } break; case SCI_INDICGETFORE: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.desired.AsLong() : 0; case SCI_INDICSETUNDER: if (wParam <= INDIC_MAX) { vs.indicators[wParam].under = lParam != 0; InvalidateStyleRedraw(); } break; case SCI_INDICGETUNDER: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].under : 0; case SCI_INDICSETALPHA: if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) { vs.indicators[wParam].fillAlpha = lParam; InvalidateStyleRedraw(); } break; case SCI_INDICGETALPHA: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fillAlpha : 0; case SCI_SETINDICATORCURRENT: pdoc->decorations.SetCurrentIndicator(wParam); break; case SCI_GETINDICATORCURRENT: return pdoc->decorations.GetCurrentIndicator(); case SCI_SETINDICATORVALUE: pdoc->decorations.SetCurrentValue(wParam); break; case SCI_GETINDICATORVALUE: return pdoc->decorations.GetCurrentValue(); case SCI_INDICATORFILLRANGE: pdoc->DecorationFillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam); break; case SCI_INDICATORCLEARRANGE: pdoc->DecorationFillRange(wParam, 0, lParam); break; case SCI_INDICATORALLONFOR: return pdoc->decorations.AllOnFor(wParam); case SCI_INDICATORVALUEAT: return pdoc->decorations.ValueAt(wParam, lParam); case SCI_INDICATORSTART: return pdoc->decorations.Start(wParam, lParam); case SCI_INDICATOREND: return pdoc->decorations.End(wParam, lParam); case SCI_LINEDOWN: case SCI_LINEDOWNEXTEND: case SCI_PARADOWN: case SCI_PARADOWNEXTEND: case SCI_LINEUP: case SCI_LINEUPEXTEND: case SCI_PARAUP: case SCI_PARAUPEXTEND: case SCI_CHARLEFT: case SCI_CHARLEFTEXTEND: case SCI_CHARRIGHT: case SCI_CHARRIGHTEXTEND: case SCI_WORDLEFT: case SCI_WORDLEFTEXTEND: case SCI_WORDRIGHT: case SCI_WORDRIGHTEXTEND: case SCI_WORDLEFTEND: case SCI_WORDLEFTENDEXTEND: case SCI_WORDRIGHTEND: case SCI_WORDRIGHTENDEXTEND: case SCI_HOME: case SCI_HOMEEXTEND: case SCI_LINEEND: case SCI_LINEENDEXTEND: case SCI_HOMEWRAP: case SCI_HOMEWRAPEXTEND: case SCI_LINEENDWRAP: case SCI_LINEENDWRAPEXTEND: case SCI_DOCUMENTSTART: case SCI_DOCUMENTSTARTEXTEND: case SCI_DOCUMENTEND: case SCI_DOCUMENTENDEXTEND: case SCI_STUTTEREDPAGEUP: case SCI_STUTTEREDPAGEUPEXTEND: case SCI_STUTTEREDPAGEDOWN: case SCI_STUTTEREDPAGEDOWNEXTEND: case SCI_PAGEUP: case SCI_PAGEUPEXTEND: case SCI_PAGEDOWN: case SCI_PAGEDOWNEXTEND: case SCI_EDITTOGGLEOVERTYPE: case SCI_CANCEL: case SCI_DELETEBACK: case SCI_TAB: case SCI_BACKTAB: case SCI_NEWLINE: case SCI_FORMFEED: case SCI_VCHOME: case SCI_VCHOMEEXTEND: case SCI_VCHOMEWRAP: case SCI_VCHOMEWRAPEXTEND: case SCI_ZOOMIN: case SCI_ZOOMOUT: case SCI_DELWORDLEFT: case SCI_DELWORDRIGHT: case SCI_DELWORDRIGHTEND: case SCI_DELLINELEFT: case SCI_DELLINERIGHT: case SCI_LINECOPY: case SCI_LINECUT: case SCI_LINEDELETE: case SCI_LINETRANSPOSE: case SCI_LINEDUPLICATE: case SCI_LOWERCASE: case SCI_UPPERCASE: case SCI_LINESCROLLDOWN: case SCI_LINESCROLLUP: case SCI_WORDPARTLEFT: case SCI_WORDPARTLEFTEXTEND: case SCI_WORDPARTRIGHT: case SCI_WORDPARTRIGHTEXTEND: case SCI_DELETEBACKNOTLINE: case SCI_HOMEDISPLAY: case SCI_HOMEDISPLAYEXTEND: case SCI_LINEENDDISPLAY: case SCI_LINEENDDISPLAYEXTEND: case SCI_LINEDOWNRECTEXTEND: case SCI_LINEUPRECTEXTEND: case SCI_CHARLEFTRECTEXTEND: case SCI_CHARRIGHTRECTEXTEND: case SCI_HOMERECTEXTEND: case SCI_VCHOMERECTEXTEND: case SCI_LINEENDRECTEXTEND: case SCI_PAGEUPRECTEXTEND: case SCI_PAGEDOWNRECTEXTEND: case SCI_SELECTIONDUPLICATE: return KeyCommand(iMessage); case SCI_BRACEHIGHLIGHT: SetBraceHighlight(static_cast<int>(wParam), lParam, STYLE_BRACELIGHT); break; case SCI_BRACEBADLIGHT: SetBraceHighlight(static_cast<int>(wParam), -1, STYLE_BRACEBAD); break; case SCI_BRACEMATCH: // wParam is position of char to find brace for, // lParam is maximum amount of text to restyle to find it return pdoc->BraceMatch(wParam, lParam); case SCI_GETVIEWEOL: return vs.viewEOL; case SCI_SETVIEWEOL: vs.viewEOL = wParam != 0; InvalidateStyleRedraw(); break; case SCI_SETZOOM: vs.zoomLevel = wParam; InvalidateStyleRedraw(); NotifyZoom(); break; case SCI_GETZOOM: return vs.zoomLevel; case SCI_GETEDGECOLUMN: return theEdge; case SCI_SETEDGECOLUMN: theEdge = wParam; InvalidateStyleRedraw(); break; case SCI_GETEDGEMODE: return vs.edgeState; case SCI_SETEDGEMODE: vs.edgeState = wParam; InvalidateStyleRedraw(); break; case SCI_GETEDGECOLOUR: return vs.edgecolour.desired.AsLong(); case SCI_SETEDGECOLOUR: vs.edgecolour.desired = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_GETDOCPOINTER: return reinterpret_cast<sptr_t>(pdoc); case SCI_SETDOCPOINTER: CancelModes(); SetDocPointer(reinterpret_cast<Document *>(lParam)); return 0; case SCI_CREATEDOCUMENT: { Document *doc = new Document(); if (doc) { doc->AddRef(); } return reinterpret_cast<sptr_t>(doc); } case SCI_ADDREFDOCUMENT: (reinterpret_cast<Document *>(lParam))->AddRef(); break; case SCI_RELEASEDOCUMENT: (reinterpret_cast<Document *>(lParam))->Release(); break; case SCI_SETMODEVENTMASK: modEventMask = wParam; return 0; case SCI_GETMODEVENTMASK: return modEventMask; case SCI_CONVERTEOLS: pdoc->ConvertLineEnds(wParam); SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document return 0; case SCI_SETLENGTHFORENCODE: lengthForEncode = wParam; return 0; case SCI_SELECTIONISRECTANGLE: return sel.selType == Selection::selRectangle ? 1 : 0; case SCI_SETSELECTIONMODE: { switch (wParam) { case SC_SEL_STREAM: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selStream)); sel.selType = Selection::selStream; break; case SC_SEL_RECTANGLE: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selRectangle)); sel.selType = Selection::selRectangle; break; case SC_SEL_LINES: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selLines)); sel.selType = Selection::selLines; break; case SC_SEL_THIN: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selThin)); sel.selType = Selection::selThin; break; default: sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selStream)); sel.selType = Selection::selStream; } InvalidateSelection(sel.RangeMain(), true); } case SCI_GETSELECTIONMODE: switch (sel.selType) { case Selection::selStream: return SC_SEL_STREAM; case Selection::selRectangle: return SC_SEL_RECTANGLE; case Selection::selLines: return SC_SEL_LINES; case Selection::selThin: return SC_SEL_THIN; default: // ?! return SC_SEL_STREAM; } case SCI_GETLINESELSTARTPOSITION: case SCI_GETLINESELENDPOSITION: { SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)), SelectionPosition(pdoc->LineEnd(wParam))); for (size_t r=0; r<sel.Count(); r++) { SelectionSegment portion = sel.Range(r).Intersect(segmentLine); if (portion.start.IsValid()) { return (iMessage == SCI_GETLINESELSTARTPOSITION) ? portion.start.Position() : portion.end.Position(); } } return INVALID_POSITION; } case SCI_SETOVERTYPE: inOverstrike = wParam != 0; break; case SCI_GETOVERTYPE: return inOverstrike ? 1 : 0; case SCI_SETFOCUS: SetFocusState(wParam != 0); break; case SCI_GETFOCUS: return hasFocus; case SCI_SETSTATUS: errorStatus = wParam; break; case SCI_GETSTATUS: return errorStatus; case SCI_SETMOUSEDOWNCAPTURES: mouseDownCaptures = wParam != 0; break; case SCI_GETMOUSEDOWNCAPTURES: return mouseDownCaptures; case SCI_SETCURSOR: cursorMode = wParam; DisplayCursor(Window::cursorText); break; case SCI_GETCURSOR: return cursorMode; case SCI_SETCONTROLCHARSYMBOL: controlCharSymbol = wParam; break; case SCI_GETCONTROLCHARSYMBOL: return controlCharSymbol; case SCI_STARTRECORD: recordingMacro = true; return 0; case SCI_STOPRECORD: recordingMacro = false; return 0; case SCI_MOVECARETINSIDEVIEW: MoveCaretInsideView(); break; case SCI_SETFOLDMARGINCOLOUR: vs.foldmarginColourSet = wParam != 0; vs.foldmarginColour.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETFOLDMARGINHICOLOUR: vs.foldmarginHighlightColourSet = wParam != 0; vs.foldmarginHighlightColour.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETHOTSPOTACTIVEFORE: vs.hotspotForegroundSet = wParam != 0; vs.hotspotForeground.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_GETHOTSPOTACTIVEFORE: return vs.hotspotForeground.desired.AsLong(); case SCI_SETHOTSPOTACTIVEBACK: vs.hotspotBackgroundSet = wParam != 0; vs.hotspotBackground.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_GETHOTSPOTACTIVEBACK: return vs.hotspotBackground.desired.AsLong(); case SCI_SETHOTSPOTACTIVEUNDERLINE: vs.hotspotUnderline = wParam != 0; InvalidateStyleRedraw(); break; case SCI_GETHOTSPOTACTIVEUNDERLINE: return vs.hotspotUnderline ? 1 : 0; case SCI_SETHOTSPOTSINGLELINE: vs.hotspotSingleLine = wParam != 0; InvalidateStyleRedraw(); break; case SCI_GETHOTSPOTSINGLELINE: return vs.hotspotSingleLine ? 1 : 0; case SCI_SETPASTECONVERTENDINGS: convertPastes = wParam != 0; break; case SCI_GETPASTECONVERTENDINGS: return convertPastes ? 1 : 0; case SCI_GETCHARACTERPOINTER: return reinterpret_cast<sptr_t>(pdoc->BufferPointer()); case SCI_SETEXTRAASCENT: vs.extraAscent = wParam; InvalidateStyleRedraw(); break; case SCI_GETEXTRAASCENT: return vs.extraAscent; case SCI_SETEXTRADESCENT: vs.extraDescent = wParam; InvalidateStyleRedraw(); break; case SCI_GETEXTRADESCENT: return vs.extraDescent; case SCI_MARGINSETSTYLEOFFSET: vs.marginStyleOffset = wParam; InvalidateStyleRedraw(); break; case SCI_MARGINGETSTYLEOFFSET: return vs.marginStyleOffset; case SCI_MARGINSETTEXT: pdoc->MarginSetText(wParam, CharPtrFromSPtr(lParam)); break; case SCI_MARGINGETTEXT: { const StyledText st = pdoc->MarginStyledText(wParam); if (lParam) { if (st.text) memcpy(CharPtrFromSPtr(lParam), st.text, st.length); else strcpy(CharPtrFromSPtr(lParam), ""); } return st.length; } case SCI_MARGINSETSTYLE: pdoc->MarginSetStyle(wParam, lParam); break; case SCI_MARGINGETSTYLE: { const StyledText st = pdoc->MarginStyledText(wParam); return st.style; } case SCI_MARGINSETSTYLES: pdoc->MarginSetStyles(wParam, reinterpret_cast<const unsigned char *>(lParam)); break; case SCI_MARGINGETSTYLES: { const StyledText st = pdoc->MarginStyledText(wParam); if (lParam) { if (st.styles) memcpy(CharPtrFromSPtr(lParam), st.styles, st.length); else strcpy(CharPtrFromSPtr(lParam), ""); } return st.styles ? st.length : 0; } case SCI_MARGINTEXTCLEARALL: pdoc->MarginClearAll(); break; case SCI_ANNOTATIONSETTEXT: pdoc->AnnotationSetText(wParam, CharPtrFromSPtr(lParam)); break; case SCI_ANNOTATIONGETTEXT: { const StyledText st = pdoc->AnnotationStyledText(wParam); if (lParam) { if (st.text) memcpy(CharPtrFromSPtr(lParam), st.text, st.length); else strcpy(CharPtrFromSPtr(lParam), ""); } return st.length; } case SCI_ANNOTATIONGETSTYLE: { const StyledText st = pdoc->AnnotationStyledText(wParam); return st.style; } case SCI_ANNOTATIONSETSTYLE: pdoc->AnnotationSetStyle(wParam, lParam); break; case SCI_ANNOTATIONSETSTYLES: pdoc->AnnotationSetStyles(wParam, reinterpret_cast<const unsigned char *>(lParam)); break; case SCI_ANNOTATIONGETSTYLES: { const StyledText st = pdoc->AnnotationStyledText(wParam); if (lParam) { if (st.styles) memcpy(CharPtrFromSPtr(lParam), st.styles, st.length); else strcpy(CharPtrFromSPtr(lParam), ""); } return st.styles ? st.length : 0; } case SCI_ANNOTATIONGETLINES: return pdoc->AnnotationLines(wParam); case SCI_ANNOTATIONCLEARALL: pdoc->AnnotationClearAll(); break; case SCI_ANNOTATIONSETVISIBLE: SetAnnotationVisible(wParam); break; case SCI_ANNOTATIONGETVISIBLE: return vs.annotationVisible; case SCI_ANNOTATIONSETSTYLEOFFSET: vs.annotationStyleOffset = wParam; InvalidateStyleRedraw(); break; case SCI_ANNOTATIONGETSTYLEOFFSET: return vs.annotationStyleOffset; case SCI_ADDUNDOACTION: pdoc->AddUndoAction(wParam, lParam & UNDO_MAY_COALESCE); break; case SCI_SETMULTIPLESELECTION: multipleSelection = wParam != 0; InvalidateCaret(); break; case SCI_GETMULTIPLESELECTION: return multipleSelection; case SCI_SETADDITIONALSELECTIONTYPING: additionalSelectionTyping = wParam != 0; InvalidateCaret(); break; case SCI_GETADDITIONALSELECTIONTYPING: return additionalSelectionTyping; case SCI_SETMULTIPASTE: multiPasteMode = wParam; break; case SCI_GETMULTIPASTE: return multiPasteMode; case SCI_SETADDITIONALCARETSBLINK: additionalCaretsBlink = wParam != 0; InvalidateCaret(); break; case SCI_GETADDITIONALCARETSBLINK: return additionalCaretsBlink; case SCI_SETADDITIONALCARETSVISIBLE: additionalCaretsVisible = wParam != 0; InvalidateCaret(); break; case SCI_GETADDITIONALCARETSVISIBLE: return additionalCaretsVisible; case SCI_GETSELECTIONS: return sel.Count(); case SCI_CLEARSELECTIONS: sel.Clear(); Redraw(); break; case SCI_SETSELECTION: sel.SetSelection(SelectionRange(wParam, lParam)); Redraw(); break; case SCI_ADDSELECTION: sel.AddSelection(SelectionRange(wParam, lParam)); Redraw(); break; case SCI_SETMAINSELECTION: sel.SetMain(wParam); Redraw(); break; case SCI_GETMAINSELECTION: return sel.Main(); case SCI_SETSELECTIONNCARET: sel.Range(wParam).caret.SetPosition(lParam); Redraw(); break; case SCI_GETSELECTIONNCARET: return sel.Range(wParam).caret.Position(); case SCI_SETSELECTIONNANCHOR: sel.Range(wParam).anchor.SetPosition(lParam); Redraw(); break; case SCI_GETSELECTIONNANCHOR: return sel.Range(wParam).anchor.Position(); case SCI_SETSELECTIONNCARETVIRTUALSPACE: sel.Range(wParam).caret.SetVirtualSpace(lParam); Redraw(); break; case SCI_GETSELECTIONNCARETVIRTUALSPACE: return sel.Range(wParam).caret.VirtualSpace(); case SCI_SETSELECTIONNANCHORVIRTUALSPACE: sel.Range(wParam).anchor.SetVirtualSpace(lParam); Redraw(); break; case SCI_GETSELECTIONNANCHORVIRTUALSPACE: return sel.Range(wParam).anchor.VirtualSpace(); case SCI_SETSELECTIONNSTART: sel.Range(wParam).anchor.SetPosition(lParam); Redraw(); break; case SCI_GETSELECTIONNSTART: return sel.Range(wParam).Start().Position(); case SCI_SETSELECTIONNEND: sel.Range(wParam).caret.SetPosition(lParam); Redraw(); break; case SCI_GETSELECTIONNEND: return sel.Range(wParam).End().Position(); case SCI_SETRECTANGULARSELECTIONCARET: if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().caret.SetPosition(wParam); SetRectangularRange(); Redraw(); break; case SCI_GETRECTANGULARSELECTIONCARET: return sel.Rectangular().caret.Position(); case SCI_SETRECTANGULARSELECTIONANCHOR: if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().anchor.SetPosition(wParam); SetRectangularRange(); Redraw(); break; case SCI_GETRECTANGULARSELECTIONANCHOR: return sel.Rectangular().anchor.Position(); case SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE: if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().caret.SetVirtualSpace(wParam); SetRectangularRange(); Redraw(); break; case SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE: return sel.Rectangular().caret.VirtualSpace(); case SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE: if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().anchor.SetVirtualSpace(wParam); SetRectangularRange(); Redraw(); break; case SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE: return sel.Rectangular().anchor.VirtualSpace(); case SCI_SETVIRTUALSPACEOPTIONS: virtualSpaceOptions = wParam; break; case SCI_GETVIRTUALSPACEOPTIONS: return virtualSpaceOptions; case SCI_SETADDITIONALSELFORE: vs.selAdditionalForeground.desired = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_SETADDITIONALSELBACK: vs.selAdditionalBackground.desired = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_SETADDITIONALSELALPHA: vs.selAdditionalAlpha = wParam; InvalidateStyleRedraw(); break; case SCI_GETADDITIONALSELALPHA: return vs.selAdditionalAlpha; case SCI_SETADDITIONALCARETFORE: vs.additionalCaretColour.desired = ColourDesired(wParam); InvalidateStyleRedraw(); break; case SCI_GETADDITIONALCARETFORE: return vs.additionalCaretColour.desired.AsLong(); case SCI_ROTATESELECTION: sel.RotateMain(); InvalidateSelection(sel.RangeMain(), true); break; case SCI_SWAPMAINANCHORCARET: InvalidateSelection(sel.RangeMain()); sel.RangeMain() = SelectionRange(sel.RangeMain().anchor, sel.RangeMain().caret); break; case SCI_CHANGELEXERSTATE: pdoc->ChangeLexerState(wParam, lParam); break; default: return DefWndProc(iMessage, wParam, lParam); } //Platform::DebugPrintf("end wnd proc\n"); return 0l; }
[ "donho@9e717b3d-e3cd-45c4-bdc4-af0eb0386351", "harrybharry@9e717b3d-e3cd-45c4-bdc4-af0eb0386351" ]
[ [ [ 1, 4213 ], [ 4219, 8035 ], [ 8037, 8038 ], [ 8044, 8044 ], [ 8046, 8769 ] ], [ [ 4214, 4218 ], [ 8036, 8036 ], [ 8039, 8043 ], [ 8045, 8045 ] ] ]
b554c63e7bce86e14d00b839fac172245f90274e
27d5670a7739a866c3ad97a71c0fc9334f6875f2
/CPP/include/symbian-r6/TimerThread.h
66354ff7d8d110117b9c09ab8ca2ef43f3085318
[ "BSD-3-Clause" ]
permissive
ravustaja/Wayfinder-S60-Navigator
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
14d1b729b2cea52f726874687e78f17492949585
refs/heads/master
2021-01-16T20:53:37.630909
2010-06-28T09:51:10
2010-06-28T09:51:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,981
h
/* Copyright (c) 1999 - 2010, Vodafone Group Services Ltd All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Vodafone Group Services Ltd nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TIMER_THREAD_H #define TIMER_THREAD_H #include <e32std.h> /* #undef NO_LOG_OUTPUT */ #include "ModuleQueue.h" #include "Log.h" #include "GlobalData.h" #ifdef TRACE_TIMER_THREAD /* #include "TraceMacros.h" */ #endif /* #define DEBUG_TIMERS */ /* #define FAKE_REQUEST */ namespace isab { /** * Symbian class for timing. */ class TimerThread { // Wait on timer (and wakeup socket in future) /// Max Time to wait before setting new timeout #define maxWaitTimeMillis 200 /** * Holds an timeout request from a ModuleQueue. */ class timeOutItem { public: /** * Constructor. * * @param queue The ModuleQueue to insert the timerBuf into when * timeout. * @param millis The timeout in milli seconds. * @param timerBuf The MsgBuffer to insert into the ModuleQueue at * timeout. * @param id An user defined ID. */ timeOutItem(class ModuleQueue* queue, uint16 id, uint32 millis, class MsgBuffer* timerBuf ) : m_queue( queue ), m_id( id ), m_millis( millis), m_timerBuf( timerBuf ), m_next( NULL ), m_timeOutItemID( 0 ) {} ///Pointer to the requesting ModuleQueue. class ModuleQueue* m_queue; ///ModuleQueue timer id. uint16 m_id; ///Millisecond timeout uint32 m_millis; ///Buffer that shall be inserted into m_queue when the timer expires. class MsgBuffer* m_timerBuf; ///Pointer to the next timeOutItem in the single linked list. class timeOutItem* m_next; ///TimerThread tracking id. uint32 m_timeOutItemID; ///Appends this timeOutItem last in the list that starts with ///the timeOutItem pointed to by *aList. ///@param list pointer to the pointer pointing to the first /// element in the list. <code>aList</code> may not be /// NULL, but <code>*aList</code> may be NULL, which /// signifies that the list is empty. void insert(class timeOutItem** aList ) { if ( *aList == NULL ) { // Empty list *aList = this; m_next = NULL; } else { // Not empty class timeOutItem* cur = *aList; while ( cur->m_next != NULL ) { cur = cur->m_next; } cur->m_next = this; m_next = NULL; } } ///Finds this timeOutItem object in the list pointed to by ///<code>*aList</code>. ///@param aList pointer to pointer to the first timeOutItem /// object in the singly linked list. Neither /// <code>aList</code> nor <code>*aList</code> may /// be NULL. void remove(class timeOutItem** aList ) { if ( *aList == this ) { // First in list *aList = m_next; m_next = NULL; } else { // Remove from list class timeOutItem* cur = *aList; class timeOutItem* prev = cur; while((cur != this) && (cur != NULL)){ prev = cur; cur = cur->m_next; } if(cur != NULL){ prev->m_next = m_next; m_next = NULL; } else { //not found } } } }; /** * Holds an timer request that is sent to system. */ class timerItem { public: ///Constructor ///@param aQueue the ModuleQueue that set this timer. ///@param id the ModuleQueue timer id. ///@param timeOutItemID the id of the matching timeOutTimer. timerItem(class ModuleQueue* aQueue, uint16 id, uint32 timeOutItemID ) : m_queue( aQueue ), m_id( id ), m_timeOutItemID( timeOutItemID ) {} ///Destructor. ~timerItem() { m_timer.Close(); } ///Symbian system timer handle. class RTimer m_timer; ///Status variabler for the timer request. class TRequestStatus status; ///The ModuleQueue associated with this timer. class ModuleQueue* m_queue; ///The ModuleQueue timer id. uint16 m_id; ///The next timeItem in the singly linked list. class timerItem* m_next; ///The id for the matching timeOutItem object. uint32 m_timeOutItemID; /** * Inserts this into list. */ void insert(class timerItem** list ) { if ( *list == NULL ) { // Empty list *list = this; m_next = NULL; } else { // Not empty class timerItem* cur = *list; while ( cur->m_next != NULL ) { cur = cur->m_next; } cur->m_next = this; m_next = NULL; } } /** * Removes from list. */ void remove(class timerItem** list ) { if ( *list == this ) { // First in list *list = m_next; m_next = NULL; } else { // Remove from list class timerItem* cur = *list; class timerItem* prev = cur; while ( cur != this && cur != NULL) { prev = cur; cur = cur->m_next; } if(cur != NULL){ prev->m_next = m_next; m_next = NULL; } else { //not found } } } }; public: #ifdef DEBUG_TIMERS class LogMaster iLogMaster; class Log *log; #endif /** * Constructor. */ TimerThread(); ~TimerThread(); /** * Mutex method to add a timeout. * * @param queue The ModuleQueue to insert the timerBuf into when * timeout. * @param id An unique id for queue's timer used in unSetTimer. * @param millis The timeout in milli seconds. * @param timerBuf The MsgBuffer to insert into the ModuleQueue at * timeout. */ void setTimer(class ModuleQueue* queue, uint16 id, uint32 millis, class MsgBuffer* timerBuf ); /** * Mutex method to unset the timer for ModuleQueue queue. * * @param queue The ModuleQueue to unset timer for. * @param id An unique id for queue's timer. */ void unSetTimer(class ModuleQueue* queue, uint16 id ); void terminate(); int join(); int terminateAndJoin(); /** * The run method. */ void run(); private: /** * The starting method. */ static TInt startF( TAny *aPtr ); volatile bool m_terminated; volatile int m_goneFishing; #ifdef FAKE_REQUEST TRequestStatus m_fakeStatus; #endif /** * The timeOutItems in a single linked list. */ class timeOutItem* m_timeOuts; /** * The actual thread. */ class RThread m_thread; class TRequestStatus m_terminateStatus; /** * The mutex protecting m_timeOuts. */ class Mutex m_mutex; /** * The timeOutItem id. */ uint32 m_timeOutItemID; }; } // end namespace isab #endif /* TIMER_THREAD_H */
[ [ [ 1, 289 ] ] ]
a8cb091df56b35b7ac958ab8fadca3d74810fd10
12203ea9fe0801d613bbb2159d4f69cab3c84816
/Export/cpp/windows/obj/include/IntIter.h
62e8e261aade3cf81b444aa4fdc23abff5e25e32
[]
no_license
alecmce/haxe_game_of_life
91b5557132043c6e9526254d17fdd9bcea9c5086
35ceb1565e06d12c89481451a7bedbbce20fa871
refs/heads/master
2016-09-16T00:47:24.032302
2011-10-10T12:38:14
2011-10-10T12:38:14
2,547,793
0
0
null
null
null
null
UTF-8
C++
false
false
840
h
#ifndef INCLUDED_IntIter #define INCLUDED_IntIter #ifndef HXCPP_H #include <hxcpp.h> #endif HX_DECLARE_CLASS0(IntIter) class IntIter_obj : public hx::Object{ public: typedef hx::Object super; typedef IntIter_obj OBJ_; IntIter_obj(); Void __construct(int min,int max); public: static hx::ObjectPtr< IntIter_obj > __new(int min,int max); static Dynamic __CreateEmpty(); static Dynamic __Create(hx::DynamicArray inArgs); ~IntIter_obj(); HX_DO_RTTI; static void __boot(); static void __register(); void __Mark(HX_MARK_PARAMS); ::String __ToString() const { return HX_CSTRING("IntIter"); } int min; /* REM */ int max; /* REM */ virtual bool hasNext( ); Dynamic hasNext_dyn(); virtual int next( ); Dynamic next_dyn(); }; #endif /* INCLUDED_IntIter */
[ [ [ 1, 41 ] ] ]
468a7b6f8008a8377f1588a12853bbd7042884ac
2d4221efb0beb3d28118d065261791d431f4518a
/OIDE源代码/OLIDE/Controls/TreePropSheet/TreePropSheetOffice2003.h
67530e9c9dc31c5fbbc4930f522445ed8e77ce70
[]
no_license
ophyos/olanguage
3ea9304da44f54110297a5abe31b051a13330db3
38d89352e48c2e687fd9410ffc59636f2431f006
refs/heads/master
2021-01-10T05:54:10.604301
2010-03-23T11:38:51
2010-03-23T11:38:51
48,682,489
1
0
null
null
null
null
UTF-8
C++
false
false
2,887
h
// TreePropSheetOffice2003.h: interface for the CTreePropSheetOffice2003 class. // ////////////////////////////////////////////////////////////////////// // // Copyright (C) 2004 by Yves Tkaczyk // (http://www.tkaczyk.net - [email protected]) // // The contents of this file are subject to the Artistic License (the "License"). // You may not use this file except in compliance with the License. // You may obtain a copy of the License at: // http://www.opensource.org/licenses/artistic-license.html // // Documentation: http://www.codeproject.com/property/treepropsheetex.asp // CVS tree: http://sourceforge.net/projects/treepropsheetex // ///////////////////////////////////////////////////////////////////////////// #ifndef _TREEPROPSHEETOFFICE2003_H__INCLUDED_ #define _TREEPROPSHEETOFFICE2003_H__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "TreePropSheetEx.h" namespace TreePropSheet { /*! @brief TreePropSheetEx with Office 2003 option dialog look and feel. The version of CTreePropSheetEx has the following additions: - Use CPropPageFrameOffice2003 for page frame. - Tree style is modified to show for row selection. The property pages should be modified in order to return a COLOR_WINDOW background. This can be done as follows: <code> HBRUSH CAPage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { pDC->SetBkMode(TRANSPARENT); return ::GetSysColorBrush( COLOR_WINDOW ); } </code> @version 0.1 Initial release @author Yves Tkaczyk <[email protected]> @date 09/2004 */ class CTreePropSheetOffice2003 : public CTreePropSheetEx { // Construction/Destruction DECLARE_DYNAMIC(CTreePropSheetOffice2003) public: CTreePropSheetOffice2003(); CTreePropSheetOffice2003(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); CTreePropSheetOffice2003(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); virtual ~CTreePropSheetOffice2003(); // Overrided implementation helpers protected: /** Will be called during creation process, to create the object, that is responsible for drawing the frame around the pages, drawing the empty page message and the caption. Allows you to inject your own CPropPageFrame-derived classes. This default implementation simply creates a CPropPageFrameTab with new and returns it. */ virtual CPropPageFrame* CreatePageFrame(); // Overridings protected: //{{AFX_VIRTUAL(CTreePropSheetOffice2003) virtual BOOL OnInitDialog(); //}}AFX_VIRTUAL // Message handlers protected: //{{AFX_MSG(CTreePropSheetOffice2003) //}}AFX_MSG DECLARE_MESSAGE_MAP() }; }; // namespace TreePropSheet ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} #endif // _TREEPROPSHEETOFFICE2003_H__INCLUDED_
[ [ [ 1, 95 ] ] ]
fbeccab10cc38e5142f0cee94417729b05edf838
b7c505dcef43c0675fd89d428e45f3c2850b124f
/Src/SimulatorQt/Util/qt/Win32/include/Qt/qaccessiblebridge.h
cd72e097ffbf131917d0bfdbfd08df9dc786f260
[ "BSD-2-Clause" ]
permissive
pranet/bhuman2009fork
14e473bd6e5d30af9f1745311d689723bfc5cfdb
82c1bd4485ae24043aa720a3aa7cb3e605b1a329
refs/heads/master
2021-01-15T17:55:37.058289
2010-02-28T13:52:56
2010-02-28T13:52:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,327
h
/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information ([email protected]) ** ** This file is part of the QtGui module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Commercial License Agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Nokia. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at [email protected]. ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QACCESSIBLEBRIDGE_H #define QACCESSIBLEBRIDGE_H #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Gui) #ifndef QT_NO_ACCESSIBILITY class QAccessibleInterface; class QAccessibleBridge { public: virtual ~QAccessibleBridge() {} virtual void setRootObject(QAccessibleInterface *) = 0; virtual void notifyAccessibilityUpdate(int, QAccessibleInterface*, int) = 0; }; struct Q_GUI_EXPORT QAccessibleBridgeFactoryInterface : public QFactoryInterface { virtual QAccessibleBridge *create(const QString& name) = 0; }; #define QAccessibleBridgeFactoryInterface_iid "com.trolltech.Qt.QAccessibleBridgeFactoryInterface" Q_DECLARE_INTERFACE(QAccessibleBridgeFactoryInterface, QAccessibleBridgeFactoryInterface_iid) class Q_GUI_EXPORT QAccessibleBridgePlugin : public QObject, public QAccessibleBridgeFactoryInterface { Q_OBJECT Q_INTERFACES(QAccessibleBridgeFactoryInterface:QFactoryInterface) public: explicit QAccessibleBridgePlugin(QObject *parent = 0); ~QAccessibleBridgePlugin(); virtual QStringList keys() const = 0; virtual QAccessibleBridge *create(const QString &key) = 0; }; #endif // QT_NO_ACCESSIBILITY QT_END_NAMESPACE QT_END_HEADER #endif // QACCESSIBLEBRIDGE_H
[ "alon@rogue.(none)" ]
[ [ [ 1, 92 ] ] ]
6148c760eab3dbb65a03086909fd955cc0311a6a
e7c45d18fa1e4285e5227e5984e07c47f8867d1d
/Common/Scd/FlwLib/SparseSlv/Indirect/mv/src/mvmc.cc
bc942347368f1be6ad54c44197e4fa4e544f87dc
[]
no_license
abcweizhuo/Test3
0f3379e528a543c0d43aad09489b2444a2e0f86d
128a4edcf9a93d36a45e5585b70dee75e4502db4
refs/heads/master
2021-01-17T01:59:39.357645
2008-08-20T00:00:29
2008-08-20T00:00:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,837
cc
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* */ /* */ /* MV++ Numerical Matrix/Vector C++ Library */ /* MV++ Version 1.5 */ /* */ /* R. Pozo */ /* National Institute of Standards and Technology */ /* */ /* NOTICE */ /* */ /* Permission to use, copy, modify, and distribute this software and */ /* its documentation for any purpose and without fee is hereby granted */ /* provided that this permission notice appear in all copies and */ /* supporting documentation. */ /* */ /* Neither the Institution (National Institute of Standards and Technology) */ /* nor the author makes any representations about the suitability of this */ /* software for any purpose. This software is provided ``as is''without */ /* expressed or implied warranty. */ /* */ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ // // Basic matrix class (COMPLEX precision) // #include "..\include\mvm.h" int MV_ColMat_COMPLEX::dim(int i) const { if (i==0) return dim0_; if (i==1) return dim1_; else { std::cerr << "Called MV_ColMat::dim(" << i << ") must be 0 or 1 " << "\n"; exit(1); } // never should be here, but many compilers warn about not // returning a value return 0; } // NOTE: null construct have ref_ flag turned OFF, otherwise, we can // never reset the dim of matrix.... MV_ColMat_COMPLEX::MV_ColMat_COMPLEX() : v_(), dim0_(0), dim1_(0) , lda_(0), ref_(0){} MV_ColMat_COMPLEX::MV_ColMat_COMPLEX( int m, int n) : v_(m*n), dim0_(m), dim1_(n), lda_(m), ref_(0) {} MV_ColMat_COMPLEX::MV_ColMat_COMPLEX( int m, int n, const COMPLEX &s) : v_(m*n), dim0_(m), dim1_(n), lda_(m), ref_(0) { operator=(s); } // operators and member functions MV_ColMat_COMPLEX& MV_ColMat_COMPLEX::operator=(const COMPLEX & s) { int M = dim(0); int N = dim(1); if (lda_ == M) // if continuous, then just assign as a ? v_ = s; // single long vector. else { // this should run much faster than the just accessing each (i,j) // element individually // MV_VecIndex I(0,M-1); for (int j=0; j<N; j++) { v_(I) = s; I += lda_; } } return *this; } MV_ColMat_COMPLEX& MV_ColMat_COMPLEX::newsize( int M, int N) { v_.newsize(M*N); dim0_ = M; dim1_ = N; lda_ = M; return *this; } MV_ColMat_COMPLEX& MV_ColMat_COMPLEX::operator=(const MV_ColMat_COMPLEX & m) { int lM = dim0_; // left hand arg (this) int lN = dim1_; int rM = m.dim0_; // right hand arg (m) int rN = m.dim1_; // if the left-hand side is a matrix reference, the we copy the // elements of m *into* the region specfied by the reference. // i.e. inject(). if (ref_) { // check conformance, if (lM != rM || lN != rN) { std::cerr << "MV_ColMatRef::operator= non-conformant assignment.\n"; exit(1); } } else { newsize(rM,rN); } // at this point the left hand and right hand sides are conformant // this should run much faster than the just accessing each (i,j) // element individually // if both sides are contigous, then just copy as one vector if ( lM == lda_ && rM == m.lda_) { MV_VecIndex I(0,rM*rN-1); v_(I) = m.v_(I); } else { // slower way... MV_VecIndex I(0,rM-1); MV_VecIndex K(0,rM-1); for (int j=0; j<rN; j++) { v_(I) = m.v_(K); I += lda_; K += m.lda_; } } return *this; } MV_ColMat_COMPLEX::MV_ColMat_COMPLEX(const MV_ColMat_COMPLEX & m) : v_(m.dim0_*m.dim1_), dim0_(m.dim0_), dim1_(m.dim1_), lda_(m.dim0_), ref_(0) { int M = m.dim0_; int N = m.dim1_; // this should run much faster than the just accessing each (i,j) // element individually MV_VecIndex I(0,M-1); MV_VecIndex K(0,M-1); for (int j=0; j<N; j++) { v_(I) = m.v_(K); I += lda_; K += m.lda_; } } MV_ColMat_COMPLEX::MV_ColMat_COMPLEX(COMPLEX* d, int m, int n) : v_(m*n), dim0_(m), dim1_(n), lda_(m), ref_(0) { int mn = m*n; // d is contiguous, so just copy 1-d vector for (int i=0; i< mn; i++) v_[i] = d[i]; } MV_ColMat_COMPLEX::MV_ColMat_COMPLEX(COMPLEX* d, int m, int n, int lda) : v_(m*n), dim0_(m), dim1_(n), lda_(lda), ref_(0) { for (int j=0; j< n; j++) for (int i=0; i<m; i++) operator()(i,j) = d[j*lda + i]; // could be made faster!! } MV_ColMat_COMPLEX MV_ColMat_COMPLEX::operator()(const MV_VecIndex &I, const MV_VecIndex &J) { // check that index is not out of bounds // if (I.end() >= dim0_ || J.end() >= dim1_) { std::cerr << "Matrix index: (" << I.start() << ":" << I.end() << "," << J.start() << ":" << J.end() << ") not a subset of (0:" << dim0_ - 1 << ", 0:" << dim1_-1 << ") " << "\n"; exit(1); } // this automatically returns a reference // return MV_ColMat_COMPLEX(&v_[J.start()*lda_ + I.start()], I.end() - I.start() + 1, J.end() - J.start() + 1, lda_, MV_Matrix_::ref); } const MV_ColMat_COMPLEX MV_ColMat_COMPLEX::operator()(const MV_VecIndex &I, const MV_VecIndex &J) const { std::cerr << "Const operator()(MV_VecIndex, MV_VecIndex) called " << "\n"; // check that index is not out of bounds // if (I.end() >= dim0_ || J.end() >= dim1_) { std::cerr << "Matrix index: (" << I.start() << ":" << I.end() << "," << J.start() << ":" << J.end() << ") not a subset of (0:" << dim0_ - 1 << ", 0:" << dim1_-1 << ") " << "\n"; exit(1); } // this automatically returns a reference. we need to // "cast away" constness here, so the &v_[] arg will // not cause a compiler error. // MV_ColMat_COMPLEX *t = (MV_ColMat_COMPLEX*) this; return MV_ColMat_COMPLEX(&(t->v_[J.start()*lda_ + I.start()]), I.end() - I.start() + 1, J.end() - J.start() + 1, lda_, MV_Matrix_::ref); } MV_ColMat_COMPLEX::~MV_ColMat_COMPLEX() {} std::ostream& operator<<(std::ostream& s, const MV_ColMat_COMPLEX& V) { int M = V.dim(0); int N = V.dim(1); for (int i=0; i<M; i++) { for (int j=0; j<N; j++) s << V(i,j) << " " ; s << "\n"; } return s; }
[ [ [ 1, 267 ] ] ]
aacaafe474b1dba67c104f612366eb2471b1eee7
d258dd0ca5e8678c8eb81777e5fe360b8bbf7b7e
/Library/PhysXCPP/NxaPointOnLineJointDescription.h
123beedefb52452026b68aee7175d502a4224903
[]
no_license
ECToo/physxdotnet
1e7d7e9078796f1dad5c8582d28441a908e11a83
2b85d57bc877521cdbf1a9147bd6716af68a64b0
refs/heads/master
2021-01-22T07:17:58.918244
2008-04-13T11:15:26
2008-04-13T11:15:26
32,543,781
0
0
null
null
null
null
UTF-8
C++
false
false
493
h
#pragma once #include "NxaJointDescription.h" class NxScene; class NxPointOnLineJointDesc; public ref class NxaPointOnLineJointDescription : public NxaJointDescription { internal: virtual void LoadFromNative(NxPointOnLineJointDesc& desc); virtual NxPointOnLineJointDesc ConvertToNative(); virtual NxaJoint^ CreateJoint(NxScene* scenePtr) override; public: NxaPointOnLineJointDescription(); virtual void SetToDefault() override; virtual bool IsValid() override; };
[ "michael.brooks11@e8b6d1ee-b643-0410-9178-bfabf5f736f5", "amiles@e8b6d1ee-b643-0410-9178-bfabf5f736f5" ]
[ [ [ 1, 4 ], [ 7, 10 ], [ 14, 15 ], [ 17, 17 ], [ 20, 20 ] ], [ [ 5, 6 ], [ 11, 13 ], [ 16, 16 ], [ 18, 19 ] ] ]
1125a38c83645a50eed3408ba17b6a25e7ab4fc3
3aafc3c40c1464fc2a32d1b6bba23818903a4ec9
/BookDetails/BookDetails/BookDetailsControl.h
4183ce11c14bb4fae5c786b58360eebee8660376
[]
no_license
robintw/rlibrary
13930416649ec38196bfd38e0980616e9f5454c8
3e55d49acba665940828e26c8bff60863a86246f
refs/heads/master
2020-09-22T10:31:55.561804
2009-01-24T19:05:19
2009-01-24T19:05:19
34,583,564
0
1
null
null
null
null
UTF-8
C++
false
false
19,766
h
#pragma once using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::Data::Odbc; namespace BookDetails { /// <summary> /// Summary for BookDetailsControl /// </summary> /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. public ref class BookDetailsControl : public System::Windows::Forms::UserControl { public: BookDetailsControl(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~BookDetailsControl() { if (components) { delete components; } } private: System::Windows::Forms::Label^ lblRead; protected: private: System::Windows::Forms::Label^ lblPriceBought; private: System::Windows::Forms::Label^ label16; private: System::Windows::Forms::Label^ lblDateAdded; private: System::Windows::Forms::Label^ label15; private: System::Windows::Forms::Label^ lblISBN; private: System::Windows::Forms::Label^ label14; private: System::Windows::Forms::Label^ lblBinding; private: System::Windows::Forms::Label^ label13; private: System::Windows::Forms::Label^ lblType; private: System::Windows::Forms::Label^ label11; private: System::Windows::Forms::Label^ lblPages; private: System::Windows::Forms::Label^ label12; private: System::Windows::Forms::Label^ lblEdition; private: System::Windows::Forms::Label^ label10; private: System::Windows::Forms::Label^ lblDewey; private: System::Windows::Forms::Label^ label9; private: System::Windows::Forms::Label^ lblDatePublished; private: System::Windows::Forms::Label^ label8; private: System::Windows::Forms::Label^ lblKeywords; private: System::Windows::Forms::Label^ lblCopyID; private: System::Windows::Forms::Label^ label7; private: System::Windows::Forms::Label^ lblPublisher; private: System::Windows::Forms::Label^ label4; private: System::Windows::Forms::Label^ label5; private: System::Windows::Forms::Label^ lblAuthor; private: System::Windows::Forms::Label^ label3; private: System::Windows::Forms::Label^ lblTitle; private: System::Windows::Forms::Label^ label2; private: System::Windows::Forms::PictureBox^ picCoverImage; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container^ components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->lblRead = (gcnew System::Windows::Forms::Label()); this->lblPriceBought = (gcnew System::Windows::Forms::Label()); this->label16 = (gcnew System::Windows::Forms::Label()); this->lblDateAdded = (gcnew System::Windows::Forms::Label()); this->label15 = (gcnew System::Windows::Forms::Label()); this->lblISBN = (gcnew System::Windows::Forms::Label()); this->label14 = (gcnew System::Windows::Forms::Label()); this->lblBinding = (gcnew System::Windows::Forms::Label()); this->label13 = (gcnew System::Windows::Forms::Label()); this->lblType = (gcnew System::Windows::Forms::Label()); this->label11 = (gcnew System::Windows::Forms::Label()); this->lblPages = (gcnew System::Windows::Forms::Label()); this->label12 = (gcnew System::Windows::Forms::Label()); this->lblEdition = (gcnew System::Windows::Forms::Label()); this->label10 = (gcnew System::Windows::Forms::Label()); this->lblDewey = (gcnew System::Windows::Forms::Label()); this->label9 = (gcnew System::Windows::Forms::Label()); this->lblDatePublished = (gcnew System::Windows::Forms::Label()); this->label8 = (gcnew System::Windows::Forms::Label()); this->lblKeywords = (gcnew System::Windows::Forms::Label()); this->lblCopyID = (gcnew System::Windows::Forms::Label()); this->label7 = (gcnew System::Windows::Forms::Label()); this->lblPublisher = (gcnew System::Windows::Forms::Label()); this->label4 = (gcnew System::Windows::Forms::Label()); this->label5 = (gcnew System::Windows::Forms::Label()); this->lblAuthor = (gcnew System::Windows::Forms::Label()); this->label3 = (gcnew System::Windows::Forms::Label()); this->lblTitle = (gcnew System::Windows::Forms::Label()); this->label2 = (gcnew System::Windows::Forms::Label()); this->picCoverImage = (gcnew System::Windows::Forms::PictureBox()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picCoverImage))->BeginInit(); this->SuspendLayout(); // // lblRead // this->lblRead->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->lblRead->Location = System::Drawing::Point(302, 182); this->lblRead->Name = L"lblRead"; this->lblRead->Size = System::Drawing::Size(365, 13); this->lblRead->TabIndex = 56; // // lblPriceBought // this->lblPriceBought->Location = System::Drawing::Point(551, 26); this->lblPriceBought->Name = L"lblPriceBought"; this->lblPriceBought->Size = System::Drawing::Size(131, 13); this->lblPriceBought->TabIndex = 55; // // label16 // this->label16->AutoSize = true; this->label16->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label16->Location = System::Drawing::Point(461, 26); this->label16->Name = L"label16"; this->label16->Size = System::Drawing::Size(84, 13); this->label16->TabIndex = 54; this->label16->Text = L"Price Bought:"; // // lblDateAdded // this->lblDateAdded->Location = System::Drawing::Point(86, 208); this->lblDateAdded->Name = L"lblDateAdded"; this->lblDateAdded->Size = System::Drawing::Size(183, 13); this->lblDateAdded->TabIndex = 53; // // label15 // this->label15->AutoSize = true; this->label15->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label15->Location = System::Drawing::Point(2, 208); this->label15->Name = L"label15"; this->label15->Size = System::Drawing::Size(78, 13); this->label15->TabIndex = 52; this->label15->Text = L"Date Added:"; // // lblISBN // this->lblISBN->Location = System::Drawing::Point(507, 0); this->lblISBN->Name = L"lblISBN"; this->lblISBN->Size = System::Drawing::Size(143, 13); this->lblISBN->TabIndex = 51; // // label14 // this->label14->AutoSize = true; this->label14->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label14->Location = System::Drawing::Point(461, 0); this->label14->Name = L"label14"; this->label14->Size = System::Drawing::Size(40, 13); this->label14->TabIndex = 50; this->label14->Text = L"ISBN:"; // // lblBinding // this->lblBinding->Location = System::Drawing::Point(220, 156); this->lblBinding->Name = L"lblBinding"; this->lblBinding->Size = System::Drawing::Size(97, 13); this->lblBinding->TabIndex = 49; // // label13 // this->label13->AutoSize = true; this->label13->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label13->Location = System::Drawing::Point(161, 156); this->label13->Name = L"label13"; this->label13->Size = System::Drawing::Size(53, 13); this->label13->TabIndex = 48; this->label13->Text = L"Binding:"; // // lblType // this->lblType->Location = System::Drawing::Point(58, 156); this->lblType->Name = L"lblType"; this->lblType->Size = System::Drawing::Size(97, 13); this->lblType->TabIndex = 47; // // label11 // this->label11->AutoSize = true; this->label11->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label11->Location = System::Drawing::Point(2, 156); this->label11->Name = L"label11"; this->label11->Size = System::Drawing::Size(39, 13); this->label11->TabIndex = 46; this->label11->Text = L"Type:"; // // lblPages // this->lblPages->Location = System::Drawing::Point(275, 130); this->lblPages->Name = L"lblPages"; this->lblPages->Size = System::Drawing::Size(97, 13); this->lblPages->TabIndex = 45; // // label12 // this->label12->AutoSize = true; this->label12->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label12->Location = System::Drawing::Point(161, 130); this->label12->Name = L"label12"; this->label12->Size = System::Drawing::Size(108, 13); this->label12->TabIndex = 44; this->label12->Text = L"Number of Pages:"; // // lblEdition // this->lblEdition->Location = System::Drawing::Point(58, 130); this->lblEdition->Name = L"lblEdition"; this->lblEdition->Size = System::Drawing::Size(97, 13); this->lblEdition->TabIndex = 43; // // label10 // this->label10->AutoSize = true; this->label10->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label10->Location = System::Drawing::Point(2, 130); this->label10->Name = L"label10"; this->label10->Size = System::Drawing::Size(50, 13); this->label10->TabIndex = 42; this->label10->Text = L"Edition:"; // // lblDewey // this->lblDewey->Location = System::Drawing::Point(153, 182); this->lblDewey->Name = L"lblDewey"; this->lblDewey->Size = System::Drawing::Size(143, 13); this->lblDewey->TabIndex = 41; // // label9 // this->label9->AutoSize = true; this->label9->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label9->Location = System::Drawing::Point(2, 182); this->label9->Name = L"label9"; this->label9->Size = System::Drawing::Size(145, 13); this->label9->TabIndex = 40; this->label9->Text = L"Dewey Decimal Number:"; // // lblDatePublished // this->lblDatePublished->Location = System::Drawing::Point(113, 104); this->lblDatePublished->Name = L"lblDatePublished"; this->lblDatePublished->Size = System::Drawing::Size(343, 13); this->lblDatePublished->TabIndex = 39; // // label8 // this->label8->AutoSize = true; this->label8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label8->Location = System::Drawing::Point(2, 104); this->label8->Name = L"label8"; this->label8->Size = System::Drawing::Size(105, 13); this->label8->TabIndex = 38; this->label8->Text = L"Publication Date:"; // // lblKeywords // this->lblKeywords->Location = System::Drawing::Point(67, 234); this->lblKeywords->Name = L"lblKeywords"; this->lblKeywords->Size = System::Drawing::Size(343, 13); this->lblKeywords->TabIndex = 37; // // lblCopyID // this->lblCopyID->Location = System::Drawing::Point(67, 0); this->lblCopyID->Name = L"lblCopyID"; this->lblCopyID->Size = System::Drawing::Size(143, 13); this->lblCopyID->TabIndex = 33; // // label7 // this->label7->AutoSize = true; this->label7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label7->Location = System::Drawing::Point(2, 0); this->label7->Name = L"label7"; this->label7->Size = System::Drawing::Size(20, 13); this->label7->TabIndex = 28; this->label7->Text = L"ID"; // // lblPublisher // this->lblPublisher->Location = System::Drawing::Point(67, 78); this->lblPublisher->Name = L"lblPublisher"; this->lblPublisher->Size = System::Drawing::Size(343, 13); this->lblPublisher->TabIndex = 34; // // label4 // this->label4->AutoSize = true; this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label4->Location = System::Drawing::Point(2, 234); this->label4->Name = L"label4"; this->label4->Size = System::Drawing::Size(65, 13); this->label4->TabIndex = 30; this->label4->Text = L"Keywords:"; // // label5 // this->label5->AutoSize = true; this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label5->Location = System::Drawing::Point(2, 78); this->label5->Name = L"label5"; this->label5->Size = System::Drawing::Size(59, 13); this->label5->TabIndex = 29; this->label5->Text = L"Publisher"; // // lblAuthor // this->lblAuthor->Location = System::Drawing::Point(67, 52); this->lblAuthor->Name = L"lblAuthor"; this->lblAuthor->Size = System::Drawing::Size(343, 13); this->lblAuthor->TabIndex = 36; // // label3 // this->label3->AutoSize = true; this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label3->Location = System::Drawing::Point(2, 52); this->label3->Name = L"label3"; this->label3->Size = System::Drawing::Size(48, 13); this->label3->TabIndex = 32; this->label3->Text = L"Author:"; // // lblTitle // this->lblTitle->Location = System::Drawing::Point(67, 26); this->lblTitle->Name = L"lblTitle"; this->lblTitle->Size = System::Drawing::Size(343, 13); this->lblTitle->TabIndex = 35; // // label2 // this->label2->AutoSize = true; this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->label2->Location = System::Drawing::Point(2, 26); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(36, 13); this->label2->TabIndex = 31; this->label2->Text = L"Title:"; // // picCoverImage // this->picCoverImage->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle; this->picCoverImage->Location = System::Drawing::Point(688, 0); this->picCoverImage->Name = L"picCoverImage"; this->picCoverImage->Size = System::Drawing::Size(259, 247); this->picCoverImage->SizeMode = System::Windows::Forms::PictureBoxSizeMode::Zoom; this->picCoverImage->TabIndex = 27; this->picCoverImage->TabStop = false; // // BookDetailsControl // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->Controls->Add(this->lblRead); this->Controls->Add(this->lblPriceBought); this->Controls->Add(this->label16); this->Controls->Add(this->lblDateAdded); this->Controls->Add(this->label15); this->Controls->Add(this->lblISBN); this->Controls->Add(this->label14); this->Controls->Add(this->lblBinding); this->Controls->Add(this->label13); this->Controls->Add(this->lblType); this->Controls->Add(this->label11); this->Controls->Add(this->lblPages); this->Controls->Add(this->label12); this->Controls->Add(this->lblEdition); this->Controls->Add(this->label10); this->Controls->Add(this->lblDewey); this->Controls->Add(this->label9); this->Controls->Add(this->lblDatePublished); this->Controls->Add(this->label8); this->Controls->Add(this->lblKeywords); this->Controls->Add(this->lblCopyID); this->Controls->Add(this->label7); this->Controls->Add(this->lblPublisher); this->Controls->Add(this->label4); this->Controls->Add(this->label5); this->Controls->Add(this->lblAuthor); this->Controls->Add(this->label3); this->Controls->Add(this->lblTitle); this->Controls->Add(this->label2); this->Controls->Add(this->picCoverImage); this->Name = L"BookDetailsControl"; this->Size = System::Drawing::Size(950, 250); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->picCoverImage))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion public: void ShowDetails(OdbcDataReader^ reader, array<String^>^ Keywords) { reader->Read(); array<Byte>^ ByteArray = gcnew array<Byte>(reader->GetBytes(12, 0, nullptr, 0, Int32::MaxValue)); reader->GetBytes(12, 0, ByteArray, 0, ByteArray->Length); IO::MemoryStream^ ms = gcnew IO::MemoryStream(ByteArray); if (ms->Length != 0) { picCoverImage->Image = Image::FromStream(ms); } else { picCoverImage->Image = nullptr; } lblTitle->Text = reader["Title"]->ToString(); lblAuthor->Text = reader["Author"]->ToString(); lblPublisher->Text = reader["Publisher"]->ToString(); lblCopyID->Text = reader["CopyID"]->ToString(); lblDatePublished->Text = String::Format("{0:D}", reader["PublicationDate"]); lblDewey->Text = reader["Dewey"]->ToString(); lblEdition->Text = reader["Edition"]->ToString(); lblPages->Text = reader["Pages"]->ToString(); lblISBN->Text = reader["ISBN"]->ToString(); lblDateAdded->Text = String::Format("{0:D}", reader["DateAdded"]); lblPriceBought->Text = String::Format("{0:C}", reader["PriceBought"]); if (reader["Type"]->ToString() == "0") { lblType->Text = "Fiction"; } else { lblType->Text = "Nonfiction"; } if (reader["Binding"]->ToString() == "0") { lblBinding->Text = "Paperback"; } else { lblBinding->Text = "Hardback"; } if (reader["HaveRead"]->ToString() == "0") { lblRead->Text = "This book has not been read."; } else { lblRead->Text = "This book has been read."; } lblKeywords->Text = ""; int i; for (i = 0; i < Keywords->Length; i++) { lblKeywords->Text = String::Concat(lblKeywords->Text, Keywords[i], ", "); } } }; }
[ "[email protected]@02cab514-f24f-0410-a9ea-a7698ff47c65" ]
[ [ [ 1, 505 ] ] ]
74265ade9b39088cfcc9314e1cfb2919ac06b1e2
8cf9b251e0f4a23a6ef979c33ee96ff4bdb829ab
/src-ginga-editing/gingancl-cpp/src/gingancl/model/time/CostFunctionDuration.cpp
68585a407e2cd56c6eed679e5de8d51015bac799
[]
no_license
BrunoSSts/ginga-wac
7436a9815427a74032c9d58028394ccaac45cbf9
ea4c5ab349b971bd7f4f2b0940f2f595e6475d6c
refs/heads/master
2020-05-20T22:21:33.645904
2011-10-17T12:34:32
2011-10-17T12:34:32
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
4,055
cpp
/****************************************************************************** Este arquivo eh parte da implementacao do ambiente declarativo do middleware Ginga (Ginga-NCL). Direitos Autorais Reservados (c) 1989-2007 PUC-Rio/Laboratorio TeleMidia Este programa eh software livre; voce pode redistribui-lo e/ou modificah-lo sob os termos da Licença Publica Geral GNU versao 2 conforme publicada pela Free Software Foundation. Este programa eh distribuído na expectativa de que seja util, porem, SEM NENHUMA GARANTIA; nem mesmo a garantia implicita de COMERCIABILIDADE OU ADEQUACAO A UMA FINALIDADE ESPECIFICA. Consulte a Licenca Publica Geral do GNU versao 2 para mais detalhes. Voce deve ter recebido uma copia da Licenca Publica Geral do GNU versao 2 junto com este programa; se nao, escreva para a Free Software Foundation, Inc., no endereco 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. Para maiores informacoes: ncl @ telemidia.puc-rio.br http://www.ncl.org.br http://www.ginga.org.br http://www.telemidia.puc-rio.br ****************************************************************************** This file is part of the declarative environment of middleware Ginga (Ginga-NCL) Copyright: 1989-2007 PUC-RIO/LABORATORIO TELEMIDIA, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License version 2 for more details. You should have received a copy of the GNU General Public License version 2 along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA For further information contact: ncl @ telemidia.puc-rio.br http://www.ncl.org.br http://www.ginga.org.br http://www.telemidia.puc-rio.br *******************************************************************************/ #include "../../../include/CostFunctionDuration.h" namespace br { namespace pucrio { namespace telemidia { namespace ginga { namespace ncl { namespace model { namespace time { CostFunctionDuration::CostFunctionDuration( double expectedValue, double minValue, double maxValue, TemporalFlexibilityFunction* function) : FlexibleTimeMeasurement( expectedValue, minValue, maxValue) { this->costFunction = function; } CostFunctionDuration::CostFunctionDuration(double expectedValue, TemporalFlexibilityFunction* function) : FlexibleTimeMeasurement( expectedValue, expectedValue, expectedValue) { this->costFunction = function; updateDurationInterval(); } TemporalFlexibilityFunction* CostFunctionDuration::getCostFunction() { return costFunction; } void CostFunctionDuration::setCostFunction( TemporalFlexibilityFunction* function) { costFunction = function; updateDurationInterval(); } void CostFunctionDuration::overwrite(CostFunctionDuration* dur) { FlexibleTimeMeasurement::overwrite(dur); costFunction = dur->getCostFunction(); } void CostFunctionDuration::updateDurationInterval() { if (!isNaN(expectedValue)) { if (costFunction->getShrinkingFactor() > 0 && costFunction->getShrinkingFactor() <= 1) { minimumValue = (long)((1 - costFunction-> getShrinkingFactor()) * expectedValue); } if (costFunction->getStretchingFactor() >= 0) { maximumValue = (long)((1 + costFunction-> getStretchingFactor()) * expectedValue); } else { maximumValue = infinity(); } } else { minimumValue = NaN(); maximumValue = NaN(); } } double CostFunctionDuration::getCostValue(double value) { return value; } } } } } } } }
[ [ [ 1, 129 ] ] ]
e28a09721c2ac2323d841968eaea12e12844c006
f13f46fbe8535a7573d0f399449c230a35cd2014
/JelloMan/TextFormatLoader.h
43c9f40504dcf27d666311c1d71fbe9a39d2c30f
[]
no_license
fangsunjian/jello-man
354f1c86edc2af55045d8d2bcb58d9cf9b26c68a
148170a4834a77a9e1549ad3bb746cb03470df8f
refs/heads/master
2020-12-24T16:42:11.511756
2011-06-14T10:16:51
2011-06-14T10:16:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
652
h
#pragma once #include "D3DUtil.h" #include "AssetContainer.h" class TextFormat; class TextFormatLoader { public: // CONSTRUCTOR - DESTRUCTOR TextFormatLoader(); virtual ~TextFormatLoader(); // GENERAL TextFormat* LoadTextFormat(const tstring& fontName, float size, bool bold = false, bool italic = false); private: HRESULT CreateWriteFactory(); // DATAMEMBERS IDWriteFactory* m_pDWriteFactory; AssetContainer<TextFormat>* m_pAssetContainer; // DISABLE DEFAULT COPY & ASSIGNMENT OPERATOR TextFormatLoader(const TextFormatLoader& yRef); TextFormatLoader& operator=(const TextFormatLoader& yRef); };
[ [ [ 1, 32 ] ] ]
0d82b3e48b45b25ee9d324a83c05b3bf57014708
d19003930543ea6f162a308eec675718d4fecd4f
/ShootingGameAlgorithmLibrary/include/ball/ball.h
f347e1dcbae12f4857333e2d17e279a562b8f5e6
[]
no_license
yudixiaok/shooting-game-algorithm-library
3414668b470fb3aa62bd5eefde2a7e91d26446ea
c114a2e365516f43e1b49df2363dbcf0119cc7bb
refs/heads/master
2020-04-04T00:36:39.699887
2011-07-18T07:08:07
2011-07-18T07:08:07
34,234,604
0
0
null
null
null
null
UTF-8
C++
false
false
792
h
#pragma once #include "../math/OgreVector3.h" #include "../common/utility.h" #include "behavior.h" #include <vector> #include <list> class Ball { public: enum BallStatus { FLY, STOP, DESTORY }; Ogre::Vector3 mPosition; Ogre::Vector3 mDirection; Ogre::Vector3 mUp; float mTimeRate; Behavior* mpBehavior; BallStatus mBallStatus; public: GET_CLASS_SIZE(Ball) inline Ball():mTimeRate(1) { } inline Ball(const Ogre::Vector3 pos, const Ogre::Vector3 dir, Behavior* behavior = NULL) :mTimeRate(1), mPosition(pos), mDirection(dir), mUp(Ogre::Vector3::UNIT_Z), mpBehavior(behavior), mBallStatus(FLY) { } int Update(float elapsedtime); bool HasBehavior(); }; typedef std::vector<Ball> BallVector; typedef std::list<Ball> BallList;
[ "t1238142000@bec1ec1d-4e10-fd0a-0ccf-f7fb723f4b98" ]
[ [ [ 1, 38 ] ] ]
172ebb59de2852da37c0645d0e7d782ff5c952ac
e3e69b1533b942e6b834cc53a461e2bfce68244e
/mensajes.cpp
99cb575401eb996d73e19e3d1546710a61c1036b
[]
no_license
berilevi/cidei
89d396e67a934e2c5698bd6d3b8d177ea829d7b5
3c84935809f0a68783733db57c3de6fdad2ecedf
refs/heads/master
2020-05-02T22:13:52.643632
2008-09-04T18:51:00
2008-09-04T18:51:00
33,262,364
0
0
null
null
null
null
ISO-8859-1
C++
false
false
3,650
cpp
// Class automatically generated by Dev-C++ New Class wizard #include <FL/Fl.H> #include <FL/fl_draw.H> #include "mensajes.h" // class's header file /******************************************************************************* * Mensajes::draw(): Método heredado para graficar. * Se debe sobrecargar este método para modificarlo ya que es heredado de la * clase FL_WIDGET. * Solamente se envían como parametro al método sobrecargado la posición y tamaño * de los gráficos. *******************************************************************************/ void Mensajes::draw(){ draw(x(),y(),w(),h()); } /******************************************************************************* * Mensajes::draw(int,int,int,int): Sobrecarga del método draw(), para dibujar * los números que indican el número de muestra * graficado en el analizador lógico. * fpos: Variable que equivale a la mitad del tiempo de bit en la gráfica, el * número se ubica en la mitad de la posición que ocupa la gráfica de una * muestra. * Los números que se grafican se generan con un ciclo desde cero hasta el número * de muestras. * El número se posiciona en la mitad de cada posición de muestra graficada. * inum_inicial : Número que inicia en la muestra que queda a la izquierda de la * pantalla del instrumento. *******************************************************************************/ void Mensajes::draw(int xx, int yy, int ww, int hh){ float fpos = inum_muestras/2; fl_color(_TextColour); //Color de los numero graficados fl_font(FL_HELVETICA,10); //Tipo y tamaño de Fuente for (int i=0;i<inum_muestras;i++){ //Ciclo para generar los numeros itoa((i+inum_inicial),text,10); //Convertir el número entero if (i+inum_inicial > 9) //Si el número solo tiene un digito fl_draw(text,(fpos+(inum_muestras*i)+(xx-6)),yy); else //Si el número tiene más de 1 digito se coloca 3 pixels más a tras para que quede centrado fl_draw(text,(fpos+(inum_muestras*i)+(xx-3)),yy); } } /******************************************************************************* * Mensajes::Mensajes: Constructor de la clase Mensajes. * Genera y grafica la numeración de las muestras graficadas del analizador * lógico. * Se inicializan las variables, color de los números y posición. *******************************************************************************/ Mensajes::Mensajes(int X, int Y, int W, int H, const char *l):Fl_Widget(X,Y,W,H,l){ x(X);y(Y); //Posición de los números TextColour(Fl_Color(0)); //Color del texto strcpy(text," "); //Inicializacion de la cadena de caracteres que contiene el numero graficado inum_muestras = 20; //Número de muestras representadas en pantalla inum_inicial = 0; //Número de muestra del extremo izquierdo de la pantalla del instrumento } /******************************************************************************* * Mensajes::~Mensajes: destructor de la clase *******************************************************************************/ Mensajes::~Mensajes(){ }
[ "juanpab1980@b98271d3-b73c-0410-b3e6-1dfb2072a0f9" ]
[ [ [ 1, 67 ] ] ]
e56cd11eb30b0fae2836889b6f36e3ecd3b37d3d
cc336f796b029620d6828804a866824daa6cc2e0
/cximage/CxImage/ximalyr.cpp
72835f19ba27f993d74956259f2964cb72a07fa0
[]
no_license
tokyovigilante/xbmc-sources-fork
84fa1a4b6fec5570ce37a69d667e9b48974e3dc3
ac3c6ef8c567f1eeb750ce6e74c63c2d53fcde11
refs/heads/master
2021-01-19T10:11:37.336476
2009-03-09T20:33:58
2009-03-09T20:33:58
29,232
2
0
null
null
null
null
UTF-8
C++
false
false
2,479
cpp
// Place the code and data below here into the CXIMAGE section. #ifndef _DLL #pragma code_seg( "CXIMAGE" ) #pragma data_seg( "CXIMAGE_RW" ) #pragma bss_seg( "CXIMAGE_RW" ) #pragma const_seg( "CXIMAGE_RD" ) #pragma comment(linker, "/merge:CXIMAGE_RW=CXIMAGE") #pragma comment(linker, "/merge:CXIMAGE_RD=CXIMAGE") #endif // xImaLyr.cpp : Layers functions /* 21/04/2003 v1.00 - [email protected] * CxImage version 5.80 29/Sep/2003 */ #include "ximage.h" #if CXIMAGE_SUPPORT_LAYERS //////////////////////////////////////////////////////////////////////////////// bool CxImage::LayerCreate(long position) { if ( position < 0 || position > info.nNumLayers ) position = info.nNumLayers; CxImage** ptmp = (CxImage**)malloc((info.nNumLayers + 1)*sizeof(CxImage**)); if (ptmp==0) return false; int i=0; for (int n=0; n<info.nNumLayers; n++){ if (position == n){ ptmp[n] = new CxImage(); i=1; } ptmp[n+i]=pLayers[n]; } if (i==0) ptmp[info.nNumLayers] = new CxImage(); if (ptmp[position]){ ptmp[position]->info.pParent = this; } else { free(ptmp); return false; } info.nNumLayers++; if (pLayers) free(pLayers); pLayers = ptmp; return true; } //////////////////////////////////////////////////////////////////////////////// bool CxImage::LayerDelete(long position) { if ( position >= info.nNumLayers ) return false; if ( position < 0) position = info.nNumLayers - 1; CxImage** ptmp = (CxImage**)malloc((info.nNumLayers - 1)*sizeof(CxImage**)); if (ptmp==0) return false; int i=0; for (int n=0; n<(info.nNumLayers - 1); n++){ if (position == n){ delete pLayers[n]; i=1; } ptmp[n]=pLayers[n+i]; } if (i==0) delete pLayers[info.nNumLayers - 1]; info.nNumLayers--; if (pLayers) free(pLayers); pLayers = ptmp; return true; } //////////////////////////////////////////////////////////////////////////////// void CxImage::LayerDeleteAll() { if (pLayers) { for(long n=0; n<info.nNumLayers;n++){ delete pLayers[n]; } free(pLayers); pLayers=0; } } //////////////////////////////////////////////////////////////////////////////// CxImage* CxImage::GetLayer(long position) { if ( position >= info.nNumLayers ) return 0; if ( position < 0) position = info.nNumLayers - 1; return pLayers[position]; } //////////////////////////////////////////////////////////////////////////////// #endif //CXIMAGE_SUPPORT_LAYERS
[ "jmarshallnz@568bbfeb-2a22-0410-94d2-cc84cf5bfa90" ]
[ [ [ 1, 89 ] ] ]
2a968a5508d98edfb09092717b42cbcb9420e741
724cded0e31f5fd52296d516b4c3d496f930fd19
/inc/jrtp/rtcpapppacket.h
800df8eef0ef04f7c65fd1cf4ce3d837be54c0a8
[]
no_license
yubik9/p2pcenter
0c85a38f2b3052adf90b113b2b8b5b312fefcb0a
fc4119f29625b1b1f4559ffbe81563e6fcd2b4ea
refs/heads/master
2021-08-27T15:40:05.663872
2009-02-19T00:13:33
2009-02-19T00:13:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,008
h
/* This file is a part of JRTPLIB Copyright (c) 1999-2006 Jori Liesenborgs Contact: [email protected] This library was developed at the "Expertisecentrum Digitale Media" (http://www.edm.uhasselt.be), a research center of the Hasselt University (http://www.uhasselt.be). The library is based upon work done for my thesis at the School for Knowledge Technology (Belgium/The Netherlands). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef RTCPAPPPACKET_H #define RTCPAPPPACKET_H #include "rtpconfig.h" #include "rtcppacket.h" #include "rtpstructs.h" #if ! (defined(WIN32) || defined(_WIN32_WCE)) #include <netinet/in.h> #endif // WIN32 class RTCPCompoundPacket; class RTCPAPPPacket : public RTCPPacket { public: RTCPAPPPacket(uint8_t *data,size_t datalen); ~RTCPAPPPacket() { } uint8_t GetSubType() const; uint32_t GetSSRC() const; uint8_t *GetName(); // Note that the name always consists of 4 octets and is not null-terminated uint8_t *GetAPPData(); size_t GetAPPDataLength() const; #ifdef RTPDEBUG void Dump(); #endif // RTPDEBUG private: size_t appdatalen; }; inline uint8_t RTCPAPPPacket::GetSubType() const { if (!knownformat) return 0; RTCPCommonHeader *hdr = (RTCPCommonHeader *)data; return hdr->count; } inline uint32_t RTCPAPPPacket::GetSSRC() const { if (!knownformat) return 0; uint32_t *ssrc = (uint32_t *)(data+sizeof(RTCPCommonHeader)); return ntohl(*ssrc); } inline uint8_t *RTCPAPPPacket::GetName() { if (!knownformat) return 0; return (data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)); } inline uint8_t *RTCPAPPPacket::GetAPPData() { if (!knownformat) return 0; if (appdatalen == 0) return 0; return (data+sizeof(RTCPCommonHeader)+sizeof(uint32_t)*2); } inline size_t RTCPAPPPacket::GetAPPDataLength() const { if (!knownformat) return 0; return appdatalen; } #endif // RTCPAPPPACKET_H
[ "fuwenke@b5bb1052-fe17-11dd-bc25-5f29055a2a2d" ]
[ [ [ 1, 106 ] ] ]
c3d829742a45fc2653590b8e0496f4b8b6fb661d
5b61b21b4ee18488e9bc1074ea32ed20c62f9633
/ExploreDirectories/SimpleWriter.h
0dabec0faec3b12c47edafacd91f865f21ac3f64
[]
no_license
mohammadharisbaig/opencv-kinect
ca8905e0c32b65b6410adf2a73e70562f1633fb0
e1dab326d44351da8dec4fa11a8ad1cb65dcfdcb
refs/heads/master
2016-09-06T17:33:51.809798
2011-09-01T21:22:55
2011-09-01T21:22:55
32,089,782
0
1
null
null
null
null
UTF-8
C++
false
false
657
h
#ifndef _SIMPLEWRITER_H #define _SIMPLEWRITER_H #include <fstream> #include <string> #include <vector> class SimpleWriter { // Class created to do file writing of simple structured files private: // Contains Variabels // 1- aFileWriter is an output stream to connect to the file you want to write std::ofstream aFileWriter; public: // Constructor SimpleWriter(); // the write function is over-ridden for different data types void writeFile(std::string fileName,std::vector<std::vector<float> > theData); void writeFile(std::string fileName,std::vector<std::string> theData); }; #endif
[ "[email protected]@b19eb72c-7a23-c4c4-98cb-0a5561f3c209" ]
[ [ [ 1, 30 ] ] ]
2fbf28d50302d2b5a7e828b3804da3086304003a
36d0ddb69764f39c440089ecebd10d7df14f75f3
/プログラム/Game/Manager/Scene/Option/XMLLoader.cpp
9b71b148cfa88c8d904f538e4d2d14d101cf4f7b
[]
no_license
weimingtom/tanuki-mo-issyo
3f57518b4e59f684db642bf064a30fc5cc4715b3
ab57362f3228354179927f58b14fa76b3d334472
refs/heads/master
2021-01-10T01:36:32.162752
2009-04-19T10:37:37
2009-04-19T10:37:37
48,733,344
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
2,987
cpp
/*******************************************************************************/ /* * @file XMLLoader.cpp. * * @brief XML読み込み補助クラス. * * @date 2009/01/13. * * @version 1.00. * * @author Kenji Iwata. */ /*******************************************************************************/ /*===== インクルード ==========================================================*/ #include <Ngl/TinyXML/XMLDomParserTinyXML.h> #include <Ngl/XML/XMLUtil.h> #include "XMLLoader.h" /*===== 定数宣言 ==============================================================*/ /*=============================================================================*/ /** * @brief コンストラクタ. * * @param[in] 引数名 引数説明. */ XMLLoader::XMLLoader() { } /*=============================================================================*/ /** * @brief デストラクタ. * */ XMLLoader::~XMLLoader() { } /*=============================================================================*/ /** * @brief 関数説明. * * @param[in] 引数名 引数説明. * @return 戻り値説明. */ SpriteInfo XMLLoader::LoadSpriteInfo( std::string name ) { SpriteInfo info; Ngl::XML::XMLFile file; Ngl::IXMLElement* spriteInfo; Ngl::IXMLElement* element = NULL; Ngl::TinyXML::XMLDomParserTinyXML xml; xml.load("Resource/Data/sprite.xml", file); spriteInfo = file.getElementByName("spriteInfo"); for(unsigned int i=0; i<spriteInfo->childElementCount(); i++) { if(spriteInfo->getElementByIndex(i)->getAttribByName("name").getText() == name) { element = spriteInfo->getElementByIndex(i); break; } } if(!element) return info; if(element->getElementByName("srcPositionX")) info.srcPosition.x << element->getElementByName("srcPositionX")->getValue(); if(element->getElementByName("srcPositionY")) info.srcPosition.y << element->getElementByName("srcPositionY")->getValue(); if(element->getElementByName("srcSizeX")) info.srcSize.x << element->getElementByName("srcSizeX")->getValue(); if(element->getElementByName("srcSizeY")) info.srcSize.y << element->getElementByName("srcSizeY")->getValue(); if(element->getElementByName("positionX")) info.position.x << element->getElementByName("positionX")->getValue(); if(element->getElementByName("positionY")) info.position.y << element->getElementByName("positionY")->getValue(); if(element->getElementByName("sizeX")) info.size.x << element->getElementByName("sizeX")->getValue(); if(element->getElementByName("sizeY")) info.size.y << element->getElementByName("sizeY")->getValue(); if(element->getElementByName("textureName")) info.spriteName << element->getElementByName("textureName")->getValue(); return info; } /*=============================================================================*/ /*===== EOF ===================================================================*/
[ "rs.drip@aa49b5b2-a402-11dd-98aa-2b35b7097d33" ]
[ [ [ 1, 93 ] ] ]
f0826f713c35a8c27d648e2a6c01344901442c46
ffe0a7d058b07d8f806d610fc242d1027314da23
/dev/threads/Master.h
9054ab4ff57ccc64b5c4d64d4a58e94f0113837d
[]
no_license
Cybie/mangchat
27bdcd886894f8fdf2c8956444450422ea853211
2303d126245a2b4778d80dda124df8eff614e80e
refs/heads/master
2016-09-11T13:03:57.386786
2009-12-13T22:09:37
2009-12-13T22:09:37
32,145,077
0
0
null
null
null
null
UTF-8
C++
false
false
221
h
#pragma once #include "Threading.h" class Master : public CyTHREAD::CThread { public: Master(void); ~Master(void); Master(void *arg); public: virtual void Setup(); virtual void Execute(void *arg); };
[ "cybraxvd@dfcbb000-c142-0410-b1aa-f54c88fa44bd" ]
[ [ [ 1, 14 ] ] ]
a9223ebeb45ea8f949e71e46860ce87ed4d05ace
c3a0cf3d0c023cbdb9a1ab8295aa1231543d83e7
/sln/src/FbgRenderer.cpp
fd41a6dacc9979013fd31d2e256dcfe138210966
[]
no_license
yakergong/seedcup2008
2596cdb5fe404ef8628366cdd2f8003141625264
e57b92cf576900ba6cb5e0c0f6661bba3e7f75d7
refs/heads/master
2016-09-05T11:06:12.717346
2008-12-19T13:04:28
2008-12-19T13:04:28
32,268,668
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
32,785
cpp
/* * Falling Block Game * Copyright (C) 1999-2002 Jared Krinke <http://derajdezine.vze.com/> * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 or (at your option) any later version * as published by the Free Software Foundation. * * This application is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA * * Jared Krinke * * Deraj DeZine * http://derajdezine.vze.com/ */ #include "glTGAImage.h" #include "FbgBlock.h" #include "FbgRenderer.h" #include "FbgGame.h" #include "FbgResource.h" #include "GameMgr.h" #include "ConfigMgr.h" #include <windows.h> #include <GL/gl.h> #include <GL/glu.h> #include <SDL/SDL.h> #include <math.h> #include <iostream> #include <stdlib.h> FbgRenderer FbgRenderer::instance_; using namespace std; #define FBG_TITLE "Falling Block Game" #pragma warning(disable:4996) bool FbgRenderer::init(bool fs, int width, int height, int bpp) { // Initialize SDL/OpenGL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) { cerr << "Unable to initialize SDL: " << SDL_GetError() << endl; return false; } SDL_WM_SetCaption(FBG_TITLE, NULL); if (fs) SDL_ShowCursor(0); // User didn't specify bpp if (bpp < 0) bpp = SDL_GetVideoInfo()->vfmt->BitsPerPixel; // Set bits per channel const unsigned char bpc = bpp < 32 ? 4 : 5; SDL_GL_SetAttribute(SDL_GL_RED_SIZE, bpc); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, bpc); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, bpc); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (SDL_SetVideoMode(width, height, bpp, (fs ? SDL_FULLSCREEN : 0) | SDL_OPENGL) == NULL) { cerr << "Unable to Create OpenGL Screen: " << SDL_GetError() << endl; return false; } glViewport(0, 0, width, height); // Setup OpenGL Viewport glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, GLfloat(4) / GLfloat(3), 300.0f, 2000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); loadTextures(); buildLists(); // Setup OpenGL options (lighting, texturing, etc.) glEnable(GL_TEXTURE_2D); glShadeModel(GL_FLAT); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); GLfloat LightAmbient[] = { 0.2f, 0.2f, 0.2f, 1.0f }; GLfloat LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat LightPosition[] = { -2.0f, 2.0f, 0.0f, 1.0f }; glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); glEnable(GL_LIGHT1); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); // Setup line gain speeds for (int row = 0; row < 4; row++) { for (int col = 0; col < 10; col++) lineZSpeeds_[row][col] = float (rand() % 100 + 50) / 100 * 250; } return true; } void FbgRenderer::exit() { killLists(); // Quit SDL SDL_Quit(); } void FbgRenderer::loadTextures() { FbgResource& resource = FbgResource::Instance(); GLTgaImage bgload, mlload, mbload, mtload, nbload, blocksload, digitsload, gameoverload; // Load Images if ( !bgload.loadTGAImage(resource.LoadThemeFile("bg.tga")) || !mlload.loadTGAImage(resource.LoadThemeFile("ml.tga")) || !mbload.loadTGAImage(resource.LoadThemeFile("mb.tga")) || !mtload.loadTGAImage(resource.LoadThemeFile("mt.tga")) || !nbload.loadTGAImage(resource.LoadThemeFile("nb.tga")) || !nr_.loadTGAImage(resource.LoadThemeFile("nr.tga")) || !blocksload.loadTGAImage(resource.LoadThemeFile("blockmap.tga")) || !digitsload.loadTGAImage(resource.LoadThemeFile("digits.tga")) || !gameoverload.loadTGAImage(resource.LoadThemeFile("gameover.tga")) || !msb_.loadTGAImage(resource.LoadThemeFile("msb.tga")) ) { cout << "Could not load graphics" << endl; ::exit(0); } // Setup Images bg_ = bgload.splitImageMap(256, 256, 12); for (int i = 0; i < 12; i++) bg_[i].makeClamped(); mlload.cropImage(0, -24, 64, 768); ml_ = mlload.splitImageMap(64, 256, 3); for (int i = 0; i < 3; i++) ml_[i].makeClamped(); mbload.cropImage(-24, 0, 512, 64); mb_ = mbload.splitImageMap(256, 64, 2); for (int i = 0; i < 2; i++) mb_[i].makeClamped(); mtload.cropImage(-24, 0, 512, 64); mt_ = mtload.splitImageMap(256, 64, 2); for (int i = 0; i < 2; i++) mt_[i].makeClamped(); nbload.cropImage(-32, 0, 512, 64); nb_ = nbload.splitImageMap(256, 64, 2); for (int i = 0; i < 2; i++) nb_[i].makeClamped(); nr_.cropImage(0, -32, 64, 256); nr_.makeClamped(); blocks_ = blocksload.splitImageMap(64, 64, 7); digits_ = digitsload.splitImageMap(64, 64, 10); for (int i = 0; i < 10; i++) digits_[i].makeClamped(); gameover_ = gameoverload.splitImageMap(256, 256, 2); for (int i = 0; i < 2; i++) gameover_[i].makeClamped(); } void FbgRenderer::killTextures() { delete[] bg_; delete[] ml_; delete[] mb_; delete[] mt_; delete[] nb_; delete[] digits_; delete[] gameover_; } void FbgRenderer::buildLists() { cube_ = glGenLists(2); glNewList(cube_, GL_COMPILE); // Back glBegin(GL_TRIANGLE_STRIP); glNormal3f(0.0f, 0.0f, -1.0f); glTexCoord2d(1,1);glVertex3f(0.0f, 0.0f, -40.0f); glTexCoord2d(0,1);glVertex3f(40.0f, 0.0f, -40.0f); glTexCoord2d(1,0);glVertex3f(0.0f, -40.0f, -40.0f); glTexCoord2d(0,0);glVertex3f(40.0f, -40.0f, -40.0f); glEnd(); // Bottom glBegin(GL_TRIANGLE_STRIP); glNormal3f(0.0f, -1.0f, 0.0f); glTexCoord2d(1,1);glVertex3f(40.0f, -40.0f, 0.0f); glTexCoord2d(0,1);glVertex3f(0.0f, -40.0f, 0.0f); glTexCoord2d(1,0);glVertex3f(40.0f, -40.0f, -40.0f); glTexCoord2d(0,0);glVertex3f(0.0f, -40.0f, -40.0f); glEnd(); // Top glBegin(GL_TRIANGLE_STRIP); glNormal3f(0.0f, 1.0f, 0.0f); glTexCoord2d(1,1);glVertex3f(40.0f, 0.0f, -40.0f); glTexCoord2d(0,1);glVertex3f(0.0f, 0.0f, -40.0f); glTexCoord2d(1,0);glVertex3f(40.0f, 0.0f, 0.0f); glTexCoord2d(0,0);glVertex3f(0.0f, 0.0f, 0.0f); glEnd(); // Left glBegin(GL_TRIANGLE_STRIP); glNormal3f(-1.0f, 0.0f, 0.0f); glTexCoord2d(1,1);glVertex3f(0.0f, 0.0f, 0.0f); glTexCoord2d(0,1);glVertex3f(0.0f, 0.0f, -40.0f); glTexCoord2d(1,0);glVertex3f(0.0f, -40.0f, 0.0f); glTexCoord2d(0,0);glVertex3f(0.0f, -40.0f, -40.0f); glEnd(); // Right glBegin(GL_TRIANGLE_STRIP); glNormal3f(1.0f, 0.0f, 0.0f); glTexCoord2d(1,1);glVertex3f(40.0f, 0.0f, -40.0f); glTexCoord2d(0,1);glVertex3f(40.0f, 0.0f, 0.0f); glTexCoord2d(1,0);glVertex3f(40.0f, -40.0f, -40.0f); glTexCoord2d(0,0);glVertex3f(40.0f, -40.0f, 0.0f); glEnd(); // Front glBegin(GL_TRIANGLE_STRIP); glNormal3f(0.0f, 0.0f, 1.0f); glTexCoord2d(1,1);glVertex3f(40.0f, 0.0f, 0.0f); glTexCoord2d(0,1);glVertex3f(0.0f, 0.0f, 0.0f); glTexCoord2d(1,0);glVertex3f(40.0f, -40.0f, 0.0f); glTexCoord2d(0,0);glVertex3f(0.0f, -40.0f, 0.0f); glEnd(); glEndList(); cubeWithoutBack_ = cube_+1; glNewList(cubeWithoutBack_, GL_COMPILE); // Bottom glBegin(GL_TRIANGLE_STRIP); glNormal3f(0.0f, -1.0f, 0.0f); glTexCoord2d(1,1);glVertex3f(40.0f, -40.0f, 0.0f); glTexCoord2d(0,1);glVertex3f(0.0f, -40.0f, 0.0f); glTexCoord2d(1,0);glVertex3f(40.0f, -40.0f, -40.0f); glTexCoord2d(0,0);glVertex3f(0.0f, -40.0f, -40.0f); glEnd(); // Top glBegin(GL_TRIANGLE_STRIP); glNormal3f(0.0f, 1.0f, 0.0f); glTexCoord2d(1,1);glVertex3f(40.0f, 0.0f, -40.0f); glTexCoord2d(0,1);glVertex3f(0.0f, 0.0f, -40.0f); glTexCoord2d(1,0);glVertex3f(40.0f, 0.0f, 0.0f); glTexCoord2d(0,0);glVertex3f(0.0f, 0.0f, 0.0f); glEnd(); // Left glBegin(GL_TRIANGLE_STRIP); glNormal3f(-1.0f, 0.0f, 0.0f); glTexCoord2d(1,1);glVertex3f(0.0f, 0.0f, 0.0f); glTexCoord2d(0,1);glVertex3f(0.0f, 0.0f, -40.0f); glTexCoord2d(1,0);glVertex3f(0.0f, -40.0f, 0.0f); glTexCoord2d(0,0);glVertex3f(0.0f, -40.0f, -40.0f); glEnd(); // Right glBegin(GL_TRIANGLE_STRIP); glNormal3f(1.0f, 0.0f, 0.0f); glTexCoord2d(1,1);glVertex3f(40.0f, 0.0f, -40.0f); glTexCoord2d(0,1);glVertex3f(40.0f, 0.0f, 0.0f); glTexCoord2d(1,0);glVertex3f(40.0f, -40.0f, -40.0f); glTexCoord2d(0,0);glVertex3f(40.0f, -40.0f, 0.0f); glEnd(); // Front glBegin(GL_TRIANGLE_STRIP); glNormal3f(0.0f, 0.0f, 1.0f); glTexCoord2d(1,1);glVertex3f(40.0f, 0.0f, 0.0f); glTexCoord2d(0,1);glVertex3f(0.0f, 0.0f, 0.0f); glTexCoord2d(1,0);glVertex3f(40.0f, -40.0f, 0.0f); glTexCoord2d(0,0);glVertex3f(0.0f, -40.0f, 0.0f); glEnd(); glEndList(); digitsBase_=glGenLists(10); for (int i=0; i<10; i++) { glNewList(digitsBase_+i, GL_COMPILE); glBindTexture(GL_TEXTURE_2D, digits_[i].getID()); glBegin(GL_TRIANGLE_STRIP); glNormal3f(32.0f,-32.0f,10.0f); glTexCoord2f(0.0f,1.0f);glVertex3f(0.0f, 64.0f, 0.0f); glTexCoord2f(0.0f,0.0f);glVertex3f(0.0f, 0.0f, 0.0f); glTexCoord2f(1.0f,1.0f);glVertex3f(64.0f, 64.0f, 0.0f); glTexCoord2f(1.0f,0.0f);glVertex3f(64.0f, 0.0f, 0.0f); glEnd(); glEndList(); } } void FbgRenderer::killLists() { glDeleteLists(cube_, 2); glDeleteLists(digitsBase_, 10); } void FbgRenderer::drawDigits(const string & str) { for (size_t i = 0; i < str.size(); i++) { if (str[i] >= 48 && str[i] <= 57) glCallList(digitsBase_ + str[i] - 48); glTranslatef(64.0f, 0.0f, 0.0f); } // Move back glTranslatef(-float (str.size() * 64), 0.0f, 0.0f); } void FbgRenderer::draw() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Makes the visible screen 0-1024x 0-(-768)y glLoadIdentity(); glTranslatef(-512.0f,384.0f,-927.05801f); vector<FbgGame *>& vec = GameMgr::Instance().GetGameVec(); for(int i = 0; i < (int)vec.size(); ++i) { FbgGame *game = vec[i]; string mode = game->getMode(); int singleMode = ConfigMgr().GetIntegerValue(mode + ".single_mode"); if(!singleMode) { glPushMatrix(); glTranslatef(game->getDestCoord().first, game->getDestCoord().second, 0.0f); glScalef(0.5f, 0.5f, 0.5f); } drawBkgnd(game); drawCurBlockFrame(game); if(singleMode) { drawNextBlockFrame(game); drawNextBlock(game); drawGameInfo(game); } if (game->getLineGain()) drawLineGain(game); else { if (game->getState() == GAMEOVER) drawGameOver(game); else drawGameplay(game); } if(!singleMode) { drawGameID(game); glPopMatrix(); glPushMatrix(); glScalef(0.5f, 0.5f, 0.5f); drawMulGameInfo(game); glPopMatrix(); } } SDL_GL_SwapBuffers(); } void FbgRenderer::drawGameMatrix( FbgGame *game ) { glPushMatrix(); glTranslatef(24.0f, -24.0f, -24.0f); for (int row = 0; row < 18; row++) { for (int col = 0; col < 10; col++) { if (game->getMatrixAt(row, col)) { glBindTexture(GL_TEXTURE_2D, blocks_[game->getMatrixAt(row, col) - 1].getID()); glCallList(cubeWithoutBack_); } glTranslatef(40.0f, 0.0f, 0.0f); } glTranslatef(-400.0f, -40.0f, 0.0f); // Move to front of row } glPopMatrix(); } void FbgRenderer::drawBlock( FbgGame *game, FbgBlock * theBlock ) { // Draw Next Block glPushMatrix(); glTranslatef(48.0f + 627.0f, -568.0f, 0.0f); glTranslatef(float (theBlock->getWidth() % 2) * (20.0f), (4.0f - theBlock->getHeight()) / 2 * (-40.0f), 20.0f); glBindTexture(GL_TEXTURE_2D, blocks_[theBlock->getIndex()].getID()); for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { if (theBlock->getMatrixAt(row, col)) glCallList(cube_ + 1); glTranslatef(40.0f, 0.0f, 0.0f); } glTranslatef(-160.0f, -40.0f, 0.0f); // Move to front of row } glPopMatrix(); } void FbgRenderer::drawGameOver( FbgGame *game ) { glEnable(GL_LIGHTING); drawGameMatrix(game); glDisable(GL_LIGHTING); glBindTexture(GL_TEXTURE_2D, gameover_[0].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, -256.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, -512.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(256.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(256.0f, -512.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, gameover_[1].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(256.0f, -256.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(256.0f, -512.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(512.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(512.0f, -512.0f, 0.0f); glEnd(); } void FbgRenderer::drawGameplay( FbgGame *game ) { glEnable(GL_LIGHTING); // Draw Matrix drawGameMatrix(game); // Current Block glPushMatrix(); glTranslatef(24.0f + game->getCurBlock()->getPosX() * 40.0f, -24.0f - game->getCurBlock()->getPosY() * 40.0f , -24.0f); glBindTexture(GL_TEXTURE_2D, blocks_[game->getCurBlock()->getIndex()].getID()); for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { if (game->getCurBlock()->getMatrixAt(row, col)) glCallList(cube_ + 1); glTranslatef(40.0f, 0.0f, 0.0f); } glTranslatef(-160.0f, -40.0f, 0.0f); } glPopMatrix(); glDisable(GL_LIGHTING); } void FbgRenderer::drawLineGain( FbgGame *game ) { // Draw non-transparent matrix glTranslatef(24.0f, -24.0f - 680.0f, -24.0f); for (int row = 17; row >= 0; row--) { for (int col = 0; col < 10; col++) { if (game->getMatrixAt(row , col)) { glBindTexture(GL_TEXTURE_2D, blocks_[game->getMatrixAt( row , col) - 1].getID()); glCallList(cubeWithoutBack_); } glTranslatef(40.0f, 0.0f, 0.0f); } glTranslatef(-400.0f, 40.0f, 0.0f); // Move to front of row } glTranslatef(-24.0f, 24.0f - 40.0f, 24.0f); // If a level was gained if (game->getLineGain()->levelGained > 1) { char tmpString[3]; glEnable(GL_BLEND); glColor4f(1.0f, 1.0f, 1.0f, 1.0f ); glTranslatef(512.0f, -368.0f, 0.0f); sprintf(tmpString, "%02u", game->getLineGain()->levelGained); drawDigits(tmpString); glTranslatef(512.0f, -368.0f, 0.0f); glDisable(GL_BLEND); } drawCurBlock(game); glDisable(GL_LIGHTING); } void FbgRenderer::drawBkgnd(FbgGame *game) { // ×ó²à±³¾°Í¼ glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glBindTexture(GL_TEXTURE_2D, bg_[0].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f);glVertex3f(0.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.90625f);glVertex3f(0.0f, -24.0f, 0.0f); glTexCoord2f(1.0f, 1.0f);glVertex3f(256.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.90625f);glVertex3f(256.0f, -24.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[1].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(256.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.90625f); glVertex3f(256.0f, -24.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(512.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.90625f); glVertex3f(512.0f, -24.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[0].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.90625f); glVertex3f(0.0f, -24.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, -256.0f, 0.0f); glTexCoord2f(0.09375f, 0.90625f); glVertex3f(24.0f, -24.0f, 0.0f); glTexCoord2f(0.09375f, 0.0f); glVertex3f(24.0f, -256.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[4].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 1); glVertex3f(0.0f, -256.0f, 0.0f); glTexCoord2f(0, 0); glVertex3f(0.0f, -512.0f, 0.0f); glTexCoord2f(0.09375f, 1); glVertex3f(24.0f, -256.0f, 0.0f); glTexCoord2f(0.09375f, 0); glVertex3f(24.0f, -512.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[8].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 1); glVertex3f(0.0f, -512.0f, 0.0f); glTexCoord2f(0, 0.09375f); glVertex3f(0.0f, -744.0f, 0.0f); glTexCoord2f(0.09375f, 1); glVertex3f(24.0f, -512.0f, 0.0f); glTexCoord2f(0.09375f, 0.09375f); glVertex3f(24.0f, -744.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[1].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.65625f, 0.90625f); glVertex3f(424.0f, -24.0f, 0.0f); glTexCoord2f(0.65625f, 0.0f); glVertex3f(424.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 0.90625f); glVertex3f(512.0f, -24.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(512.0f, -256.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[5].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.65625f, 1.0f); glVertex3f(424.0f, -256.0f, 0.0f); glTexCoord2f(0.65625f, 0.0f); glVertex3f(424.0f, -512.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(512.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(512.0f, -512.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[9].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.65625f, 1.0f); glVertex3f(424.0f, -512.0f, 0.0f); glTexCoord2f(0.65625f, 0.09375f); glVertex3f(424.0f, -744.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(512.0f, -512.0f, 0.0f); glTexCoord2f(1.0f, 0.09375f); glVertex3f(512.0f, -744.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[8].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.09375f); glVertex3f(0.0f, -744.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, -768.0f, 0.0f); glTexCoord2f(1.0f, 0.09375f); glVertex3f(256.0f, -744.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(256.0f, -768.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[9].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.09375f); glVertex3f(256.0f, -744.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(256.0f, -768.0f, 0.0f); glTexCoord2f(1.0f, 0.09375f); glVertex3f(512.0f, -744.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(512.0f, -768.0f, 0.0f); glEnd(); ConfigMgr config; if( !config.GetIntegerValue(game->getMode() + ".single_mode") ) return; // ÓҲ౳¾°Í¼ glBindTexture(GL_TEXTURE_2D, bg_[2].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(512.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(512.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(768.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(768.0f, -256.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[3].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(768.0f, 0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(768.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(1024.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(1024.0f, -256.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[6].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(512.0f, -256.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(512.0f, -512.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(768.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(768.0f, -512.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[7].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(768.0f, -256.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(768.0f, -512.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(1024.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(1024.0f, -512.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[10].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.09375f); glVertex3f(512.0f, -744.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(512.0f, -768.0f, 0.0f); glTexCoord2f(1.0f, 0.09375f); glVertex3f(768.0f, -744.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(768.0f, -768.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[11].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.09375f); glVertex3f(768.0f, -744.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(768.0f, -768.0f, 0.0f); glTexCoord2f(1.0f, 0.09375f); glVertex3f(1024.0f, -744.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(1024.0f, -768.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[10].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(512.0f, -512.0f, 0.0f); glTexCoord2f(0.0f, 0.09375f); glVertex3f(512.0f, -744.0f, 0.0f); glTexCoord2f(0.5625f, 1.0f); glVertex3f(656.0f, -512.0f, 0.0f); glTexCoord2f(0.5625f, 0.09375f); glVertex3f(656.0f, -744.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[11].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.3125f, 1.0f); glVertex3f(848.0f, -512.0f, 0.0f); glTexCoord2f(0.3125f, 0.09375f); glVertex3f(848.0f, -744.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(1024.0f, -512.0f, 0.0f); glTexCoord2f(1.0f, 0.09375f); glVertex3f(1024.0f, -744.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[10].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.5625f, 1.0f); glVertex3f(656.0f, -512.0f, 0.0f); glTexCoord2f(0.5625f, 0.84375f); glVertex3f(656.0f, -552.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(768.0f, -512.0f, 0.0f); glTexCoord2f(1.0f, 0.84375f); glVertex3f(768.0f, -552.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[11].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(768.0f, -512.0f, 0.0f); glTexCoord2f(0.0f, 0.84375f); glVertex3f(768.0f, -552.0f, 0.0f); glTexCoord2f(0.3125f, 1.0f); glVertex3f(848.0f, -512.0f, 0.0f); glTexCoord2f(0.3125f, 0.84375f); glVertex3f(848.0f, -552.0f, 0.0f); glEnd(); } void FbgRenderer::drawNextBlockFrame( FbgGame *game ) { // Next Block Insets glBindTexture(GL_TEXTURE_2D, nb_[0].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.5625f, 1.0f); glVertex3f(656.0f, -744.0f, -64.0f); glTexCoord2f(0.5625f, 0.0f); glVertex3f(656.0f, -744.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(768.0f, -744.0f, -64.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(768.0f, -744.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, nb_[1].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(768.0f, -744.0f, -64.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(768.0f, -744.0f, 0.0f); glTexCoord2f(0.3125f, 1.0f); glVertex3f(848.0f, -744.0f, -64.0f); glTexCoord2f(0.3125f, 0.0f); glVertex3f(848.0f, -744.0f, 0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, nr_.getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.84375f); glVertex3f(848.0f, -552.0f, -64.0f); glTexCoord2f(0.0f, 0.09375f); glVertex3f(848.0f, -744.0f, -64.0f); glTexCoord2f(1.0f, 0.84375f); glVertex3f(848.0f, -552.0f, 0.0f); glTexCoord2f(1.0f, 0.09375f); glVertex3f(848.0f, -744.0f, 0.0f); glEnd(); // Next Block Backing glBindTexture(GL_TEXTURE_2D, bg_[10].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.5625f, 0.84375f); glVertex3f(656.0f, -552.0f, -64.0f); glTexCoord2f(0.5625f, 0.125f); glVertex3f(656.0f, -744.0f, -64.0f); glTexCoord2f(1.0f, 0.84375f); glVertex3f(768.0f, -552.0f, -64.0f); glTexCoord2f(1.0f, 0.125f); glVertex3f(768.0f, -744.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[11].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.84375f); glVertex3f(768.0f, -552.0f, -64.0f); glTexCoord2f(0.0f, 0.125f); glVertex3f(768.0f, -744.0f, -64.0f); glTexCoord2f(0.3125f, 0.84375f); glVertex3f(848.0f, -552.0f, -64.0f); glTexCoord2f(0.3125f, 0.125f); glVertex3f(848.0f, -744.0f, -64.0f); glEnd(); } void FbgRenderer::drawCurBlockFrame( FbgGame *game ) { // Main Insets glBindTexture(GL_TEXTURE_2D, ml_[0].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.90625f); glVertex3f(24.0f, -24.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(24.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 0.90625f); glVertex3f(24.0f, -24.0f, -64.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(24.0f, -256.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, ml_[1].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(24.0f, -256.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(24.0f, -512.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(24.0f, -256.0f, -64.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(24.0f, -512.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, ml_[2].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(24.0f, -512.0f, 0.0f); glTexCoord2f(0.0f, 0.09375f); glVertex3f(24.0f, -744.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(24.0f, -512.0f, -64.0f); glTexCoord2f(1.0f, 0.09375f); glVertex3f(24.0f, -744.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, mb_[0].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.09375f, 1.0f); glVertex3f(24.0f, -744.0f, -64.0f); glTexCoord2f(0.09375f, 0.0f); glVertex3f(24.0f, -744.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(256.0f, -744.0f, -64.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(256.0f, -744.0f, -0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, mb_[1].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(256.0f, -744.0f, -64.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(256.0f, -744.0f, 0.0f); glTexCoord2f(0.65625f, 1.0f); glVertex3f(424.0f, -744.0f, -64.0f); glTexCoord2f(0.65625f, 0.0f); glVertex3f(424.0f, -744.0f, -0.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, mt_[0].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.09375f, 1.0f); glVertex3f(24.0f, -24.0f, 0.0f); glTexCoord2f(0.09375f, 0.0f); glVertex3f(24.0f, -24.0f, -64.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(256.0f, -24.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(256.0f, -24.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, mt_[1].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(256.0f, -24.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(256.0f, -24.0f, -64.0f); glTexCoord2f(0.65625f, 1.0f); glVertex3f(424.0f, -24.0f, 0.0f); glTexCoord2f(0.65625f, 0.0f); glVertex3f(424.0f, -24.0f, -64.0f); glEnd(); // Main Backing glBindTexture(GL_TEXTURE_2D, bg_[0].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.09375f, 0.90625f); glVertex3f(24.0f, -24.0f, -64.0f); glTexCoord2f(0.09375f, 0.0f); glVertex3f(24.0f, -256.0f, -64.0f); glTexCoord2f(1.0f, 0.90625f); glVertex3f(256.0f, -24.0f, -64.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(256.0f, -256.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[1].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 0.90625f); glVertex3f(256.0f, -24.0f, -64.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(256.0f, -256.0f, -64.0f); glTexCoord2f(0.65625f, 0.90625f); glVertex3f(424.0f, -24.0f, -64.0f); glTexCoord2f(0.65625f, 0.0f); glVertex3f(424.0f, -256.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[4].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.09375f, 1.0f); glVertex3f(24.0f, -256.0f, -64.0f); glTexCoord2f(0.09375f, 0.0f); glVertex3f(24.0f, -512.0f, -64.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(256.0f, -256.0f, -64.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(256.0f, -512.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[5].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(256.0f, -256.0f, -64.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(256.0f, -512.0f, -64.0f); glTexCoord2f(0.65625f, 1.0f); glVertex3f(424.0f, -256.0f, -64.0f); glTexCoord2f(0.65625f, 0.0f); glVertex3f(424.0f, -512.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[8].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.09375f, 1.0f); glVertex3f(24.0f, -512.0f, -64.0f); glTexCoord2f(0.09375f, 0.09375f); glVertex3f(24.0f, -744.0f, -64.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(256.0f, -512.0f, -64.0f); glTexCoord2f(1.0f, 0.09375f); glVertex3f(256.0f, -744.0f, -64.0f); glEnd(); glBindTexture(GL_TEXTURE_2D, bg_[9].getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(256.0f, -512.0f, -64.0f); glTexCoord2f(0.0f, 0.09375f); glVertex3f(256.0f, -744.0f, -64.0f); glTexCoord2f(0.65625f, 1.0f); glVertex3f(424.0f, -512.0f, -64.0f); glTexCoord2f(0.65625f, 0.09375f); glVertex3f(424.0f, -744.0f, -64.0f); glEnd(); } void FbgRenderer::drawGameInfo( FbgGame *game ) { // Draw Level, Lines, Score char tmpString[9]; glPushMatrix(); glTranslatef(512.0f, -368.0f, 0.0f); sprintf(tmpString, "%02u", game->getLevel()); drawDigits(tmpString); glPopMatrix(); glPushMatrix(); glTranslatef(800.0f, -368.0f, 0.0f); sprintf(tmpString, "%03u", game->getLines()); drawDigits(tmpString); glPopMatrix(); glPushMatrix(); glTranslatef(528.0f, -480.0f, 0.0f); sprintf(tmpString, "%07u", game->getScore()); drawDigits(tmpString); glPopMatrix(); } FbgRenderer::FbgRenderer() { } FbgRenderer& FbgRenderer::Instance() { return instance_; } void FbgRenderer::drawNextBlock( FbgGame * game ) { drawBlock(game, game->getBlockSet(game->getNextBlockIndex())); } void FbgRenderer::drawCurBlock( FbgGame * game ) { drawBlock(game, game->getCurBlock()); } void FbgRenderer::drawMulGameInfo( FbgGame *game ) { glPushMatrix(); float translateY = -256.0f * float(game->getID()); glTranslatef(1024.0f, translateY, 0.0f); glBindTexture(GL_TEXTURE_2D, msb_.getID()); glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0.0f, 1.0f); glVertex3f(512.0f, -0.0f, 0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(512.0f, -256.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(1024.0f, -0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(1024.0f, -256.0f, 0.0f); glEnd(); // Draw Level, Lines, Score char tmpString[9]; glPushMatrix(); glTranslatef(512.0f, -112.0f, 0.0f); sprintf(tmpString, "%02u", game->getLevel()); drawDigits(tmpString); glPopMatrix(); glPushMatrix(); glTranslatef(800.0f, -112.0f, 0.0f); sprintf(tmpString, "%u", game->getTotalLines()); glTranslatef(64.0f*(3 - strlen(tmpString)), 0.0f, 0.0f); drawDigits(tmpString); glPopMatrix(); glPushMatrix(); glTranslatef(528.0f, -244.0f, 0.0f); sprintf(tmpString, "%u", game->getTotalScore()); glTranslatef(64.0f*(7 - strlen(tmpString)), 0.0f, 0.0f); drawDigits(tmpString); glPopMatrix(); glPopMatrix(); } void FbgRenderer::drawGameID( FbgGame *game ) { char tmpString[2]; glPushMatrix(); glTranslatef(0.0f, -64.0f, 0.0f); sprintf(tmpString, "%01u", game->getID()); drawDigits(tmpString); glPopMatrix(); } #pragma warning(default:4996)
[ "yakergong@c3067968-ca50-11dd-8ca8-e3ff79f713b6" ]
[ [ [ 1, 897 ] ] ]
49843cfe796d71805c3c20e13c1e442ec509aa14
c9599775f0da57207d0a90f88a588e054f926b04
/guano/math/vector2.h
e1395e45dc94eabdfa3c786261f5d3ba036f2965
[]
no_license
isoiphone/ggjvic
7faced0e60ad4dae69131bf4b4925000f0170a86
ff8b47013152f5f0909232f00b2a514c2321a267
refs/heads/master
2020-06-01T05:09:55.790734
2011-01-30T23:04:33
2011-01-30T23:04:33
32,309,386
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
4,134
h
/**************************************** * 2D Vector Classes * By Bill Perone ([email protected]) * Original: 9-16-2002 * Revised: 19-11-2003 * 18-12-2003 * 06-06-2004 * * © 2003, This code is provided "as is" and you can use it freely as long as * credit is given to Bill Perone in the application it is used in ****************************************/ #pragma once #include <math.h> template <typename T> struct vector2 { T x, y; //! trivial ctor vector2<T>() {} //! setting ctor vector2<T>(const T x0, const T y0): x(x0), y(y0) {} //! array indexing T &operator [](unsigned int i) { return *(&x+i); } //! array indexing const T &operator [](unsigned int i) const { return *(&x+i); } //! function call operator void operator ()(const T x0, const T y0) { x= x0; y= y0; } //! test for equality bool operator==(const vector2<T> &v) { return (x==v.x && y==v.y); } //! test for inequality bool operator!=(const vector2<T> &v) { return (x!=v.x || y!=v.y); } //! set to value const vector2<T> &operator =(const vector2<T> &v) { x= v.x; y= v.y; return *this; } //! negation const vector2<T> operator -(void) const { return vector2<T>(-x, -y); } //! addition const vector2<T> operator +(const vector2<T> &v) const { return vector2<T>(x+v.x, y+v.y); } //! subtraction const vector2<T> operator -(const vector2<T> &v) const { return vector2<T>(x-v.x, y-v.y); } //! uniform scaling const vector2<T> operator *(const T num) const { vector2<T> temp(*this); return temp*=num; } //! uniform scaling const vector2<T> operator /(const T num) const { vector2<T> temp(*this); return temp/=num; } //! addition const vector2<T> &operator +=(const vector2<T> &v) { x+=v.x; y+=v.y; return *this; } //! subtraction const vector2<T> &operator -=(const vector2<T> &v) { x-=v.x; y-=v.y; return *this; } //! uniform scaling const vector2<T> &operator *=(const T num) { x*=num; y*=num; return *this; } //! uniform scaling const vector2<T> &operator /=(const T num) { x/=num; y/=num; return *this; } //! dot product T operator *(const vector2<T> &v) const { return x*v.x + y*v.y; } }; // macro to make creating the ctors for derived vectors easier #define VECTOR2_CTORS(name, type) \ /* trivial ctor */ \ name() {} \ /* down casting ctor */ \ name(const vector2<type> &v): vector2<type>(v.x, v.y) {} \ /* make x,y combination into a vector */ \ name(type x0, type y0): vector2<type>(x0, y0) {} struct vector2i: public vector2<int> { VECTOR2_CTORS(vector2i, int) }; struct vector2ui: public vector2<unsigned int> { VECTOR2_CTORS(vector2ui, unsigned int) }; struct vector2f: public vector2<float> { VECTOR2_CTORS(vector2f, float) //! gets the length of this vector squared float length_squared() const { return (float)(*this * *this); } //! gets the length of this vector float length() const { return (float)sqrt(*this * *this); } //! normalizes this vector void normalize() { *this/=length(); } //! returns the normalized vector vector2f normalized() const { return *this/length(); } //! reflects this vector about n void reflect(const vector2f &n) { vector2f orig(*this); project(n); *this= *this*2 - orig; } //! projects this vector onto v void project(const vector2f &v) { *this= v * (*this * v)/(v*v); } //! returns this vector projected onto v vector2f projected(const vector2f &v) { return v * (*this * v)/(v*v); } //! computes the angle between 2 arbitrary vectors static inline float angle(const vector2f &v1, const vector2f &v2) { return acosf((v1*v2) / (v1.length()*v2.length())); } //! computes the angle between 2 normalized arbitrary vectors static inline float angle_normalized(const vector2f &v1, const vector2f &v2) { return acosf(v1*v2); } };
[ "[email protected]@d29389ee-23ba-95cd-0add-1ea859d12ca3" ]
[ [ [ 1, 186 ] ] ]
81d3582074d0c06518c5e61f48bce5154e21fb2b
72449e9f77d221deddcc5371901c61303387ef09
/Layers/Renderer.cpp
3113fe51696ffe14ef228ea1ba8db7bc592cb925
[]
no_license
dsrbecky/PipeWars
a427f006292033f361260b0075929ade9b3f0c44
109a05e3db35f3725647d917a770332d8badeecc
refs/heads/master
2020-05-20T11:23:05.394233
2010-01-14T08:23:06
2010-01-14T16:00:25
958,353
2
0
null
null
null
null
UTF-8
C++
false
false
15,478
cpp
#include "StdAfx.h" #include "Layer.h" #include "../Entities.h" #include "../Maths.h" #include "../Resources.h" #include "../Util.h" extern Database db; extern Database serverDb; extern Player* localPlayer; extern Resources resources; extern float stat_netDatabaseUpdateSize; void (*onCameraSet)(IDirect3DDevice9* dev) = NULL; // Event for others const string PipeFilename = "pipe.dae"; class Renderer: Layer { IDirect3DVertexBuffer9* gridBuffer; float cameraYaw; float cameraPitch; float cameraDistance; int lastMouseX; int lastMouseY; static const int targetFPS = 30; float hiQualityPipes; int stat_objRendered; int stat_pipesRendered; public: Renderer(): gridBuffer(NULL), hiQualityPipes(0), cameraYaw(D3DX_PI / 4), cameraPitch(-D3DX_PI / 4 * 0.75f), cameraDistance(15), lastMouseX(0), lastMouseY(0) {} bool MouseProc(bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, int nMouseWheelDelta, int xPos, int yPos) { // Camera movement if (bMiddleButtonDown) { int deltaX = xPos - lastMouseX; int deltaY = yPos - lastMouseY; cameraPitch -= (float)deltaY / 200.0f; cameraYaw -= (float)deltaX / 200.0f; cameraPitch = max(-D3DX_PI/2, min(cameraPitch, D3DX_PI/2)); } if (nMouseWheelDelta != 0) { cameraDistance -= (float)nMouseWheelDelta / 120.0f * 3; cameraDistance = max(cameraDistance, 4); } lastMouseX = xPos; lastMouseY = yPos; return false; } void FrameMove(double fTime, float fElapsedTime) { float extraFPS = DXUTGetFPS() - targetFPS; if (extraFPS < 0) { hiQualityPipes += fElapsedTime * extraFPS * 0.5f; } else { hiQualityPipes += fElapsedTime * extraFPS * 0.05f; } hiQualityPipes = max(0, hiQualityPipes); } void SetupCamera(IDirect3DDevice9* dev) { float flux1 = 0; float flux2 = 0; if (localPlayer == NULL) { flux1 = cos((float)DXUTGetTime() / 4) * D3DX_PI * 0.01f; flux2 = sin((float)DXUTGetTime() / 3) * D3DX_PI * 0.01f; } D3DXMATRIXA16 matPitch; D3DXMatrixRotationX(&matPitch, cameraPitch + flux1); D3DXMATRIXA16 matYaw; D3DXMatrixRotationY(&matYaw, cameraYaw + flux2); D3DXMATRIXA16 matYawPitch; D3DXMatrixMultiply(&matYawPitch, &matYaw, &matPitch); D3DXMATRIXA16 matZoom; if (localPlayer == NULL) { D3DXMatrixTranslation(&matZoom, 0, 0, 20); } else { D3DXMatrixTranslation(&matZoom, 0, 0, cameraDistance); } D3DXMATRIXA16 matView; D3DXMatrixMultiply(&matView, &matYawPitch, &matZoom); D3DXMATRIXA16 matMove; if (localPlayer == NULL) { D3DXMatrixTranslation(&matMove, 0, -2, -7); } else { D3DXMatrixTranslation(&matMove, -localPlayer->position.x, -localPlayer->position.y, -localPlayer->position.z); } D3DXMATRIXA16 matMoveView; D3DXMatrixMultiply(&matMoveView, &matMove, &matView); dev->SetTransform(D3DTS_VIEW, &matMoveView); // Prespective D3DXMATRIXA16 matProj; D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI / 4, (float)DXUTGetWindowWidth() / DXUTGetWindowHeight(), NearClip, FarClip); dev->SetTransform(D3DTS_PROJECTION, &matProj); if (onCameraSet != NULL) { onCameraSet(dev); } } void SetupLight(IDirect3DDevice9* dev) { dev->SetRenderState(D3DRS_LIGHTING, true); dev->SetRenderState(D3DRS_AMBIENT, 0); dev->SetRenderState(D3DRS_SPECULARENABLE, !keyToggled_Alt['S']); dev->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL); dev->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL); dev->SetRenderState(D3DRS_ALPHABLENDENABLE, false); D3DLIGHT9 light; ZeroMemory(&light, sizeof(light)); light.Type = D3DLIGHT_DIRECTIONAL; light.Direction.x = -100.0f; light.Direction.y = -500.0f; light.Direction.z = 0.0f; D3DCOLORVALUE ambi = {0.3f, 0.3f, 0.3f, 1.0f}; D3DCOLORVALUE diff = {1.0f, 1.0f, 1.0f, 1.0f}; D3DCOLORVALUE spec = {0.3f, 0.3f, 0.1f, 1.0f}; if (!keyToggled_Alt['A']) light.Ambient = ambi; if (!keyToggled_Alt['D']) light.Diffuse = diff; if (!keyToggled_Alt['S']) light.Specular = spec; // Don't attenuate. light.Attenuation0 = 1.0f; light.Range = 10000.0f; dev->SetLight(0, &light); dev->LightEnable(0, true); } void Render(IDirect3DDevice9* dev) { dev->SetRenderState(D3DRS_FILLMODE, keyToggled_Alt['W'] ? D3DFILL_WIREFRAME : D3DFILL_SOLID); dev->SetRenderState(D3DRS_ZENABLE, !keyToggled_Alt['Z']); SetupCamera(dev); SetupLight(dev); stat_objRendered = 0; stat_pipesRendered = 0; if (keyToggled_Alt['E']) { if (!keyToggled_Alt['F']) RenderFrameStats(dev); return; } // Get the camera settings D3DVIEWPORT9 viewport; D3DXMATRIX matProj; D3DXMATRIX matView; dev->GetViewport(&viewport); dev->GetTransform(D3DTS_PROJECTION, &matProj); dev->GetTransform(D3DTS_VIEW, &matView); // Find and mark pipes to be rendered in hi-quality // (the closeset ones to the player) multiset<pair<float, MeshEntity*>> pipes; { DbLoop_Meshes(db, it) if (entity->getMesh()->isPipeOrTank) { D3DXVECTOR3 playerPos(0, 0, 0); if (localPlayer != NULL) playerPos = localPlayer->position; D3DXVECTOR3 entityPos = entity->ToWorldCoordinates(entity->getMesh()->boundingBox.centre); D3DXVECTOR3 delta = entityPos - playerPos; float distance = D3DXVec3LengthSq(&delta); pipes.insert(pair<float, MeshEntity*>(distance, entity)); entity->hiQuality = false; // Defualt } } multiset<pair<float, MeshEntity*>>::iterator it = pipes.begin(); for(int i = 0; i < (int)hiQualityPipes && it != pipes.end(); i++) { it->second->hiQuality = true; it++; } // Render meshes { DbLoop_Meshes(db, it) Mesh* mesh = entity->getMesh(); // Render only the level the player is in if (localPlayer != NULL && !keyToggled_Alt['L']) { float relY = entity->position.y - localPlayer->position.y; // Upper level if (relY > 1.75) continue; // Do not show at all // Lower level float minY; if (mesh->boundingBox.maxCorner.y >= 2.7) // The level up piece minY = -2.25; else minY = -0.25; entity->showOutside = relY < minY; entity->showInside = relY > minY - 2; } else { entity->showOutside = false; entity->showInside = true; } // Is it hidden powerup? PowerUp* powerUp = dynamic_cast<PowerUp*>(entity); if (powerUp != NULL && !powerUp->present) continue; // Set the WORLD for the this entity D3DXMATRIXA16 matWorld; D3DXMatrixIdentity(&matWorld); D3DXMATRIXA16 matScale; D3DXMatrixScaling(&matScale, entity->scale, entity->scale, entity->scale); D3DXMatrixMultiply(&matWorld, &matWorld, &matScale); D3DXMATRIXA16 matRot; D3DXMatrixRotationY(&matRot, -(entity->rotY + entity->rotY_multiplyByTime * (float)DXUTGetTime()) / 360 * 2 * D3DX_PI); D3DXMatrixMultiply(&matWorld, &matWorld, &matRot); D3DXMATRIXA16 matTrans; D3DXMatrixTranslation(&matTrans, entity->position.x, entity->position.y, entity->position.z); D3DXMatrixMultiply(&matWorld, &matWorld, &matTrans); dev->SetTransform(D3DTS_WORLD, &matWorld); // Clip using frustum if (!keyToggled_Alt['C']) { // Corners of the screen float w = (float)viewport.Width; float h = (float)viewport.Height; D3DXVECTOR3 screen[8] = { D3DXVECTOR3(0, 0, 0), D3DXVECTOR3(w, 0, 0), D3DXVECTOR3(w, h, 0), D3DXVECTOR3(0, h, 0), D3DXVECTOR3(0, 0, 1), D3DXVECTOR3(w, 0, 1), D3DXVECTOR3(w, h, 1), D3DXVECTOR3(0, h, 1) }; // Vertecies of the frustum D3DXVECTOR3 model[8]; D3DXVec3UnprojectArray( model, sizeof(D3DXVECTOR3), screen, sizeof(D3DXVECTOR3), &viewport, &matProj, &matView, &matWorld, 8 ); // Normals to the frustrum sides (pointing inside) D3DXVECTOR3 nTop = GetFrustumNormal(model[0], model[1], model[4]); D3DXVECTOR3 nRight = GetFrustumNormal(model[1], model[2], model[5]); D3DXVECTOR3 nBottom = GetFrustumNormal(model[2], model[3], model[6]); D3DXVECTOR3 nLeft = GetFrustumNormal(model[3], model[0], model[7]); D3DXVECTOR3 nNear = GetFrustumNormal(model[0], model[3], model[1]); D3DXVECTOR3 ns[] = {nTop, nRight, nBottom, nLeft, nNear}; D3DXVECTOR3 nPs[] = {model[0], model[1], model[2], model[3], model[0]}; // Test against the sides bool outsideFrustum; for(int i = 0; i < (sizeof(ns) / sizeof(D3DXVECTOR3)); i++) { D3DXVECTOR3 n = ns[i]; // Normal D3DXVECTOR3 nP = nPs[i]; // Point on the side outsideFrustum = true; for(int j = 0; j < 8; j++) { D3DXVECTOR3 bbCorner = mesh->boundingBox.corners[j]; D3DXVECTOR3 bbCornerRelativeToP = bbCorner - nP; bool isIn = D3DXVec3Dot(&n, &bbCornerRelativeToP) > 0; if (isIn) { outsideFrustum = false; break; // Fail, try next side } } if (outsideFrustum) break; // Done } if (outsideFrustum) continue; // Skip entity } // Debug frustrum D3DXMATRIXA16 oldView; dev->GetTransform(D3DTS_VIEW, &oldView); if (keyToggled_Alt['V']) { D3DXMATRIXA16 newMove; D3DXMatrixTranslation(&newMove, 0, 0, 25); D3DXMATRIXA16 newView; D3DXMatrixMultiply(&newView, &oldView, &newMove); dev->SetTransform(D3DTS_VIEW, &newView); } D3DCOLOR on = 0xFFFFFFFF; D3DCOLOR off = 0; if (mesh->isPipeOrTank) { if (entity->showInside) { mesh->SetMaterialColor("-Low", entity->hiQuality ? off : on); mesh->SetMaterialColor("-Hi", entity->hiQuality ? on : off); mesh->SetMaterialColor("InnerWall", on); } else { mesh->SetMaterialColor("*", off); } mesh->SetMaterialColor("Path", keyToggled_Alt['P'] ? (DWORD)0xFFF800000 : off); mesh->SetMaterialColor("OuterWall", entity->showOutside ? on : off); } if (entity->GetType() == Player::Type) { mesh->SetMaterialColor("Armour", ((Player*)entity)->colorArmour); mesh->SetMaterialColor("ArmourDetail", ((Player*)entity)->colorArmoutDetail); } mesh->Render(dev); entity->hiQuality = false; // Reset stat_objRendered++; if (mesh->isPipeOrTank) stat_pipesRendered++; if (keyToggled_Alt['B']) { RenderBoundingBox(dev, mesh->boundingBox); } dev->SetTransform(D3DTS_VIEW, &oldView); } // Render player names if (!keyToggled_Alt['N']) RenderPlayerNames(dev, matProj, matView); hiQualityPipes = min(hiQualityPipes, stat_pipesRendered + 4); // Do not outgrow by more then 4 if (keyToggled_Alt['G']) RenderGrid(dev); if (!keyToggled_Alt['F']) RenderFrameStats(dev); } void RenderPlayerNames(IDirect3DDevice9* dev, D3DXMATRIX& matProj, D3DXMATRIX& matView) { dev->SetRenderState(D3DRS_ZENABLE, false); { DbLoop_Players(db, it) if (player != localPlayer) { D3DVIEWPORT9 unitViewport = {0, 0, 100, 100, 0, 1}; D3DXVECTOR3 worldPos = player->position; worldPos.y += 0.6f; D3DXVECTOR3 screenPos; D3DXMATRIXA16 matWorld; D3DXMatrixIdentity(&matWorld); D3DXVec3Project(&screenPos, &worldPos, &unitViewport, &matProj, &matView, &matWorld); // Clip the point to screen corners if it is behind you screenPos.x = (screenPos.x / 50) - 1; screenPos.y = (screenPos.y / 50) - 1; if (screenPos.z > unitViewport.MaxZ) { screenPos.y /= abs(screenPos.x) + (float)Epsilon; screenPos.x = screenPos.x > 0 ? 1.0f : -1.0f; if (screenPos.y < -1 || screenPos.y > 1) { screenPos.x /= abs(screenPos.y); screenPos.y = screenPos.y > 0 ? 1.0f : -1.0f; } screenPos.x *= -1; screenPos.y *= -1; } screenPos.x = (screenPos.x + 1) / 2 * DXUTGetWindowWidth(); screenPos.y = (screenPos.y + 1) / 2 * DXUTGetWindowHeight(); RECT textSize = {0, 0, 0, 0}; resources.LoadFont(dev)->DrawTextA(NULL, player->name, -1, &textSize, DT_NOCLIP | DT_SINGLELINE | DT_CALCRECT, player->colorArmoutDetail); RECT rect = {(int)screenPos.x - textSize.right / 2, (int)screenPos.y - textSize.bottom, 0, 0}; rect.left = max(4, min(DXUTGetWindowWidth() - textSize.right - 4, rect.left)); rect.top = max(keyToggled_Alt['F'] ? 4 : 24, min(DXUTGetWindowHeight() - textSize.bottom - 64 - 4, rect.top)); resources.LoadFont(dev)->DrawTextA(NULL, player->name, -1, &rect, DT_NOCLIP | DT_SINGLELINE, player->colorArmoutDetail); } } } void RenderBoundingBox(IDirect3DDevice9* dev, BoundingBox& bb) { vector<D3DXVECTOR3> ver; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { if (i < j) { D3DXVECTOR3 v1 = bb.corners[i]; D3DXVECTOR3 v2 = bb.corners[j]; int same = 0; if (v1.x == v2.x) same++; if (v1.y == v2.y) same++; if (v1.z == v2.z) same++; if (same == 2) { // Line from i to j ver.push_back(v1); ver.push_back(v2); } } } } dev->DrawPrimitiveUP(D3DPT_LINELIST, ver.size() / 2, &(ver[0]), sizeof(D3DXVECTOR3)); } static const int gridSize = 25; void RenderGrid(IDirect3DDevice9* dev) { int fvf = D3DFVF_XYZ; static int lineCount; // Create buffer on demand if (gridBuffer == NULL) { vector<float> vb; for(int i = -gridSize; i <= gridSize; i++) { // Along X vb.push_back((float)-gridSize); vb.push_back(0); vb.push_back((float)i); vb.push_back((float)+gridSize); vb.push_back(0); vb.push_back((float)i); lineCount++; /// Along Z vb.push_back((float)i); vb.push_back(0); vb.push_back((float)-gridSize); vb.push_back((float)i); vb.push_back(0); vb.push_back((float)+gridSize); lineCount++; } // Copy the buffer to graphic card memory dev->CreateVertexBuffer(vb.size() * sizeof(float), 0, fvf, D3DPOOL_DEFAULT, &gridBuffer, NULL); void* bufferData; gridBuffer->Lock(0, vb.size() * sizeof(float), &bufferData, 0); copy(vb.begin(), vb.end(), (float*)bufferData); gridBuffer->Unlock(); } D3DMATERIAL9 material; ZeroMemory(&material, sizeof(material)); material.Emissive.a = 1; material.Emissive.r = 0.5; D3DXMATRIXA16 matWorld; D3DXMatrixIdentity(&matWorld); dev->SetTransform(D3DTS_WORLD, &matWorld); dev->SetStreamSource(0, gridBuffer, 0, 3 * sizeof(float)); dev->SetFVF(fvf); dev->SetTexture(0, NULL); dev->SetMaterial(&material); dev->DrawPrimitive(D3DPT_LINELIST, 0, lineCount); } void RenderFrameStats(IDirect3DDevice9* dev) { ostringstream msg; msg << fixed << std::setprecision(1); msg << "FPS = " << DXUTGetFPS() << " (target = " << targetFPS << ")" << " "; msg << "Objects = " << stat_objRendered << " (hq = " << (int)hiQualityPipes << ")" << " "; if (localPlayer != NULL) { msg << "Net-in = " << stat_netDatabaseUpdateSize / DXUTGetElapsedTime() / 1000 << " kb/s" << " "; msg << "Pos = " << localPlayer->position.x << ","<< localPlayer->position.y << "," << localPlayer->position.z << " "; // msg << "Rot = " << localPlayer->rotY << " ("<< localPlayer->rotY_velocity << ")" << " "; } msg << "Press H for help or ESC to exit."; textX = 8; textY = 8; RenderText(dev, msg.str()); } void ReleaseDeviceResources() { if (gridBuffer != NULL) { gridBuffer->Release(); gridBuffer = NULL; } } }; Renderer renderer;
[ [ [ 1, 478 ] ] ]
80fca44b8c852ecb1107bf19a8ae52ae6fcccd31
2bf221bc84477471c79e47bdb758776176202e0a
/plc/cewki.cpp
daacb15da9b73dbae36817d800bf273e107a3fb9
[]
no_license
uraharasa/plc-programming-simulator
9613522711f6f9b477c5017e7e1dd0237316a3f4
a03e068db8b9fdee83ae4db8fe3666f0396000ef
refs/heads/master
2016-09-06T12:01:02.666354
2011-08-14T08:36:49
2011-08-14T08:36:49
34,528,882
0
1
null
null
null
null
UTF-8
C++
false
false
9,510
cpp
#include "cewki.h" #include "okno_glowne.h" cewka::cewka(void) { adres_bazowy = new pamiec(L"", MOZNA_Q|MOZNA_R|MOZNA_M|MOZNA_AQ); } cewka::cewka(FILE * plik): element_zwykly(plik) { } void cewka::podaj_rozmiar(int & szerokosc, int & wysokosc, int tryb) { szerokosc = wysokosc = 1; } cewka_zwierna::cewka_zwierna(void) { nazwa = L"cewka_zwierna"; } cewka_zwierna::cewka_zwierna(FILE * plik): cewka(plik) { nazwa = L"cewka_zwierna"; } element * cewka_zwierna::sklonuj(FILE * plik) { if (plik) return new cewka_zwierna(plik); else return new cewka_zwierna; } int cewka_zwierna::dzialaj(int wejscie) { adres_bazowy->zapisz_pamiec(wejscie); return wejscie; } void cewka_zwierna::narysuj(HDC kontekst, int tryb, int x, int y) { int x_pocz = akt_program_LD->mapuj_x(x); int y_pocz = akt_program_LD->mapuj_y(y); MoveToEx(kontekst, x_pocz, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA); MoveToEx(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+60, y_pocz+Y_WYJSCIA); if (tryb&RYSUJ_ADRES) adres_bazowy->narysuj_adres(kontekst, x_pocz+30, y_pocz, TA_CENTER|TA_TOP|TA_NOUPDATECP); } cewka_rozwierna::cewka_rozwierna(void) { nazwa = L"cewka_rozwierna"; } cewka_rozwierna::cewka_rozwierna(FILE * plik): cewka(plik) { nazwa = L"cewka_rozwierna"; } element * cewka_rozwierna::sklonuj(FILE * plik) { if (plik) return new cewka_rozwierna(plik); else return new cewka_rozwierna; } int cewka_rozwierna::dzialaj(int wejscie) { adres_bazowy->zapisz_pamiec(!wejscie); return wejscie; } void cewka_rozwierna::narysuj(HDC kontekst, int tryb, int x, int y) { int x_pocz = akt_program_LD->mapuj_x(x); int y_pocz = akt_program_LD->mapuj_y(y); MoveToEx(kontekst, x_pocz, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA); MoveToEx(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA+10); LineTo(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA-10); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+60, y_pocz+Y_WYJSCIA); if (tryb&RYSUJ_ADRES) adres_bazowy->narysuj_adres(kontekst, x_pocz+30, y_pocz, TA_CENTER|TA_TOP|TA_NOUPDATECP); } cewka_zbocze_narastajace::cewka_zbocze_narastajace(void) { nazwa = L"cewka_zbocze_narastajace"; stan_poprzedni = 0; } cewka_zbocze_narastajace::cewka_zbocze_narastajace(FILE * plik): cewka(plik) { nazwa = L"cewka_zbocze_narastajace"; stan_poprzedni = 0; } element * cewka_zbocze_narastajace::sklonuj(FILE * plik) { if (plik) return new cewka_zbocze_narastajace(plik); else return new cewka_zbocze_narastajace; } int cewka_zbocze_narastajace::dzialaj(int wejscie) { if ((wejscie)&&(!stan_poprzedni)) adres_bazowy->zapisz_pamiec(1); else adres_bazowy->zapisz_pamiec(0); stan_poprzedni = wejscie; return wejscie; } void cewka_zbocze_narastajace::narysuj(HDC kontekst, int tryb, int x, int y) { int x_pocz = akt_program_LD->mapuj_x(x); int y_pocz = akt_program_LD->mapuj_y(y); MoveToEx(kontekst, x_pocz, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA); MoveToEx(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+30, y_pocz+Y_WYJSCIA+10, NULL); LineTo(kontekst, x_pocz+30, y_pocz+Y_WYJSCIA-10); MoveToEx(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+30, y_pocz+Y_WYJSCIA-10); LineTo(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA); MoveToEx(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+60, y_pocz+Y_WYJSCIA); if (tryb&RYSUJ_ADRES) adres_bazowy->narysuj_adres(kontekst, x_pocz+30, y_pocz, TA_CENTER|TA_TOP|TA_NOUPDATECP); } cewka_zbocze_opadajace::cewka_zbocze_opadajace(void) { nazwa = L"cewka_zbocze_opadajace"; stan_poprzedni = 0; } cewka_zbocze_opadajace::cewka_zbocze_opadajace(FILE * plik): cewka(plik) { nazwa = L"cewka_zbocze_opadajace"; stan_poprzedni = 0; } element * cewka_zbocze_opadajace::sklonuj(FILE * plik) { if (plik) return new cewka_zbocze_opadajace(plik); else return new cewka_zbocze_opadajace; } int cewka_zbocze_opadajace::dzialaj(int wejscie) { if ((!wejscie)&&(stan_poprzedni)) adres_bazowy->zapisz_pamiec(1); else adres_bazowy->zapisz_pamiec(0); stan_poprzedni = wejscie; return wejscie; } void cewka_zbocze_opadajace::narysuj(HDC kontekst, int tryb, int x, int y) { int x_pocz = akt_program_LD->mapuj_x(x); int y_pocz = akt_program_LD->mapuj_y(y); MoveToEx(kontekst, x_pocz, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA); MoveToEx(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+30, y_pocz+Y_WYJSCIA+10, NULL); LineTo(kontekst, x_pocz+30, y_pocz+Y_WYJSCIA-10); MoveToEx(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+30, y_pocz+Y_WYJSCIA+10); LineTo(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA); MoveToEx(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+60, y_pocz+Y_WYJSCIA); if (tryb&RYSUJ_ADRES) adres_bazowy->narysuj_adres(kontekst, x_pocz+30, y_pocz, TA_CENTER|TA_TOP|TA_NOUPDATECP); } cewka_S::cewka_S(void) { nazwa = L"cewka_S"; } cewka_S::cewka_S(FILE * plik): cewka(plik) { nazwa = L"cewka_S"; } element * cewka_S::sklonuj(FILE * plik) { if (plik) return new cewka_S(plik); else return new cewka_S; } int cewka_S::dzialaj(int wejscie) { if (wejscie) adres_bazowy->zapisz_pamiec(1); return wejscie; } void cewka_S::narysuj(HDC kontekst, int tryb, int x, int y) { int x_pocz = akt_program_LD->mapuj_x(x); int y_pocz = akt_program_LD->mapuj_y(y); MoveToEx(kontekst, x_pocz, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA); MoveToEx(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+60, y_pocz+Y_WYJSCIA); if (tryb&RYSUJ_NAZWE) { SetTextAlign(kontekst, TA_TOP|TA_CENTER|TA_NOUPDATECP); TextOut(kontekst, x_pocz+30, y_pocz+Y_WYJSCIA-7, L"S", 1); } if (tryb&RYSUJ_ADRES) adres_bazowy->narysuj_adres(kontekst, x_pocz+30, y_pocz, TA_CENTER|TA_TOP|TA_NOUPDATECP); } cewka_R::cewka_R(void) { nazwa = L"cewka_R"; } cewka_R::cewka_R(FILE * plik): cewka(plik) { nazwa = L"cewka_R"; } element * cewka_R::sklonuj(FILE * plik) { if (plik) return new cewka_R(plik); else return new cewka_R; } int cewka_R::dzialaj(int wejscie) { if (wejscie) adres_bazowy->zapisz_pamiec(0); return wejscie; } void cewka_R::narysuj(HDC kontekst, int tryb, int x, int y) { int x_pocz = akt_program_LD->mapuj_x(x); int y_pocz = akt_program_LD->mapuj_y(y); MoveToEx(kontekst, x_pocz, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA); MoveToEx(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+20, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+25, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA-10, NULL); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA-5); LineTo(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA+5); LineTo(kontekst, x_pocz+35, y_pocz+Y_WYJSCIA+10); MoveToEx(kontekst, x_pocz+40, y_pocz+Y_WYJSCIA, NULL); LineTo(kontekst, x_pocz+60, y_pocz+Y_WYJSCIA); if (tryb&RYSUJ_NAZWE) { SetTextAlign(kontekst, TA_TOP|TA_CENTER|TA_NOUPDATECP); TextOut(kontekst, x_pocz+30, y_pocz+Y_WYJSCIA-7, L"R", 1); } if (tryb&RYSUJ_ADRES) adres_bazowy->narysuj_adres(kontekst, x_pocz+30, y_pocz, TA_CENTER|TA_TOP|TA_NOUPDATECP); }
[ "[email protected]@2c618d7f-f323-8192-d80b-44f770db81a5" ]
[ [ [ 1, 315 ] ] ]
f00184ff8bfaf09be217efcfeb329fea5b98ce80
c1c3866586c56ec921cd8c9a690e88ac471adfc8
/Practise_2005/FormatV_Test/FormatV_Test.cpp
d22f0c35c6e025cc5b39d688d97bd70e5eb0e33f
[]
no_license
rtmpnewbie/lai3d
0802dbb5ebe67be2b28d9e8a4d1cc83b4f36b14f
b44c9edfb81fde2b40e180a651793fec7d0e617d
refs/heads/master
2021-01-10T04:29:07.463289
2011-03-22T17:51:24
2011-03-22T17:51:24
36,842,700
1
0
null
null
null
null
GB18030
C++
false
false
1,068
cpp
// FormatV_Test.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "FormatV_Test.h" #include <string.h> #include <atlsimpstr.h> #include <atlstr.h> #ifdef _DEBUG #define new DEBUG_NEW #endif void WriteString(LPCWSTR pstrFormat, ...) { CString str; // format and write the data you were given va_list args; va_start(args, pstrFormat); str.FormatV(pstrFormat, args); va_end(args); ::wprintf_s(str.GetString()); return; } // 唯一的应用程序对象 CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; // 初始化 MFC 并在失败时显示错误 if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: 更改错误代码以符合您的需要 _tprintf(_T("错误: MFC 初始化失败\n")); nRetCode = 1; } else { // TODO: 在此处为应用程序的行为编写代码。 WriteString( _T("%d error(s) found in %d line(s)"), 10, 1351 ); } return nRetCode; }
[ "laiyanlin@27d9c402-1b7e-11de-9433-ad2e3fad96c5" ]
[ [ [ 1, 57 ] ] ]
690c1f468d198b03d254c70cc31087450f110f8f
25426133cf6405c5cebf4b51c48ff3dce2629ea9
/engine/object.h
2e826588cb97813da92b1121fd6a55a0ecfd470a
[]
no_license
tolhc1234/openglengine
456fd5a099b30544af1e338fab289402d2b81341
6ed525f9a74235605157e68728e36b8b5291b096
refs/heads/master
2021-01-10T02:38:58.457222
2010-01-12T20:28:21
2010-01-12T20:28:21
50,214,430
0
0
null
null
null
null
UTF-8
C++
false
false
223
h
#ifndef OBJECT_H #define OBJECT_H class object{ public: //3dModel model int posX, posY, posZ; int directionX, directionY, directionZ;//the object is moving(flying?) this direction int viewX, viewY, viewZ; }; #endif
[ [ [ 1, 10 ] ] ]
942942f30e970f5f0852c46948a2c1048290bace
1cc5720e245ca0d8083b0f12806a5c8b13b5cf98
/archive/ok/2432/c.cpp
f1a6cded0756e1266fd84bb83f4aad1457afaad2
[]
no_license
Emerson21/uva-problems
399d82d93b563e3018921eaff12ca545415fd782
3079bdd1cd17087cf54b08c60e2d52dbd0118556
refs/heads/master
2021-01-18T09:12:23.069387
2010-12-15T00:38:34
2010-12-15T00:38:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,253
cpp
#include <iostream> using namespace std; int pais[200][200]; int filhos[200]; int im[200]; #define FOR(a,b) for(a=0;a<b;a++) void st() { int n,m,i,j,k; cin >> n >> m; FOR(i,n) { FOR(j,n) pais[i][j] = 0; filhos[i] = 0; im[i] = 0; } while(m--) { cin >> i >> j; i--; filhos[i] = j; while(j--) { cin >> k; k--; pais[k][i] = 1; } } int imp = 0; while(imp!=n) { FOR(i,n) { if(im[i]==0 && filhos[i]==0) { im[i] = 1; if(imp!=0) cout << " "; cout << (i+1); FOR(j,n) { if(pais[i][j]) filhos[j]--; } imp++; break; } } } cout << endl; } int main() { int t; cin >> t; while(t--) st(); return 0; }
[ [ [ 1, 55 ] ] ]
c17b821b1eaace7785af582f081b3b43e583b096
b2d46af9c6152323ce240374afc998c1574db71f
/cursovideojuegos/theflostiproject/3rdParty/boost/libs/config/test/has_winthreads_fail.cpp
d744456378ab2cb892a681697461e3cce556932c
[]
no_license
bugbit/cipsaoscar
601b4da0f0a647e71717ed35ee5c2f2d63c8a0f4
52aa8b4b67d48f59e46cb43527480f8b3552e96d
refs/heads/master
2021-01-10T21:31:18.653163
2011-09-28T16:39:12
2011-09-28T16:39:12
33,032,640
0
0
null
null
null
null
UTF-8
C++
false
false
1,173
cpp
// This file was automatically generated on Sun Jul 25 11:47:49 GMTDT 2004, // by libs/config/tools/generate // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/libs/config for the most recent version. // Test file for macro BOOST_HAS_WINTHREADS // This file should not compile, if it does then // BOOST_HAS_WINTHREADS may be defined. // see boost_has_winthreads.ipp for more details // Do not edit this file, it was generated automatically by // ../tools/generate from boost_has_winthreads.ipp on // Sun Jul 25 11:47:49 GMTDT 2004 // Must not have BOOST_ASSERT_CONFIG set; it defeats // the objective of this file: #ifdef BOOST_ASSERT_CONFIG # undef BOOST_ASSERT_CONFIG #endif #include <boost/config.hpp> #include "test.hpp" #ifndef BOOST_HAS_WINTHREADS #include "boost_has_winthreads.ipp" #else #error "this file should not compile" #endif int main( int, char *[] ) { return boost_has_winthreads::test(); }
[ "ohernandezba@71d53fa2-cca5-e1f2-4b5e-677cbd06613a" ]
[ [ [ 1, 39 ] ] ]
ee1cd39179b159495f05959e31705da71169577c
a928a4c1b78aac448d66a1b5c3f450fc62a03c42
/src/ofxTLKeyframer.h
b68d9ce43e06465dc99aef2c7c577265b41fc999
[]
no_license
cwhitney/ofxTimeline
c4892904b645c2676d36d6650fc6aab37efe1854
368a13d765ea077df0c803beea64072a8ad486e4
refs/heads/master
2020-12-25T13:12:56.173136
2011-08-19T23:09:39
2011-08-19T23:09:39
2,236,481
0
0
null
null
null
null
UTF-8
C++
false
false
2,175
h
/* * THISKeyframeEditor.h * THIS_Editor * * Created by Jim on 6/26/11. * Copyright 2011 FlightPhase. All rights reserved. * */ #pragma once #include "ofMain.h" #include "ofRange.h" #include "ofxTween.h" #include "ofxTLElement.h" typedef struct { int id; ofRectangle bounds; string name; ofxEasing* easing; } EasingFunction; typedef struct { int id; ofRectangle bounds; string name; ofxTween::ofxEasingType type; } EasingType; typedef struct { EasingFunction* easeFunc; EasingType* easeType; ofVec2f position; // x is value, y is time, all 0 - 1.0 } ofxTLKeyframe; class ofxTLKeyframer : public ofxTLElement { public: ofxTLKeyframer(); ~ofxTLKeyframer(); virtual void setup(); virtual void draw(); //main function to get values out of the timeline virtual float sampleTimelineAt(float percent); virtual void mousePressed(ofMouseEventArgs& args); virtual void mouseMoved(ofMouseEventArgs& args); virtual void mouseDragged(ofMouseEventArgs& args); virtual void mouseReleased(ofMouseEventArgs& args); virtual void keyPressed(ofKeyEventArgs& args); virtual void save(); virtual void load(); virtual void reset(); virtual void clear(); private: ofxTLKeyframe* firstkey; ofxTLKeyframe* lastkey; ofVec2f grabOffset; vector<ofxTLKeyframe*> keyframes; bool keyframeIsInBounds(ofxTLKeyframe* key); ofxTLKeyframe* selectedKeyframe; int selectedKeyframeIndex; ofVec2f keyframeGrabOffset; float minBound; //TODO: replace with range float maxBound; void updateKeyframeSort(); ofxTLKeyframe* keyframeAtScreenpoint(ofVec2f p, int& selectedIndex); bool screenpointIsInBounds(ofVec2f screenpoint); ofVec2f coordForKeyframePoint(ofVec2f keyframePoint); ofVec2f keyframePointForCoord(ofVec2f coord); //easing dialog stuff ofVec2f easingWindowPosition; bool drawingEasingWindow; vector<EasingFunction*> easingFunctions; vector<EasingType*> easingTypes; float easingBoxWidth; float easingBoxHeight; float easingWindowSeperatorHeight; void initializeEasings(); ofxTLKeyframe* newKeyframe(ofVec2f point); };
[ [ [ 1, 97 ] ] ]
5a1f05286178fc7924f2a1c8b10db8ac1cef1ebe
847cccd728e768dc801d541a2d1169ef562311cd
/src/Utils/test/TestArray.cpp
c6b58e6958fa0d620bf8b587326140e1709a1cb9
[]
no_license
aadarshasubedi/Ocerus
1bea105de9c78b741f3de445601f7dee07987b96
4920b99a89f52f991125c9ecfa7353925ea9603c
refs/heads/master
2021-01-17T17:50:00.472657
2011-03-25T13:26:12
2011-03-25T13:26:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,104
cpp
#include "Common.h" #include "UnitTests.h" #include "../Array.h" SUITE(Array) { TEST(ConstructorAndDestructor) { Array<int32>* testArray = new Array<int32>(1024); { Array<int32> testArray(1024); } // the destructor is called here delete testArray; } TEST(ReadAndWriteBracketOperators) { Array<int32>* testArray = new Array<int32>(1024); for (int32 i=0; i<1024; ++i) (*testArray)[i] = 0; (*testArray)[0] = (*testArray)[1023] = (*testArray)[10] = 123456; CHECK_EQUAL((*testArray)[0], 123456); CHECK_EQUAL((*testArray)[10], 123456); CHECK_EQUAL((*testArray)[1023], 123456); const Array<int32>* testConstArray = testArray; CHECK_EQUAL((*testConstArray)[0], 123456); CHECK_EQUAL((*testConstArray)[10], 123456); CHECK_EQUAL((*testConstArray)[1023], 123456); } TEST(ArrayOfPointers) { Array<int32*> testArray(16); for (int32 i=0; i<16; ++i) testArray[i] = new int32(i); for (int32 i=0; i<16; ++i) CHECK_EQUAL(*testArray[i], i); for (int32 i=0; i<16; ++i) delete testArray[i]; } TEST(RawArrayPointer) { Array<int32> testArray(16); int32* rawArray = testArray.GetRawArrayPtr(); for (int32 i=0; i<16; ++i) rawArray[i] = i; for (int32 i=0; i<16; ++i) CHECK_EQUAL(rawArray[i], i); } TEST(Clear) { Array<int32> testArray(16); for (int32 i=0; i<testArray.GetSize(); ++i) testArray[i] = i; testArray.Clear(); CHECK_EQUAL(testArray.GetSize(), 0); } TEST(Resize) { Array<int32> testArray(16); for (int32 i=0; i<testArray.GetSize(); ++i) testArray[i] = i; testArray.Resize(10); for (int32 i=0; i<testArray.GetSize(); ++i) CHECK_EQUAL(testArray[i], i); testArray.Resize(16); for (int32 i=0; i<10; ++i) CHECK_EQUAL(testArray[i], i); } TEST(CopyFrom) { Array<int32> firstArray(16); for (int32 i=0; i<firstArray.GetSize(); ++i) firstArray[i] = i; Array<int32> secondArray; secondArray.CopyFrom(firstArray); for (int32 i=0; i<secondArray.GetSize(); ++i) CHECK_EQUAL(secondArray[i], i); } }
[ [ [ 1, 90 ] ] ]
4d8b10529c7bc36632a5bc08e4360cdcab158e21
37c11de5fa036e89b5cd742f1ea688290038e322
/State.cc
1b94215c6b4c63b33c5e433808aa279ecd385059
[ "Apache-2.0" ]
permissive
patches11/aichallenge_ant
3c7eef9603782ae45ecfcdf92573c8b0d974c03d
6909b38cc2e9287990ef6ec279b1cccce375af91
refs/heads/master
2020-04-01T18:43:50.469456
2011-11-11T19:17:10
2011-11-11T19:17:10
29,498,473
0
0
null
null
null
null
UTF-8
C++
false
false
40,758
cc
#include "State.h" using namespace std; //constructor State::State() { gameover = 0; turn = 0; bug.open("./debug.txt"); hasUnexplored = true; }; //deconstructor State::~State() { bug.close(); }; void State::setAttackDistanceBuffer(int b) { attackDistanceBuffer = b; } void State::setSearchStepLimit(int l) { searchStepLimit = l; } void State::setMinExploreDistanceFromHill(int m) { minExploreDistanceFromHill = m; } void State::setExpLamda(double l) { expLamda = l; } void State::setTurnsTillNotAtRisk(int t) { turnsTillNotAtRisk = t; } void State::setMaxDefendingAnts(int a) { maxDefendingAnts = a; } void State::setUseExponentialExploring(bool e) { useExponentialExploring = e; } //sets the state up void State::setup() { grid = vector<vector<Square> >(rows, vector<Square>(cols, Square())); gridNextTurn = vector<vector<Square> >(rows, vector<Square>(cols, Square())); }; bool State::outOfTime(double marginOfError) { return (timer.getTime() >= (turntime - marginOfError)); } Location State::randomLocation(Location origin, int min, int distance) { if (useExponentialExploring) return randomLocationExp(origin, min, distance); else return randomLocationUni(origin, min, distance); } Location State::randomLocationUni(Location origin, int min, int distance) { int row = (origin.row + randomWithNeg(min, distance) + rows) % rows; int col = (origin.col + randomWithNeg(min, distance) + cols) % cols; if (row < 0) row = -row; if (col < 0) col = -col; Location loc = Location(row, col); if (passable(loc) && xAwayFromMyHill(minExploreDistanceFromHill,loc)) return loc; return randomLocationUni(origin, min, distance); } Location State::randomLocationExp(Location origin, int min, int distance) { int row = (origin.row + randomWithNegExp(min, distance) + rows) % rows; int col = (origin.col + randomWithNegExp(min, distance) + cols) % cols; if (row < 0) row = -row; if (col < 0) col = -col; Location loc = Location(row, col); if (passable(loc) && xAwayFromMyHill(minExploreDistanceFromHill,loc)) return loc; return randomLocationExp(origin, min, distance); } Location State::randomLocation() { vector<Location> unexplored; for (int row = 0;row<rows;row++) for(int col = 0;col<cols;col++) if (!grid[row][col].isExplored) unexplored.push_back(Location(row,col)); if (unexplored.empty()) { hasUnexplored = false; return Location(-1,-1); } return unexplored.at(rand() % unexplored.size()); } bool State::xAwayFromMyHill(int dis, Location current) { for(int i = 0;i<(int)myHills.size();i++) if(locDistance(myHills[i],current) <= dis) return false; return true; } int State::randomWithNeg(int min, int distance) { int r = (rand() % (2*distance)) - distance; r += (r >= 0) ? min : (-min); bug << "random: " << r << endl; return r; } int State::randomWithNegExp(int min, int distance) { bool positive = rand() % 2 == 0 ? true : false; double x = (-lnApprox(((double)rand()/(double)RAND_MAX),25))/(expLamda); bug << "random Exp ln: " << x; x = x*distance + min; if (!positive) x = -x; bug << " result: " << (int)x << endl; return (int)x; } double State::lnApprox(double x, int steps) { double result = x - 1; for(int i=2;i<steps;i++) if (i % 2 == 0) result -= pow(x-1,steps)/steps; else result += pow(x-1,steps)/steps; return result; } double State::pow(double x, int y) { double result = x; if (y == 0) return 1; for(int i = 0;i<y;i++) result *= x; return result; } //resets all non-water squares to land and clears the bots ant vector void State::reset() { antsMap.clear(); for(int i = 0;i<(int)myAnts.size();i++) { antsMap[myAnts[i].loc] = myAnts[i]; } for(map<Location, int>::iterator harIt = hillsAtRisk.begin();harIt != hillsAtRisk.end();harIt++) { if (grid[(*harIt).first.row][(*harIt).first.col].isVisible) { if (!grid[(*harIt).first.row][(*harIt).first.col].isHill) (*harIt).second = 0; else if ((*harIt).second > 0) { (*harIt).second--; } } } myAnts.clear(); enemyAnts.clear(); myHills.clear(); enemyHills.clear(); food.clear(); for(int row=0; row<rows; row++) for(int col=0; col<cols; col++) if(!grid[row][col].isWater) { grid[row][col].reset(); gridNextTurn[row][col].ant = 0; } }; //outputs move information to the engine void State::makeMove(const Location &loc, int direction) { cout << "o " << loc.row << " " << loc.col << " " << CDIRECTIONS[direction] << endl; Location nLoc = getLocation(loc, direction); grid[nLoc.row][nLoc.col].ant = grid[loc.row][loc.col].ant; grid[loc.row][loc.col].ant = -1; }; void State::moveAnt(Ant &a) { Location loc = a.loc; int direction = directionFromPoints(a.loc,a.queue.front()); bug << "moving ant at " << a.loc << " " << CDIRECTIONS[direction] << " " << a.roleText() << endl; cout << "o " << loc.row << " " << loc.col << " " << CDIRECTIONS[direction] << endl; a.countRetreating(); Location nLoc = getLocation(loc, direction); grid[nLoc.row][nLoc.col].ant = grid[loc.row][loc.col].ant; grid[loc.row][loc.col].ant = -1; a.updateQueue(); }; void State::makeMoves() { for(int i = 0;i<(int)myAnts.size();i++) { if(!myAnts[i].idle()) moveAnt(myAnts[i]); else bug << "ant at " << myAnts[i].loc << " idle" << endl; } } int State::locDistance(const Location &loc1, const Location &loc2) { return modDistance(rows, loc1.row, loc2.row) + modDistance(cols, loc1.col, loc2.col); } int State::modDistance(int m, int x, int y) { int a = abs(x - y); return (a < (m - a)) ? a : (m - a); } //returns the euclidean distance between two locations with the edges wrapped double State::distance(const Location &loc1, const Location &loc2) { return sqrt(distanceSq(loc1, loc2)); }; //returns the square of the euclidean distance between two locations with the edges wrapped double State::distanceSq(const Location &loc1, const Location &loc2) { int d1 = abs(loc1.row-loc2.row), d2 = abs(loc1.col-loc2.col), dr = min(d1, rows-d1), dc = min(d2, cols-d2); return dr*dr + dc*dc; }; //returns the new location from moving in a given direction with the edges wrapped Location State::getLocation(const Location &loc, int direction) { return Location( (loc.row + DIRECTIONS[direction][0] + rows) % rows, (loc.col + DIRECTIONS[direction][1] + cols) % cols ); }; vector<Location> State::validNeighbors(const Location &current, const Location &start) { vector<Location> valid; for(int i = 0;i<4;i++) { Location loc = getLocation(current, i); if (((current == start) ? passableNextTurn(loc) : passable(loc)) && !isOnMyHill(loc))//avoiding routefinding on the hill can cause an ant to get stuck if the hill is near a single passable square with no other way out valid.push_back(loc); } return valid; }; vector<Location> State::validNeighbors(const Location &current) { vector<Location> valid; for(int i = 0;i<4;i++) { Location loc = getLocation(current, i); if (passable(loc)) valid.push_back(loc); } return valid; }; bool State::isOnMyHill(const Location &current) { for(int i = 0;i<(int)myHills.size();i++) if(myHills[i] == current) return true; return false; } bool State::passableNextTurn(const Location &loc) { if (grid[loc.row][loc.col].isWater) return false; if (gridNextTurn[loc.row][loc.col].ant>0) return false; return true; }; bool State::passable(const Location &loc) { return (!grid[loc.row][loc.col].isWater); }; /* This function will update update the lastSeen value for any squares currently visible by one of your live ants. BE VERY CAREFUL IF YOU ARE GOING TO TRY AND MAKE THIS FUNCTION MORE EFFICIENT, THE OBVIOUS WAY OF TRYING TO IMPROVE IT BREAKS USING THE EUCLIDEAN METRIC, FOR A CORRECT MORE EFFICIENT IMPLEMENTATION, TAKE A LOOK AT THE GET_VISION FUNCTION IN ANTS.PY ON THE CONTESTS GITHUB PAGE. */ void State::updateVisionInformation() { std::queue<Location> locQueue; Location sLoc, cLoc, nLoc; for(int a=0; a<(int) myAnts.size(); a++) { sLoc = myAnts[a].loc; locQueue.push(sLoc); std::vector<std::vector<bool> > visited(rows, std::vector<bool>(cols, false)); grid[sLoc.row][sLoc.col].isVisible = true; visited[sLoc.row][sLoc.col] = true; while(!locQueue.empty()) { cLoc = locQueue.front(); locQueue.pop(); for(int d=0; d<TDIRECTIONS; d++) { nLoc = getLocation(cLoc, d); if(!visited[nLoc.row][nLoc.col] && distance(sLoc, nLoc) <= viewradius) { grid[nLoc.row][nLoc.col].isVisible = true; grid[nLoc.row][nLoc.col].isExplored = true; locQueue.push(nLoc); } visited[nLoc.row][nLoc.col] = true; } } } }; /* This is the output function for a state. It will add a char map representation of the state to the output stream passed to it. For example, you might call "cout << state << endl;" */ ostream& operator<<(ostream &os, const State &state) { for(int row=0; row<state.rows; row++) { for(int col=0; col<state.cols; col++) { if(state.grid[row][col].isWater) os << '%'; else if(state.grid[row][col].isFood) os << '*'; else if(state.grid[row][col].isHill) os << (char)('A' + state.grid[row][col].hillPlayer); else if(state.grid[row][col].ant >= 0) os << (char)('a' + state.grid[row][col].ant); else if(state.grid[row][col].isVisible) os << '.'; else os << '?'; } os << endl; } return os; }; //input function istream& operator>>(istream &is, State &state) { int row, col, player; string inputType, junk; //finds out which turn it is while(is >> inputType) { if(inputType == "end") { state.gameover = 1; break; } else if(inputType == "turn") { is >> state.turn; break; } else //unknown line getline(is, junk); } if(state.turn == 0) { //reads game parameters while(is >> inputType) { if(inputType == "loadtime") is >> state.loadtime; else if(inputType == "turntime") { is >> state.turntime; state.bug << "turntime: " << state.turntime << " ms" << endl; } else if(inputType == "rows") is >> state.rows; else if(inputType == "cols") is >> state.cols; else if(inputType == "turns") is >> state.turns; else if(inputType == "player_seed") { is >> state.seed; //srand ( state.seed ); srand ( (int) time(NULL) ); } else if(inputType == "viewradius2") { is >> state.viewradius; state.viewradius2 = state.viewradius; state.viewradius = sqrt(state.viewradius); } else if(inputType == "attackradius2") { is >> state.attackradius; state.attackradius2 = state.attackradius; state.attackradius = sqrt(state.attackradius); } else if(inputType == "spawnradius2") { is >> state.spawnradius; state.spawnradius = sqrt(state.spawnradius); } else if(inputType == "ready") //end of parameter input { state.timer.start(); break; } else //unknown line getline(is, junk); } } else { //reads information about the current turn while(is >> inputType) { if(inputType == "w") //water square { is >> row >> col; state.grid[row][col].isWater = true; } else if(inputType == "f") //food square { is >> row >> col; state.grid[row][col].isFood = true; state.food.push_back(Location(row, col)); } else if(inputType == "a") //live ant square { is >> row >> col >> player; state.grid[row][col].ant = player; if(player == 0) { Location loc = Location(row, col); state.bug << "new ant at " << loc; map<Location,Ant>::iterator it = state.antsMap.find(loc); if (it == state.antsMap.end()) { state.bug << " not found in map" << endl; state.myAnts.push_back(Ant(loc,0)); } else { state.bug << " found in map" << endl; state.myAnts.push_back(it -> second); } Location nLoc = state.myAnts.back().positionNextTurn(); state.gridNextTurn[nLoc.row][nLoc.col].ant++; } else state.enemyAnts.push_back(Ant(Location(row, col),player)); } else if(inputType == "d") //dead ant square { is >> row >> col >> player; state.grid[row][col].deadAnts.push_back(player); } else if(inputType == "h") { is >> row >> col >> player; state.grid[row][col].isHill = true; state.grid[row][col].hillPlayer = player; if(player == 0) state.myHills.push_back(Location(row, col)); else state.enemyHills.push_back(Location(row, col)); } else if(inputType == "players") //player information is >> state.noPlayers; else if(inputType == "scores") //score information { state.scores = vector<double>(state.noPlayers, 0.0); for(int p=0; p<state.noPlayers; p++) is >> state.scores[p]; } else if(inputType == "go") //end of turn input { if(state.gameover) is.setstate(std::ios::failbit); else state.timer.start(); break; } else //unknown line getline(is, junk); } } return is; }; // Pathfinding void State::setAntQueue(Ant &a, list<Location> q, Location destination) { Location oLoc = a.positionNextTurn(); a.queue = q; a.iDestination = destination; Location nLoc = a.positionNextTurn(); gridNextTurn[nLoc.row][nLoc.col].ant++; gridNextTurn[oLoc.row][oLoc.col].ant--; } void State::setAntQueue(Ant &a, Location destination) { Location oLoc = a.positionNextTurn(); a.queue.clear(); a.queue.push_back(destination); a.iDestination = destination; Location nLoc = a.positionNextTurn(); gridNextTurn[nLoc.row][nLoc.col].ant++; gridNextTurn[oLoc.row][oLoc.col].ant--; } bool State::locationEq(Location a, Location b) { if (a.row == b.row && a.col == b.col) return true; return false; }; // Timeout here? debug: // killing hills with idle ants // pathfinding from (126, 75) to (82, 121) // steps taken: 550 list<Location> State::reconstruct_path(map<Location, Location> cameFrom, Location prev) { if (cameFrom.count(prev)>0) { list<Location> path = reconstruct_path(cameFrom, cameFrom[prev]); path.push_back(prev); return path; } else { list<Location> path; path.push_back(prev); return path; } } int State::heuristic_cost_estimate(Location start, Location goal) { return locDistance(start, goal); }; //const char CDIRECTIONS[4] = {'N', 'E', 'S', 'W'}; int State::directionFromPoints(Location point1, Location point2) { if (point1.row == 0 && point2.row == (rows-1) ) return 0; if (point2.row == 0 && point1.row == (rows-1) ) return 2 ; if (point1.col == 0 && point2.col == (cols-1) ) return 3; if (point2.col == 0 && point1.col == (cols-1)) return 1; if (point1.row > point2.row ) return 0; if (point2.row > point1.row ) return 2; if (point1.col > point2.col ) return 3; return 1; }; struct LocationContainer { Location l; int f_score; int g_score; LocationContainer() { f_score = 0; } public: LocationContainer(Location ls, int f, int g) { l = ls; f_score = f; g_score = g; } int getf_score() const { return f_score; } }; class locContainerCompare { public: locContainerCompare() { } bool operator() (const LocationContainer& lhs, const LocationContainer& rhs) { return (lhs.f_score > rhs.f_score); } }; /* From Wikipedia function A*(start,goal) closedset := the empty set // The set of nodes already evaluated. openset := {start} // The set of tentative nodes to be evaluated, initially containing the start node came_from := the empty map // The map of navigated nodes. g_score[start] := 0 // Cost from start along best known path. h_score[start] := heuristic_cost_estimate(start, goal) f_score[start] := g_score[start] + h_score[start] // Estimated total cost from start to goal through y. while openset is not empty x := the node in openset having the lowest f_score[] value if x = goal return reconstruct_path(came_from, came_from[goal]) remove x from openset add x to closedset foreach y in neighbor_nodes(x) if y in closedset continue tentative_g_score := g_score[x] + dist_between(x,y) if y not in openset add y to openset tentative_is_better := true else if tentative_g_score < g_score[y] tentative_is_better := true else tentative_is_better := false if tentative_is_better = true came_from[y] := x g_score[y] := tentative_g_score h_score[y] := heuristic_cost_estimate(y, goal) f_score[y] := g_score[y] + h_score[y] return failure function reconstruct_path(came_from, current_node) if came_from[current_node] is set p = reconstruct_path(came_from, came_from[current_node]) return (p + current_node) else return current_node */ list<Location> State::bfs(Location start, Location goal) { //typedef priority_queue<Location, vector<Location>, heuristicCompare> mypq_type; //mypq_type openSet (heuristicCompare(rows,cols,goal)); priority_queue<LocationContainer, vector<LocationContainer>, locContainerCompare> openSet; map<Location, bool> openSetMap; map<Location, bool> closedSet; map<Location, Location> cameFrom; map<Location, int> g_score; bug << "pathfinding from " << start << " to " << goal << endl; g_score[start] = 0; openSet.push(LocationContainer(start, heuristic_cost_estimate(start, goal), 0)); openSetMap[start] = true; int steps = 0; while (!openSet.empty()) { steps++; LocationContainer current = openSet.top(); openSet.pop(); if (locationEq(current.l, goal) || steps >= searchStepLimit) { bug << "steps taken: " << steps << endl; return reconstruct_path(cameFrom, current.l); } closedSet[current.l]=true; vector<Location> validNeighborsV = validNeighbors(current.l, start); for(int i = 0;i < (int)validNeighborsV.size();i++) { Location neighbor = validNeighborsV[i]; if (closedSet.count(neighbor)>0) continue; int tentative_g_score = current.g_score + locDistance(current.l,neighbor); bool tentativeIsBetter = false; if (! (openSetMap.count(neighbor)>0)) { tentativeIsBetter = true; } else if (tentative_g_score < g_score[neighbor]) { tentativeIsBetter = true; } if (tentativeIsBetter) { cameFrom[neighbor] = current.l; g_score[neighbor] = tentative_g_score; openSet.push(LocationContainer(neighbor,heuristic_cost_estimate(neighbor, goal)+tentative_g_score, tentative_g_score)); openSetMap[neighbor] = true; } } } bug << "no path found" << endl; list<Location> empty; return empty; }; // Action functions bool State::checkDestinations(vector<Location> destinations, Location destination) { for(int i = 0;i<(int)destinations.size();i++) if(destination == destinations[i]) return true; return false; } void State::getCloseFoods(vector<Ant*> &ants, list<Location> &food, int maxDistance, bool retainCurrentDestination) { vector<Ant*> tooFarAnts; while(!ants.empty()) { if (food.empty()) break; Ant *a = ants.back(); Location minFood = food.front(); for (list<Location>::iterator foodIt=food.begin(); foodIt != food.end(); foodIt++ ){ if ( locDistance((*a).loc, *foodIt) < locDistance((*a).loc, minFood)) minFood = *foodIt; } if (locDistance((*a).loc,minFood) > maxDistance) { bug << "ant too far " << locDistance((*a).loc,minFood) << endl; tooFarAnts.push_back(a); ants.pop_back(); continue; } ants.pop_back(); food.remove(minFood); list<Location> path = bfs((*a).loc, minFood); if (! path.empty()) { path.pop_front(); if (retainCurrentDestination && !(*a).idle()) { (*a).rDestination = (*a).destination(); (*a).intRole = (*a).role; } (*a).setFood(); setAntQueue((*a), path, minFood); } } while(!tooFarAnts.empty()) { ants.push_back(tooFarAnts.back()); tooFarAnts.pop_back(); } } void State::killCloseHills(vector<Ant*> &ants, int maxDistance, bool retainCurrentDestination) { vector<Ant*> tooFarAnts; while(!ants.empty()) { if (enemyHills.empty()) break; Ant *a = ants.back(); Location minHill = enemyHills.front(); for (vector<Location>::iterator hillIt=enemyHills.begin(); hillIt != enemyHills.end(); hillIt++ ){ if ( locDistance((*a).loc, *hillIt) < locDistance((*a).loc, minHill)) minHill = *hillIt; } if (locDistance((*a).loc,minHill) > maxDistance) { bug << "ant too far " << locDistance((*a).loc,minHill) << endl; tooFarAnts.push_back(a); ants.pop_back(); continue; } ants.pop_back(); list<Location> path = bfs((*a).loc, minHill); if (! path.empty()) { path.pop_front(); if (retainCurrentDestination && !(*a).idle()) { (*a).rDestination = (*a).destination(); (*a).intRole = (*a).role; } (*a).setFood(); setAntQueue((*a), path, minHill); } } while(!tooFarAnts.empty()) { ants.push_back(tooFarAnts.back()); tooFarAnts.pop_back(); } } void State::getFoods(vector<Ant*> &ants, list<Location> &food, int maxDistance) { vector<Ant*> idleAnts; while(!food.empty() && !ants.empty()) { Location currFood = food.front(); Ant *a = ants.front(); for(list<Location>::iterator foodIt=food.begin(); foodIt != food.end(); foodIt++) for (vector<Ant*>::iterator antIt=ants.begin(); antIt != ants.end(); antIt++ ) if ((**antIt).idle() && (!(*a).idle() || locDistance((**antIt).loc, *foodIt) < locDistance((*a).loc, currFood))) { a = *antIt; currFood = *foodIt; } food.remove(currFood); if (locDistance((*a).loc,currFood) > maxDistance) { bug << "ant too far " << locDistance((*a).loc,currFood) << endl; continue; } if (!(*a).idle()) { bug << "no more idle ants"; break; } list<Location> path = bfs((*a).loc, currFood); if (! path.empty()) { #ifdef DEBUG list<Location>::iterator it; bug << "food path: "; for ( it=path.begin() ; it != path.end(); it++ ) bug << *it << " "; bug << endl; #endif path.pop_front(); (*a).setFood(); setAntQueue((*a), path, currFood); } } for (vector<Ant*>::iterator antIt=ants.begin(); antIt != ants.end(); antIt++ ){ if ((**antIt).idle()) idleAnts.push_back(*antIt); } ants.clear(); while(!idleAnts.empty()) { ants.push_back(idleAnts.back()); idleAnts.pop_back(); } } void State::killHills(vector<Ant*> &ants, vector<Location> &hills, int antsPerHillPerTurn) { int antsSentHere = 0; Location currentHill; while (!hills.empty()) { currentHill = hills.back(); antsSentHere = 0; while((!ants.empty()) && (antsSentHere < antsPerHillPerTurn)) { Ant *a = ants.back(); ants.pop_back(); list<Location> path = bfs((*a).loc, currentHill); #ifdef DEBUG list<Location>::iterator it; bug << "kill path: "; for ( it=path.begin() ; it != path.end(); it++ ) bug << *it << " "; bug << endl; #endif if (! path.empty()) { path.pop_front(); (*a).setAttack(); setAntQueue((*a), path, currentHill); antsSentHere++; } } hills.pop_back(); } } void State::explore(Ant &ant, int mExpDis, int maxExpDis, bool closePoint) { Location exploreDest; if (closePoint) exploreDest = randomLocation(ant.loc, mExpDis, maxExpDis); else exploreDest = randomLocation(); if (exploreDest.row == -1 && exploreDest.col == -1) return; bug << "exploring from " << ant.loc << " to " << exploreDest << endl; list<Location> path = bfs(ant.loc, exploreDest); if (! path.empty()) { path.pop_front(); ant.setExplore(); setAntQueue(ant, path, exploreDest); } } void State::goExplore(vector<Ant*> &ants, int mExpDis, int maxExpDis) { //explore with additional ants if we have any while(!ants.empty()) { Ant *a = ants.back(); ants.pop_back(); explore(*a, mExpDis, maxExpDis, true); } } void State::goExploreUnexplored(vector<Ant*> &ants, int antsToTake) { if (!hasUnexplored) return; //explore with additional ants if we have any for(int i = 0;i<antsToTake && !ants.empty();i++) { Ant *a = ants.back(); ants.pop_back(); explore(*a, 0, 0, false); } } void State::rerouteAnt(Ant &ant) { list<Location> path = bfs(ant.loc, ant.destination()); #ifdef DEBUG list<Location>::iterator it; bug << "reroute path: "; for ( it=path.begin() ; it != path.end(); it++ ) bug << *it << " "; bug << endl; #endif if (path.empty()) { ant.setIdle(); } else { path.pop_front(); setAntQueue(ant, path, ant.destination()); } } bool State::xAwayFromMyHills(Ant &ant, double buffer) { for(int i = 0;i<(int)myHills.size();i++) if (distanceSq(ant.loc,myHills[i]) < viewradius2 + buffer) return false; return true; } vector<Location> State::closestEnemies(Location loc, double buffer) { vector<Location> neighbors; map<Location, bool> closedSet; vector<Location> closeAnts; neighbors.push_back(loc); while(!neighbors.empty()) { Location current = neighbors.back(); neighbors.pop_back(); closedSet[current] = true; vector<Location> validNeighborsV = validNeighbors(current); for(int j = 0;j < (int)validNeighborsV.size();j++) { if (closedSet.count(validNeighborsV[j])>0) continue; if (distanceSq(validNeighborsV[j],loc) < viewradius2 + buffer) { neighbors.push_back(validNeighborsV[j]); if (grid[validNeighborsV[j].row][validNeighborsV[j].col].ant > 0) { closeAnts.push_back(validNeighborsV[j]); } } } } neighbors.clear(); closedSet.clear(); return closeAnts; } // On very small maps this does not work well void State::defendHill(int antsPerTurn, double buffer) { vector<int> exclude; vector<Location> closeAnts; for(int i = 0;i<(int)myHills.size();i++) { bool atRisk = false; Location closestAnt; bool hasClosest = false; closeAnts = closestEnemies(myHills[i], buffer); for(int j = 0;j<(int)closeAnts.size();j++) if (!hasClosest || distanceSq(closeAnts[j],myHills[i]) < distanceSq(closestAnt,myHills[i])) { hasClosest = true; closestAnt = closeAnts[j]; } atRisk = !closeAnts.empty(); if (atRisk) { hillsAtRisk[myHills[i]] = turnsTillNotAtRisk; bug << "hill " << myHills[i] << " at risk" << endl; list<Ant*> defendingAnts; vector<Ant*> myCloseAnts; for(int j = 0;j<(int)myAnts.size();j++) { if (myAnts[j].isDefending() ) { if (distanceSq(myAnts[j].loc,myHills[i]) < viewradius2) defendingAnts.push_back(&myAnts[j]); } else { if ((int)myCloseAnts.size() < antsPerTurn && myCloseAnts.size() < (int)closeAnts.size()) myCloseAnts.push_back(&myAnts[j]); else { int minIndex = 0; for(int k = 1;k<(int)myCloseAnts.size();k++) if (distanceSq((*myCloseAnts[k]).loc,myHills[i]) > distanceSq((*myCloseAnts[minIndex]).loc,myHills[i])) minIndex = k; if (distanceSq(myAnts[j].loc,myHills[i]) < distanceSq((*myCloseAnts[minIndex]).loc,myHills[i])) myCloseAnts[minIndex] = &myAnts[j]; } } } // If we have more than maxDefendingAnts defending this hill than go on to the next hill if ((int)defendingAnts.size() >= maxDefendingAnts || (int)defendingAnts.size() >= (int)(myAnts.size()/myHills.size())) continue; // If there is only one enemy go kill him if (closeAnts.size() == 1) { Ant def; if (defendingAnts.size() > 0) def = (*defendingAnts.back()); else def = (*myCloseAnts.back()); list<Location> path = bfs(def.loc, closestAnt); bug << "sending ant at " << def.loc << "to kill ant at " << closestAnt << endl; if (! path.empty()) { path.pop_front(); setAntQueue(def, path, closestAnt); } continue; } vector<Location> hLocs = validNeighbors(myHills[i]); if (!hLocs.empty()) { Location hLoc = hLocs[0]; Location mLoc = hLocs[0]; for (int k = 1;k<(int)hLocs.size();k++) { if (distanceSq(hLocs[k],closestAnt) < distanceSq(hLoc,closestAnt)) hLoc = hLocs[k]; if (distanceSq(hLocs[k],closestAnt) > distanceSq(mLoc,closestAnt)) mLoc = hLocs[k]; } bool horizontal = false; if (hLoc.row - myHills[i].row != 0) horizontal = true; vector<Location> positions; //const char CDIRECTIONS[4] = {'N', 'E', 'S', 'W'}; if (horizontal) { positions.push_back(hLoc); positions.push_back(getLocation(hLoc,1));//E positions.push_back(getLocation(hLoc,3));//W } else { positions.push_back(hLoc); positions.push_back(getLocation(hLoc,0));//N positions.push_back(getLocation(hLoc,2));//S } list<Ant*> inPositionAnts; //Organize already defending ants that are now close to this hill // TODO bug << "organizing defending ants" << endl; bug << "sorting through defending ants" << endl; for (int l = 0;l<(int)positions.size() && !positions.empty();l++) for (list<Ant*>::iterator it1 = defendingAnts.begin(); it1 != defendingAnts.end() && !positions.empty(); it1++) { if ((**it1).loc == positions.back()) { positions.pop_back(); clearAntQueue(**it1); inPositionAnts.push_back(*it1); it1 = defendingAnts.erase(it1); } else if ((**it1).destination() == positions.back()) { positions.pop_back(); it1 = defendingAnts.erase(it1); } } //All ants in position, move towards enemies //if (positions.empty()) { // for (list<Ant*>::iterator it1 = inPositionAnts.begin(); it1 != inPositionAnts.end(); it1++) // setAntQueue(**it1, getLocation((**it1).loc, directionFromPoints(myHills[i],hLoc) )); //} bug << "sending ants to positions" << endl; while (!positions.empty() && !defendingAnts.empty()) { Location current = positions.back(); positions.pop_back(); list<Location> path = bfs((*defendingAnts.back()).loc, current); bug << "sending ant at " << (*defendingAnts.back()).loc << endl; if (! path.empty()) { path.pop_front(); setAntQueue((*defendingAnts.back()), path, current); } defendingAnts.pop_back(); } // Send new ants to defend bug << "sending new ants to defend" << endl; for(int j = 0;j<(int)myCloseAnts.size();j++) { list<Location> path = bfs((*myCloseAnts[j]).loc, mLoc); bug << "sending ant at " << (*myCloseAnts[j]).loc << endl; if (! path.empty()) { path.pop_front(); if (!(*myCloseAnts[j]).idle()) { (*myCloseAnts[j]).rDestination = (*myCloseAnts[j]).destination(); (*myCloseAnts[j]).intRole = (*myCloseAnts[j]).role; } (*myCloseAnts[j]).setDefend(myHills[i]); setAntQueue((*myCloseAnts[j]), path, mLoc); } } } } exclude.clear(); } } /* # we pre-calculate the number of enemies around each ant to make it faster # maps ants to nearby enemies nearby_enemies = {} for ant in self.current_ants.values(): nearby_enemies[ant] = self.nearby_ants(ant.loc, self.attackradius, ant.owner) # determine which ants to kill ants_to_kill = [] for ant in self.current_ants.values(): # determine this ants weakness (1/power) weakness = len(nearby_enemies[ant]) # an ant with no enemies nearby can't be attacked if weakness == 0: continue # determine the most powerful nearby enemy min_enemy_weakness = min(len(nearby_enemies[enemy]) for enemy in nearby_enemies[ant]) # ant dies if it is weak as or weaker than an enemy weakness if min_enemy_weakness <= weakness: ants_to_kill.append(ant) */ //Not Working vector<Ant> State::myAntsWhoWillAntDie() { map<Location, vector<Ant> > nearby_enemies; vector<Ant> antsWhoWillDie; for(int i = 0;i<(int)myAnts.size();i++) { nearby_enemies[myAnts[i].loc] = nearbyAnts(myAnts[i].loc, myAnts[i].owner); } for(int i = 0;i<(int)enemyAnts.size();i++) { nearby_enemies[enemyAnts[i].loc] = nearbyAnts(enemyAnts[i].loc, enemyAnts[i].owner); } for(int i = 0;i<(int)myAnts.size();i++) { vector<Ant> enemies = nearby_enemies[myAnts[i].loc]; int weakness = enemies.size(); if (weakness == 0) continue; int max_enemy_weakness = 0; for(int j = 0;j< (int)enemies.size();j++) { int tWeak = nearby_enemies[enemies[j].loc].size(); if(tWeak > max_enemy_weakness) max_enemy_weakness = tWeak; } if (max_enemy_weakness >= weakness) antsWhoWillDie.push_back(myAnts[i]); } return antsWhoWillDie; } // Need will die next turn which will use grid next turn in nearbyAnts next turn bool State::willAntDie(Location loc) { vector<Ant> enemies = nearbyAnts(loc, 0); int weakness = enemies.size(); if (weakness == 0) return false; int min_enemy_weakness = -1; for(int j = 0;j< (int)enemies.size();j++) { int tWeak = nearbyAnts(enemies[j].loc, enemies[j].owner).size(); if(min_enemy_weakness == -1 || tWeak < min_enemy_weakness) min_enemy_weakness = tWeak; } if (min_enemy_weakness <= weakness) return true; return false; } //We should use positionNextTurn or girdNextTurn when using this for ants which aren't mine vector<Ant> State::nearbyAnts(Location loc, int owner) { vector<Location> neighbors; vector<Ant> close; map<Location, bool> closedSet; neighbors.push_back(loc); while(!neighbors.empty()) { Location current = neighbors.back(); neighbors.pop_back(); closedSet[current] = true; vector<Location> validNeighborsV = validNeighbors(current); for(int i = 0;i < (int)validNeighborsV.size();i++) { if (closedSet.count(validNeighborsV[i])>0) continue; if (distanceSq(validNeighborsV[i],loc) < attackradius2+attackDistanceBuffer) { neighbors.push_back(validNeighborsV[i]); if (owner == 0) { if (grid[validNeighborsV[i].row][validNeighborsV[i].col].ant != -1 && (grid[validNeighborsV[i].row][validNeighborsV[i].col].ant != owner)) close.push_back(Ant(validNeighborsV[i], grid[validNeighborsV[i].row][validNeighborsV[i].col].ant)); } else { if (grid[validNeighborsV[i].row][validNeighborsV[i].col].ant != -1 && (grid[validNeighborsV[i].row][validNeighborsV[i].col].ant != owner) && grid[validNeighborsV[i].row][validNeighborsV[i].col].ant != 0) close.push_back(Ant(validNeighborsV[i], grid[validNeighborsV[i].row][validNeighborsV[i].col].ant)); else if (gridNextTurn[validNeighborsV[i].row][validNeighborsV[i].col].ant > 0) close.push_back(Ant(validNeighborsV[i], 0)); } } } } return close; } Location State::nearestEnemy(Ant &ant) { vector<Location> neighbors; map<Location, bool> closedSet; neighbors.push_back(ant.loc); while(!neighbors.empty()) { Location current = neighbors.back(); neighbors.pop_back(); closedSet[current] = true; vector<Location> validNeighborsV = validNeighbors(current); for(int i = 0;i < (int)validNeighborsV.size();i++) { if (closedSet.count(validNeighborsV[i])>0) continue; if (distanceSq(validNeighborsV[i],ant.loc) < 2*viewradius2) { neighbors.push_back(validNeighborsV[i]); if (grid[validNeighborsV[i].row][validNeighborsV[i].col].ant != -1 && (grid[validNeighborsV[i].row][validNeighborsV[i].col].ant != ant.owner)) return validNeighborsV[i]; } } } return ant.loc; } // Maybe want to set iDestination here if queue is empty at the beginning void State::retreatAntFromNearestEnemy(Ant &ant) { Location nearest = nearestEnemy(ant); bug << "nearest enemy at: " << nearest << endl; // No enemy within sight of this ant if (nearest == ant.loc) return; Location oLoc = ant.positionNextTurn(); Location retreat = retreatLocation(ant, nearest); if (retreat == ant.loc) return; ant.retreatCount += 2; ant.queue.push_front(ant.loc); ant.queue.push_front(retreat); Location nLoc = ant.positionNextTurn(); gridNextTurn[nLoc.row][nLoc.col].ant++; gridNextTurn[oLoc.row][oLoc.col].ant--; } //const int DIRECTIONS[4][2] = { {-1, 0}, {0, 1}, {1, 0}, {0, -1} }; //{N, E, S, W} Location State::retreatLocation(Ant &ant, Location nearest) { vector<Location> validNeighborsV = validNeighbors(ant.loc, ant.loc); if (validNeighborsV.empty()) return ant.loc; Location farthest = validNeighborsV.front(); for (int i = 1;i<(int)validNeighborsV.size();i++) if (distanceSq(nearest,validNeighborsV[i]) > distanceSq(nearest,farthest)) farthest = validNeighborsV[i]; return farthest; } int State::calcExploreDistance(int modifier, int divisor) { int t = (cols*rows)/divisor; //if (useSquareOfPlayers) // t = (cols*rows/(noPlayers*noPlayers))/divisor; //else // t = (cols*rows/(noPlayers))/divisor; return t + modifier; } int State::getExploreDistance() { return exploreDistance; } int State::getMinExploreDistance() { return minExploreDistance; } void State::setExploreDistance(int modifier, int divisor) { exploreDistance = calcExploreDistance(modifier, divisor); bug << "set explore distance at " << exploreDistance << endl; } void State::setMinExploreDistance(int modifier, int divisor) { minExploreDistance = calcExploreDistance(modifier, divisor); bug << "set min explore distance at " << minExploreDistance << endl; } void State::setAntIdle(Ant &ant) { Location oLoc = ant.positionNextTurn(); ant.setIdle(); Location nLoc = ant.positionNextTurn(); gridNextTurn[nLoc.row][nLoc.col].ant++; gridNextTurn[oLoc.row][oLoc.col].ant--; } void State::clearAntQueue(Ant &ant) { Location oLoc = ant.positionNextTurn(); ant.queue.clear(); Location nLoc = ant.positionNextTurn(); gridNextTurn[nLoc.row][nLoc.col].ant++; gridNextTurn[oLoc.row][oLoc.col].ant--; }
[ [ [ 1, 318 ], [ 320, 332 ], [ 334, 452 ], [ 454, 457 ], [ 459, 489 ], [ 491, 772 ], [ 775, 845 ], [ 847, 848 ], [ 850, 852 ], [ 859, 859 ], [ 861, 987 ], [ 993, 1000 ], [ 1007, 1007 ], [ 1009, 1050 ], [ 1052, 1054 ], [ 1056, 1061 ], [ 1063, 1071 ], [ 1073, 1075 ], [ 1077, 1078 ], [ 1080, 1093 ], [ 1095, 1095 ], [ 1097, 1099 ], [ 1101, 1102 ], [ 1125, 1293 ], [ 1295, 1297 ], [ 1299, 1329 ], [ 1339, 1471 ] ], [ [ 319, 319 ], [ 333, 333 ], [ 453, 453 ], [ 458, 458 ], [ 490, 490 ], [ 773, 774 ], [ 846, 846 ], [ 849, 849 ], [ 853, 858 ], [ 860, 860 ], [ 988, 992 ], [ 1001, 1006 ], [ 1008, 1008 ], [ 1051, 1051 ], [ 1055, 1055 ], [ 1062, 1062 ], [ 1072, 1072 ], [ 1076, 1076 ], [ 1079, 1079 ], [ 1094, 1094 ], [ 1096, 1096 ], [ 1100, 1100 ], [ 1103, 1124 ], [ 1294, 1294 ], [ 1298, 1298 ], [ 1330, 1338 ] ] ]
68be23c219e59832b43823fd8f308b6005ba0e8c
fcdddf0f27e52ece3f594c14fd47d1123f4ac863
/TeCom/src/TdkLayout/Header Files/TdkBackgroundTypeProperty.h
8744d0d8500a2d708f52323c77e1cc2cca723068
[]
no_license
radtek/terra-printer
32a2568b1e92cb5a0495c651d7048db6b2bbc8e5
959241e52562128d196ccb806b51fda17d7342ae
refs/heads/master
2020-06-11T01:49:15.043478
2011-12-12T13:31:19
2011-12-12T13:31:19
null
0
0
null
null
null
null
ISO-8859-2
C++
false
false
2,114
h
/****************************************************************************** * FUNCATE - GIS development team * * TerraLib Components - TeCOM * * @(#) TdkBackgroundTypeProperty.h * ******************************************************************************* * * $Rev$: * * $Author: rui.gregorio $: * * $Date: 2010/08/23 13:21:19 $: * ******************************************************************************/ // Elaborated by Rui Mauricio Gregório #ifndef __TDK_BACKGROUND_TYPE_PROPERTY_H #define __TDK_BACKGROUND_TYPE_PROPERTY_H #include <TdkAbstractProperty.h> //! \class TdkBackgroundTypeProperty /*! Class to represent the rectangle background type property */ class TdkBackgroundTypeProperty : public TdkAbstractProperty { protected: short _value; //!< rectangle background type value public : //! \brief TdkBackgroundTypeProperty /*! Constructor \param newVale new rectangle background type value */ TdkBackgroundTypeProperty(const short &newVal=0.0); //! \brief ~TdkBackgroundTypeProperty /*! Destructor */ virtual ~TdkBackgroundTypeProperty(); //! \brief setValue /*! Method to set the new value to rectangle background type property \param newVal new angle value */ virtual void setValue(const short &newVal); //! \brief getValue /*! Method to return the rectangle background value \return returns the angle value */ virtual short getValue(); //! \brief getValue /*! Method to return the rectangle background value by reference */ virtual void getValue(double &value); //! \brief operator /*! Operator = overload \param other other TdkBackgroundTypeProperty object \return returns the object with same values that old object */ TdkBackgroundTypeProperty& operator=(const TdkBackgroundTypeProperty &other); //! \brief operator /*! Operator = overload \param other other TdkAbstractProperty object \return returns the object with same values that old object */ TdkBackgroundTypeProperty& operator=(const TdkAbstractProperty &other); }; #endif
[ "[email protected]@58180da6-ba8b-8960-36a5-00cc02a3ddec" ]
[ [ [ 1, 79 ] ] ]
72bab3f066b35db4c743eeb54c7a8955637c560f
20cf43a2e1854d71696a6264dea4ea8cbfdb16f2
/WinNT/comm_nt_server/stdafx.h
5334765dcfa2de801d7b42178e1c8b6c46475948
[]
no_license
thebruno/comm-nt
fb0ece0a8d36715a8f0199ba3ce9f37859170ee3
6ba36941b123c272efe8d81b55555d561d8842f4
refs/heads/master
2016-09-07T19:00:59.817929
2010-01-14T20:38:58
2010-01-14T20:38:58
32,205,785
0
0
null
null
null
null
UTF-8
C++
false
false
558
h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #include <stdio.h> #include <tchar.h> #pragma warning (disable: 4482) // TODO: reference additional headers your program requires here #include <string> #include <sstream> #include <list> #include <vector> #include <map> #include <iostream> #include <process.h> #include <winsock2.h> #include <windows.h> #include <iomanip>
[ "konrad.balys@08f01046-b83b-11de-9b33-83dc4fd2bb11" ]
[ [ [ 1, 29 ] ] ]
92c4cb9b66fc953ccaaf76a9fad7a36df6d7fa28
940a846f0685e4ca0202897a60c58c4f77dd94a8
/demo/FireFox/plugin/test/nprt3/jnicall/jnicall.cpp
a48644c3e983e1fab2aaff033c2e899907a09fed
[]
no_license
grharon/tpmbrowserplugin
be33fbe89e460c9b145e86d7f03be9c4e3b73c14
53a04637606f543012c0d6d18fa54215123767f3
refs/heads/master
2016-09-05T15:46:55.064258
2010-09-04T12:05:31
2010-09-04T12:05:31
35,827,176
0
0
null
null
null
null
UTF-8
C++
false
false
3,141
cpp
#include <stdlib.h> #include <iostream> #include <string> #include <stdio.h> #include "jnitest.h" using namespace std; void usage() { cerr<<"<program name> --debug --file <filename> --method <methodname> [--eof <eofline>] [--classpath <classpath>] [--args <argnum> <arg0, ...> ]"<<endl; cerr<<" debug : output debug info"<<endl; cerr<<" filename : tmpfile name"<<endl; cerr<<" method : method to call"<<endl; cerr<<" eof : eof flag"<<endl; cerr<<" classpath: classpath"<<endl; cerr<<" argnum : number of arguments"<<endl; cerr<<" arg0,... : arguments"<<endl; exit(2); } int main(int argc, char** argv) { string tmpfile; string method; string classpath(""); string eofstr(""); int argnum = 0; bool debug = false; char** args = NULL; if (0) { cout<<" arguments : "; for (int i=0;i<argc;i++) cout<<argv[i]<<' '; cout<<endl; } for (int i=0;i<argc;i++) { if (!strcmp(argv[i],"--debug")) { debug = true; } if (!strcmp(argv[i],"--file")) { if (++i == argc) usage(); tmpfile = string(argv[i]); } else if (!strcmp(argv[i],"--method")) { if (++i == argc) usage(); method = string(argv[i]); } else if (!strcmp(argv[i],"--eof")) { if (++i == argc) usage(); eofstr = string(argv[i]); } else if (!strcmp(argv[i],"--classpath")) { if (++i == argc) usage(); classpath = string(argv[i]); } else if (!strcmp(argv[i],"--args")) { if (++i == argc) usage(); argnum = atoi(argv[i]); if (argnum > 0) { args = new char*[argnum]; for (int j=0;j<argnum;j++) { if (++i == argc) usage(); args[j] = argv[i]; } } } } if ((tmpfile.empty()) || (method.empty())) { usage(); } if (debug) { cout<<"tmpfile = "<<tmpfile<<endl; cout<<"method = "<<method<<endl; cout<<"eof = "<<eofstr<<endl; cout<<"classpath = "<<classpath<<endl; cout<<"args = "<<argnum<<":"; for (int i=0;i<argnum;i++) cout<<args[i]<<","; cout<<endl; } int v = loadJVM(classpath.c_str(), debug); if (debug) { cout<<"loadJVM = "<<v<<endl; } if (v != 0) { cerr<<"Cannot load JVM"<<endl; return -1; } char *ret = NULL; bool fail = true; if ((method == "doSignature") && (argnum == 2)) { ret = jni_doSignature(fail, args[0], args[1]); } else if ((method == "getPublicKeyContent") && (argnum == 0)) { ret = jni_getPublicKeyContent(fail); } if (debug) { if (ret) cout<<"return value is "<<ret<<endl; else cout<<"return value is null"<<endl; } FILE* f = fopen(tmpfile.c_str(),"wb"); if (f) { if (ret) { int len = strlen(ret); int done = 0; if ((done = fwrite(ret,sizeof(char),len,f)) != len) { cerr<<"write "<<done<<" bytes, less than required "<<len<<" bytes."; fail = true; } } /* fwrite(eofstr.c_str(),sizeof(char),eofstr.size(),f); */ fflush(f); fclose(f); } else { cerr<<"cannot open "<<tmpfile<<endl; fail = true; } destroyJVM(); if (fail) { unlink(tmpfile.c_str()); return -1; } else return 0; }
[ "stlt1sean@aa5d9edc-7c6f-d5c9-3e23-ee20326b5c4f" ]
[ [ [ 1, 143 ] ] ]
75ce20af9c32bde0c74e02ab02e5884169f752e2
6dac9369d44799e368d866638433fbd17873dcf7
/src/branches/01032005/sound/fmod/FMODModuleBuffer.cpp
09617a7033b4ee6a2175ea09bea7fc3712a20fc0
[]
no_license
christhomas/fusionengine
286b33f2c6a7df785398ffbe7eea1c367e512b8d
95422685027bb19986ba64c612049faa5899690e
refs/heads/master
2020-04-05T22:52:07.491706
2006-10-24T11:21:28
2006-10-24T11:21:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,875
cpp
#include <FMODModuleBuffer.h> /** FMOD ModuleBuffer Constructor */ FMODModuleBuffer::FMODModuleBuffer() { m_module = NULL; } /** FMOD ModuleBuffer Deconstructor * * Operation: * -# Stop the module playing * -# Close the module */ FMODModuleBuffer::~FMODModuleBuffer() { Stop(); Close(); } /** Load a Tracker Module * * @param filename The name of the tracker module file * * @returns boolean true or false, depending on whether the module loaded or not */ bool FMODModuleBuffer::Load(std::string filename) { if((m_module = FMUSIC_LoadSong(filename.c_str())) != NULL) { return true; }else{ return false; } } /** Closes a Tracker Module * * @returns boolean true or false, in this case, true only since you ignore any error condition */ bool FMODModuleBuffer::Close(void) { FMUSIC_FreeSong(m_module); return true; } /** Plays a Tracker Module * * @returns The channel id that the tracker module is playing on */ int FMODModuleBuffer::Play(void) { m_channel = FMUSIC_PlaySong(m_module); return m_channel; } /** Pauses a tracker module * * @param pause Whether to pause the module or not * * @returns If the module paused, return true, otherwise false */ bool FMODModuleBuffer::Pause(bool pause) { if(FMUSIC_SetPaused(m_module,pause) == 1) return true; return false; } /** Stop the tracker module * * @returns boolean true or false, depending on whether the module stopped successfully or not */ bool FMODModuleBuffer::Stop(void) { if(FMUSIC_StopSong(m_module) == 1) return true; return false; } /** Sets the play position of the module * * @param position The position to set the module to start at * * @returns boolean true or false, depending on whether it was set successfully or not * * NOTE: This method is not implemented yet, as Fusion has no need to set the position of a track as yet * So it is impossible to know whether this method will set the start position in bytes or seconds, or minutes, or hours, or whatever */ bool FMODModuleBuffer::SetPosition(int position) { return false; } /** Sets the Volume of the module to play at * * @param volume The volume to set the tracker module to play at * * @returns boolean true or false, depending on whether setting the volume was successful or not * * The valid range of values for the volume is 0 to 255, silent, to max volume respectively */ bool FMODModuleBuffer::Volume(unsigned char volume) { if(FSOUND_SetVolume(m_channel,volume) == 1) return true; return false; } /** Tests whether the module is playing or not * * @returns boolean true or false, depending on whether the module is playing or not */ bool FMODModuleBuffer::IsPlaying(void) { if(FMUSIC_IsPlaying(m_module) == 1) return true; return false; }
[ "chris_a_thomas@1bf15c89-c11e-0410-aefd-b6ca7aeaabe7" ]
[ [ [ 1, 121 ] ] ]
0fe7f52baa522cb388c033e4bd5f604469141cdb
b22c254d7670522ec2caa61c998f8741b1da9388
/common/Triangle2D.h
c6163378b615843675f9d3c66df4a71f68e7ad72
[]
no_license
ldaehler/lbanet
341ddc4b62ef2df0a167caff46c2075fdfc85f5c
ecb54fc6fd691f1be3bae03681e355a225f92418
refs/heads/master
2021-01-23T13:17:19.963262
2011-03-22T21:49:52
2011-03-22T21:49:52
39,529,945
0
1
null
null
null
null
UTF-8
C++
false
false
2,023
h
/* ------------------------[ Lbanet Source ]------------------------- Copyright (C) 2009 Author: code adaptation from mochima.com Email : [email protected] -------------------------------[ GNU License ]------------------------------- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ----------------------------------------------------------------------------- */ #if !defined(__LbaNetModel_1_Triangle2D_h) #define __LbaNetModel_1_Triangle2D_h #include "Point2D.h" const int left_turn = +1; const int right_turn = -1; const int collinear = 0; const int counter_clockwise = left_turn; const int clockwise = right_turn; class Triangle2D { public: //Constructor explicit Triangle2D (const Point2D & p1 = origin, const Point2D & p2 = origin, const Point2D & p3 = origin) : v1 (p1), v2 (p2), v3 (p3) {} // tests bool contains (const Point2D &) const; float area () const; int orientation () const; // Comparison operators bool operator== (const Triangle2D & t) const; bool operator!= (const Triangle2D & t) const; bool operator> (const Triangle2D &) const; bool operator< (const Triangle2D &) const; private: Point2D v1, v2, v3; float signed_area () const; }; inline int turn (const Point2D & p1, const Point2D & p2, const Point2D & p3) { return Triangle2D(p1,p2,p3).orientation(); } #endif
[ "vdelage@3806491c-8dad-11de-9a8c-6d5b7d1e4d13" ]
[ [ [ 1, 73 ] ] ]
7f7dd120a1f0da1c2530581f10c8159e0af12d55
5dd0d48b279823c791ba070e1db53f0137055c29
/NidSubNid.h
596aee386908d87597001df4c40f06a467c6825c
[]
no_license
ralex1975/pstviewtool
4b93349cf54ac7d93abbe199462f7eada44c752e
52f59893ad4390358053541b0257b4a7f2767024
refs/heads/master
2020-05-22T01:53:13.553501
2010-02-16T22:52:47
2010-02-16T22:52:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
428
h
#pragma once // CNidSubNid dialog class CNidSubNid : public CDialog { DECLARE_DYNAMIC(CNidSubNid) public: CNidSubNid(CWnd* pParent = NULL); // standard constructor virtual ~CNidSubNid(); // Dialog Data enum { IDD = IDD_DIALOG3 }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: CString m_nid; public: CString m_subnid; };
[ "terrymah@localhost" ]
[ [ [ 1, 25 ] ] ]
33005519c85dc0b66f7097387641509f08e40688
b505ef7eb1a6c58ebcb73267eaa1bad60efb1cb2
/sample/0190graphicsconfigtest/checkbox.h
e7a20556f9bf092469bab5710df1b68185310f78
[]
no_license
roxygen/maid2
230319e05d6d6e2f345eda4c4d9d430fae574422
455b6b57c4e08f3678948827d074385dbc6c3f58
refs/heads/master
2021-01-23T17:19:44.876818
2010-07-02T02:43:45
2010-07-02T02:43:45
38,671,921
0
0
null
null
null
null
UTF-8
C++
false
false
1,202
h
#ifndef sample_0190graphicsconfigtest_checkbox_h #define sample_0190graphicsconfigtest_checkbox_h #include"../../source/config/define.h" #include"../../source/framework/gui.h" #include"../../source/auxiliary/collision.h" #include"../../source/graphics/font.h" #include"../../source/graphics/graphics2drender.h" class CheckBox : public Maid::IGUICheckBox { public: void Initialize( Maid::Graphics2DRender* r, const Maid::String& Text, const Maid::SIZE2DI& size ); protected: virtual void OnInitialize( ID id, const IGUIParts& Parent ); virtual void OnFinalize(); virtual bool LocalIsCollision( const Maid::POINT2DI& pos )const; virtual void OnUpdateFrame(); virtual void OnUpdateDraw( const Maid::RenderTargetBase& Target, const Maid::IDepthStencil& Depth, const Maid::POINT2DI& pos ); virtual void OnMouseMove( const Maid::POINT2DI& pos ); virtual void OnMouseIn( const Maid::POINT2DI& pos ); virtual void OnMouseOut( const Maid::POINT2DI& pos ); virtual void OnStateChange( bool IsCheck ); private: Maid::Graphics2DRender* m_pRender; Maid::SIZE2DI m_Size; Maid::Font m_hFont; Maid::String m_Text; }; #endif
[ [ [ 1, 36 ] ] ]
3ba6d7ed3c7c6e37a0fe7a06fe92d2b5e6d5f8e5
5ac13fa1746046451f1989b5b8734f40d6445322
/minimangalore/Nebula2/code/contrib/nmap/src/map/nimagefile.cc
0f8113c06158a32ed167c893f888f06f03601b38
[]
no_license
moltenguy1/minimangalore
9f2edf7901e7392490cc22486a7cf13c1790008d
4d849672a6f25d8e441245d374b6bde4b59cbd48
refs/heads/master
2020-04-23T08:57:16.492734
2009-08-01T09:13:33
2009-08-01T09:13:33
35,933,330
0
0
null
null
null
null
UTF-8
C++
false
false
5,078
cc
//------------------------------------------------------------------- // nimagefile.cc // (C) 1999 A.Weissflog //------------------------------------------------------------------- #include <string.h> #include "map/nimagefile.h" //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- nImageFile::nImageFile() { this->fp = NULL; this->width = 0; this->height = 0; this->pf = NULL; this->acc_mode = N_NONE; } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- nImageFile::~nImageFile() { n_assert(NULL == this->fp); n_assert(NULL == this->pf); } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- bool nImageFile::Open(const char *fname, const char *mode) { n_assert(fname); n_assert(mode); n_assert(NULL == this->fp); this->fp = fopen(fname,mode); if (this->fp) { if (strchr(mode,'w')) this->acc_mode = N_WRITE; else this->acc_mode = N_READ; return true; } else { this->acc_mode = N_NONE; n_printf("nImageFile::Open(): could not open '%s' with mode '%s'\n",fname,mode); return false; } } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- void nImageFile::Close(void) { if (this->pf) { n_delete(this->pf); this->pf = NULL; } if (this->fp) { fclose(this->fp); this->fp = NULL; } this->acc_mode = N_NONE; } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- bool nImageFile::IsOpen(void) { return (this->acc_mode == N_NONE) ? false : true; } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- void nImageFile::SetWidth(int w) { this->width = w; } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- int nImageFile::GetWidth(void) { return this->width; } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- void nImageFile::SetHeight(int h) { this->height = h; } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- int nImageFile::GetHeight(void) { return this->height; } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- void nImageFile::SetPixelFormat(int bpp, nPalEntry *pal) { n_assert(NULL == this->pf); this->pf = n_new(nPixelFormat(bpp, pal)); } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- void nImageFile::SetPixelFormat(int bpp, int r_mask, int g_mask, int b_mask, int a_mask) { n_assert(NULL == this->pf); this->pf = n_new(nPixelFormat(bpp, r_mask, g_mask, b_mask, a_mask)); } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- nPixelFormat *nImageFile::GetPixelFormat(void) { n_assert(this->pf); return this->pf; } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- uchar *nImageFile::ReadLine(int&) { n_error("nImageFile::ReadLine(): Pure virtual function called!\n"); return NULL; } //------------------------------------------------------------------- /** - 17-Dec-99 floh created */ //------------------------------------------------------------------- int nImageFile::WriteLine(uchar *) { n_error("nImageFile::WriteLine(): Pure virtual function called!\n"); return 0; } //------------------------------------------------------------------- // EOF //-------------------------------------------------------------------
[ "BawooiT@d1c0eb94-fc07-11dd-a7be-4b3ef3b0700c" ]
[ [ [ 1, 181 ] ] ]
d4bf0effe4d8b5f93131840d1013c466fcadc93a
8a3fce9fb893696b8e408703b62fa452feec65c5
/CTimer/CTimer/Timer.cpp
5bd95b90391869267ea5422181b76a6e43f7f07f
[]
no_license
win18216001/tpgame
bb4e8b1a2f19b92ecce14a7477ce30a470faecda
d877dd51a924f1d628959c5ab638c34a671b39b2
refs/heads/master
2021-04-12T04:51:47.882699
2011-03-08T10:04:55
2011-03-08T10:04:55
42,728,291
0
2
null
null
null
null
GB18030
C++
false
false
4,705
cpp
#include "stdafx.h" #include "Timer.h" #include <iostream> CTimer::CTimer(void) { m_tv1 = new CLinkList( ebitsize ); m_tv2 = new CLinkList( sbitsize ); m_tv3 = new CLinkList( sbitsize ); m_tv4 = new CLinkList( sbitsize ); m_tv5 = new CLinkList( sbitsize ); } CTimer::CTimer(int second) { m_tv1 = new CLinkList( ebitsize ); m_tv2 = new CLinkList( sbitsize ); m_tv3 = new CLinkList( sbitsize ); m_tv4 = new CLinkList( sbitsize ); m_tv5 = new CLinkList( sbitsize ); m_mSecond = second; Init( m_mSecond ); } void CTimer::Init(int second ) { m_jeffies = m_Lasttime = GetCurrSystemTime(); if( second > 0 ) m_mSecond = second; m_tv1->init(); m_tv2->init(); m_tv3->init(); m_tv4->init(); m_tv5->init(); g_vecs = new CLinkList * [ lnum ]; //for( int i = 1 ; i <= lnum ; i++ ) ListProp(g_vecs,m_tv,1); ListProp(g_vecs,m_tv,2); ListProp(g_vecs,m_tv,3); ListProp(g_vecs,m_tv,4); ListProp(g_vecs,m_tv,5); } CTimer::~CTimer(void) { SAFE_DELETE( m_tv1 ); SAFE_DELETE( m_tv2 ); SAFE_DELETE( m_tv3 ); SAFE_DELETE( m_tv4 ); SAFE_DELETE( m_tv5 ); SAFE_ARR_DELETE( g_vecs); } void CTimer::add_timer(timernode *times) { if ( !check_timer(times) ) return ; /// hash到轮子 ulong expires = (times->etime - m_jeffies) / m_mSecond; CLinkList* lve = NULL; ListNode * lvec= NULL; int idx = 0 ; if( expires < ebitsize ) { idx = ( expires + m_tv1->GetIndex() ) & eMask; lvec= m_tv1->GetNode( idx ); lve = m_tv1; } else if ( expires < ( 1<< (sbits+ebits) ) ) { idx = ( (expires>>ebits) + m_tv2->GetIndex() ) & sMask; lvec = m_tv2->GetNode( idx ); lve = m_tv2; } else if ( expires < ( 1<< (2*sbits+ebits) ) ) { idx = ( (expires>>(sbits+ebits)) + m_tv3->GetIndex() ) & sMask; lvec = m_tv3->GetNode( idx ); lve = m_tv3; } else if ( expires < ( 1<< (3*sbits+ebits) )) { idx = ( (expires>>(2*sbits+ebits)) + m_tv4->GetIndex() ) & sMask; lvec = m_tv4->GetNode( idx ); lve = m_tv4; } else if ( expires < 0xffffffffUL ) { idx = ( (expires>>(3*sbits+ebits)) + m_tv5->GetIndex() ) & sMask; lvec = m_tv5->GetNode( idx ); m_tv1->insert_tail(&times->tlist , lvec ); lve = m_tv5; } if( lve !=NULL && lvec != NULL ) lve->insert_tail(&times->tlist , lvec ); } bool CTimer::check_timer(timernode *times) { return times->tlist.next /*== times->tlist.prev */!= NULL; } bool CTimer::delete_timer(CLinkList* list, timernode *times) { if ( !check_timer(times)) return false; list->list_del( &times->tlist ); init_timer(times); return true; } void CTimer::init_timer(timernode *timers) { timers->tlist.next = timers->tlist.prev = NULL; } void CTimer::Cancel(timernode *timers) { //delete_timer( timers ); } void CTimer::Expires(ulong jeffies) { long Count = ( jeffies - m_jeffies ) / m_mSecond; long tCount= Count; while ( Count >= 0 ) { ListNode *head ,*curr , *next; head = m_tv1->GetNode( m_tv1->GetIndex() ); curr = head->next; while ( curr != head ) { timernode* timer; next = curr->next; timer= (timernode*)( (char*)curr - offsetof(timernode,tlist)); void* fun = timer->pFun; static_cast<CGameEvent*>(fun)->TimeOut( timer->eType ); /// 定时器触发 delete_timer(m_tv1,timer); /// 如果是循环定时器 if ( timer->expires > 0) { /// 重新增加 /// add_timer( timer ); } else { /// 删除 SAFE_DELETE(timer); } curr = next; } Count --; if ( m_jeffies + m_mSecond <= jeffies && tCount > 0) { m_jeffies +=m_mSecond; m_tv1->SetIndex( (m_tv1->GetIndex() + 1) & eMask ); /// 旋转一周,更新后面的轮子 if ( m_tv1->GetIndex() == 0 ) { int n = 1; do { cascade_timer( g_vecs[n] ); std::cout <<" 第 "<< n+1 <<" 个轮子,索引 " << g_vecs[n]->GetIndex() <<" 转动" << std::ends; } while ( g_vecs[n]->GetIndex() == 0 && ++n < lnum); } } } } void CTimer::cascade_timer(CLinkList* tlist) { ListNode *head ,*curr,*next; head = tlist->GetNode( tlist->GetIndex() ); curr = head->next; while ( curr != head ) { timernode* tmp = (timernode*)( (char*)curr - offsetof(timernode,tlist)); next = curr->next; tlist->list_del( curr ); Mod_timer( tmp ); curr = next; } tlist->init_list_self( tlist->GetIndex() ); tlist->SetIndex( ( tlist->GetIndex() + 1 ) & sMask ); } void CTimer::Mod_timer(timernode *timers) { int ret = 0 ; if ( timers->etime < m_jeffies) timers->etime = m_jeffies; add_timer(timers); }
[ [ [ 1, 220 ] ] ]
b630a825e2fe390181adb7d804537cfee3a45474
28aa23d9cb8f5f4e8c2239c70ef0f8f6ec6d17bc
/mytesgnikrow --username hotga2801/Project/AdaboostFaceDetection/AdaboostFaceDetection/AdaboostFaceDetection.h
93dc966b77f618558d05579d69333f6849c457d3
[]
no_license
taicent/mytesgnikrow
09aed8836e1297a24bef0f18dadd9e9a78ec8e8b
9264faa662454484ade7137ee8a0794e00bf762f
refs/heads/master
2020-04-06T04:25:30.075548
2011-02-17T13:37:16
2011-02-17T13:37:16
34,991,750
0
0
null
null
null
null
UTF-8
C++
false
false
594
h
// AdaboostFaceDetection.h : main header file for the PROJECT_NAME application // #pragma once #ifndef __AFXWIN_H__ #error "include 'stdafx.h' before including this file for PCH" #endif #include "resource.h" // main symbols // CAdaboostFaceDetectionApp: // See AdaboostFaceDetection.cpp for the implementation of this class // class CAdaboostFaceDetectionApp : public CWinApp { public: CAdaboostFaceDetectionApp(); // Overrides public: virtual BOOL InitInstance(); // Implementation DECLARE_MESSAGE_MAP() }; extern CAdaboostFaceDetectionApp theApp;
[ "hotga2801@ecd9aaca-b8df-3bf4-dfa7-576663c5f076" ]
[ [ [ 1, 31 ] ] ]
4a4576d1182ae90ad5a2e572b140c721c0baef67
2fdbf2ba994ba3ed64f0e2dc75cd2dfce4936583
/spectre/data/methodelement.h
592061082d787d5ae1bb9ca5cffa0b8aa5ffadb6
[]
no_license
TERRANZ/terragraph
36219a4e512e15a925769512a6b60637d39830bf
ea8c36070f532ad0a4af08e46b19f4ee1b85f279
refs/heads/master
2020-05-25T10:31:26.994233
2011-01-29T21:23:04
2011-01-29T21:23:04
1,047,237
0
0
null
null
null
null
UTF-8
C++
false
false
1,185
h
#ifndef METHODELEMENT_H #define METHODELEMENT_H #include "base.h" class MethodElement: public Base { public: enum ElementType { Condition = 0, Send, Activate, None //на всякий случай, хотя в терии нереальный }; public: MethodElement(const DomElement &domElement = DomElement(), XmlData *xmlData = 0); ElementType elementType(); void setElementType(ElementType type); string id() const; string method() const; string port() const; float x() const; float y() const; string rem() const; void setId(string value); void setMethod(string value); void setPort(string value); void setX(float value); void setY(float value); void setRem(string value); // Method parent() const; static const string CONDITION_NAME; static const string SEND_NAME; static const string ACTIVATE_NAME; static const string ID; static const string METHOD; static const string PORT; static const string X; static const string Y; static const string REM; }; #endif // METHODELEMENT_H
[ [ [ 1, 50 ] ] ]
0c308c0d634d4360c501c77df3b3f4444e3db0d9
21da454a8f032d6ad63ca9460656c1e04440310e
/src/wcpp/lang/wscInteger.cpp
089c99e2c25460e4ef0716d85bccba0a9000b1b4
[]
no_license
merezhang/wcpp
d9879ffb103513a6b58560102ec565b9dc5855dd
e22eb48ea2dd9eda5cd437960dd95074774b70b0
refs/heads/master
2021-01-10T06:29:42.908096
2009-08-31T09:20:31
2009-08-31T09:20:31
46,339,619
0
0
null
null
null
null
UTF-8
C++
false
false
899
cpp
#include "wscInteger.h" #include "wscLong.h" ws_int wscInteger::ParseInt(wsiString *s) { ws_long lo = wscLong::ParseLong(s); return static_cast<ws_int>(lo); } WS_IMPL_ClassName_OF( wscInteger ) wscInteger::wscInteger(wsiString * s) : m_value(0) { m_value = ParseInt(s); } wscInteger::wscInteger(ws_int n) : m_value(n) { } wscInteger::~wscInteger(void) { } ws_byte wscInteger::ByteValue(void) { return static_cast<ws_byte>(m_value); } ws_double wscInteger::DoubleValue(void) { return m_value; } ws_float wscInteger::FloatValue(void) { return static_cast<ws_float>(m_value); } ws_int wscInteger::IntValue(void) { return m_value; } ws_long wscInteger::LongValue(void) { return m_value; } ws_short wscInteger::ShortValue(void) { return static_cast<ws_short>(m_value); }
[ "xukun0217@98f29a9a-77f1-11de-91f8-ab615253d9e8" ]
[ [ [ 1, 65 ] ] ]
324f887a7e1f7b875aaa382c6b2e55fcc00e095d
9340e21ef492eec9f19d1e4ef2ef33a19354ca6e
/cing/src/graphics/Window.h
ef6a4f1fb94369cde0d9b68907c072033218d422
[]
no_license
jamessqr/Cing
e236c38fe729fd9d49ccd1584358eaad475f7686
c46045d9d0c2b4d9e569466971bbff1662be4e7a
refs/heads/master
2021-01-17T22:55:17.935520
2011-05-14T18:35:30
2011-05-14T18:35:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,708
h
/* This source file is part of the Cing project For the latest info, see http://www.cing.cc Copyright (c) 2006-2009 Julio Obelleiro and Jorge Cano This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _Window_H_ #define _Window_H_ // Precompiled headers #include "Cing-Precompiled.h" #include "GraphicsPrereqs.h" #include "graphics/Color.h" // OGRE #include "OgreRenderTarget.h" namespace Cing { /** * @internal * Represents a rendering window with an associated camera. * It is also a wrapper around the Ogre window class. */ class Window { public: // Public structures /** * @internal * Contains the information of the window metrics */ struct TWindowMetrics { unsigned int width; unsigned int height; unsigned int colourDepth; int left; int top; }; // Constructor / Destructor Window (); ~Window (); // Init / Release / Update bool init ( Ogre::RenderWindow* pOgreWindow ); void end (); void update (); // Query methods bool isValid () const { return m_bIsValid; } bool isClosed () const; bool isFullScreen () const; int getWidth () const { return m_width; } int getHeight () const { return m_height; } void getMetrics ( TWindowMetrics& metrics ) const; size_t getWindowHandle () const; const Ogre::RenderTarget::FrameStats& getFrameStats () const { return *m_stats; } Ogre::RenderWindow* getOgreWindow () { return m_pOgreWindow; } const Ogre::ColourValue& getBackgroundColor (); Ogre::Viewport* getMainViewport () { return m_mainViewport; } Ogre::Viewport* getViewport ( int index = 0 ); // Various void attachCameraToWindow ( Camera3D& camera, int viewportIndex = 0 ); void attachCameraToWindow ( Ogre::Camera* ogreCamera, int viewportIndex = 0); void setBackgroundColor ( const Color& color ); private: // Attributes Ogre::RenderWindow* m_pOgreWindow; ///< Ogre window Ogre::Viewport* m_mainViewport; ///< Window viewport const Ogre::RenderTarget::FrameStats* m_stats; ///< Window render statistics int m_width, m_height; ///< Window size bool m_bIsValid; ///< Indicates whether the class is valid or not. If invalid none of its methods except init should be called. }; } // namespace Cing #endif // _Window_H_
[ [ [ 1, 28 ], [ 30, 101 ] ], [ [ 29, 29 ] ] ]
0909fe53cbc331b71afe0ab9777116335aaa1282
037faae47a5b22d3e283555e6b5ac2a0197faf18
/pcsx2v2/x86/ix86-32/iR5900LoadStore.cpp
e689e1f0c67e84bb0ab5862ce61b1477eb968a3c
[]
no_license
isabella232/pcsx2-sourceforge
6e5aac8d0b476601bfc8fa83ded66c1564b8c588
dbb2c3a010081b105a8cba0c588f1e8f4e4505c6
refs/heads/master
2023-03-18T22:23:15.102593
2008-11-17T20:10:17
2008-11-17T20:10:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
110,352
cpp
/* Pcsx2 - Pc Ps2 Emulator * Copyright (C) 2002-2008 Pcsx2 Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include <stdlib.h> #include <string.h> #include <assert.h> #include "Common.h" #include "InterTables.h" #include "ix86/ix86.h" #include "iR5900.h" #ifdef _WIN32 #pragma warning(disable:4244) #pragma warning(disable:4761) #endif /********************************************************* * Load and store for GPR * * Format: OP rt, offset(base) * *********************************************************/ #ifndef LOADSTORE_RECOMPILE REC_FUNC(LB); REC_FUNC(LBU); REC_FUNC(LH); REC_FUNC(LHU); REC_FUNC(LW); REC_FUNC(LWU); REC_FUNC(LWL); REC_FUNC(LWR); REC_FUNC(LD); REC_FUNC(LDR); REC_FUNC(LDL); REC_FUNC(LQ); REC_FUNC(SB); REC_FUNC(SH); REC_FUNC(SW); REC_FUNC(SWL); REC_FUNC(SWR); REC_FUNC(SD); REC_FUNC(SDL); REC_FUNC(SDR); REC_FUNC(SQ); REC_FUNC(LWC1); REC_FUNC(SWC1); REC_FUNC(LQC2); REC_FUNC(SQC2); void SetFastMemory(int bSetFast) {} #else PCSX2_ALIGNED16(u64 retValues[2]); extern u32 maxrecmem; static u32 s_bCachingMem = 0; static u32 s_nAddMemOffset = 0; static u32 s_tempaddr = 0; void _eeOnLoadWrite(int reg) { int regt; if( !reg ) return; _eeOnWriteReg(reg, 1); regt = _checkXMMreg(XMMTYPE_GPRREG, reg, MODE_READ); if( regt >= 0 ) { if( xmmregs[regt].mode & MODE_WRITE ) { if( cpucaps.hasStreamingSIMD2Extensions && (reg != _Rs_) ) { SSE2_PUNPCKHQDQ_XMM_to_XMM(regt, regt); SSE2_MOVQ_XMM_to_M64((u32)&cpuRegs.GPR.r[reg].UL[2], regt); } else SSE_MOVHPS_XMM_to_M64((u32)&cpuRegs.GPR.r[reg].UL[2], regt); } xmmregs[regt].inuse = 0; } } #ifdef PCSX2_VIRTUAL_MEM extern void iMemRead32Check(); #define _Imm_co_ (*(s16*)PSM(pc)) // perf counters #ifdef PCSX2_DEVBUILD extern void StartPerfCounter(); extern void StopPerfCounter(); #else #define StartPerfCounter() #define StopPerfCounter() #endif //////////////////////////////////////////////////// //#define REC_SLOWREAD //#define REC_SLOWWRITE #define REC_FORCEMMX 0 // if sp, always mem write int _eeIsMemWrite() { return _Rs_==29||_Rs_== 31||_Rs_==26||_Rs_==27; } // sp, ra, k0, k1 // gp can be 1000a020 (jak1) void recTransferX86ToReg(int x86reg, int gprreg, int sign) { //if( !REC_FORCEMMX ) assert( _checkMMXreg(MMX_GPR+gprreg, MODE_WRITE) == -1 ); if( sign ) { if( x86reg == EAX && EEINST_ISLIVE1(gprreg) ) CDQ(); MOV32RtoM( (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ], x86reg ); if(EEINST_ISLIVE1(gprreg)) { if( x86reg == EAX ) MOV32RtoM( (int)&cpuRegs.GPR.r[ gprreg ].UL[ 1 ], EDX ); else { SAR32ItoR(x86reg, 31); MOV32RtoM( (int)&cpuRegs.GPR.r[ gprreg ].UL[ 1 ], x86reg ); } } else { EEINST_RESETHASLIVE1(gprreg); } } else { MOV32RtoM( (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ], x86reg ); if(EEINST_ISLIVE1(gprreg)) MOV32ItoM( (int)&cpuRegs.GPR.r[ gprreg ].UL[ 1 ], 0 ); else EEINST_RESETHASLIVE1(gprreg); } } #ifdef _DEBUG void testaddrs() { register int tempaddr; __asm mov tempaddr, ecx //__asm mov incaddr, edx assert( (tempaddr < 0x40000000) || (tempaddr&0xd0000000)==0x50000000 || (tempaddr >= 0x80000000 && tempaddr < 0xc0000000) ); //assert( (tempaddr>>28) == ((tempaddr+incaddr)>>28) ); __asm mov ecx, tempaddr } #endif #define SET_HWLOC() { \ if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[2]); \ else x86SetJ8(j8Ptr[0]); \ if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[3]); \ else x86SetJ8(j8Ptr[3]); \ if (x86FpuState==MMX_STATE) { \ if (cpucaps.has3DNOWInstructionExtensions) FEMMS(); \ else EMMS(); \ } \ if( s_nAddMemOffset ) ADD32ItoR(ECX, s_nAddMemOffset); \ if( s_bCachingMem & 4 ) AND32ItoR(ECX, 0x5fffffff); \ } \ static u16 g_MemMasks0[16] = {0x00f0, 0x80f1, 0x00f2, 0x00f3, 0x00f1, 0x00f5, 0x00f1, 0x00f5, 0x00f5, 0x80f5, 0x00f5, 0x80f5, 0x00f1, 0x00f1, 0x00f1, 0x00f5 }; static u16 g_MemMasks8[16] = {0x0080, 0x8081, 0x0082, 0x0083, 0x0081, 0x0085, 0x0081, 0x0085, 0x0085, 0x8085, 0x0085, 0x8085, 0x0081, 0x0081, 0x0081, 0x0085 }; static u16 g_MemMasks16[16] ={0x0000, 0x8001, 0x0002, 0x0003, 0x0001, 0x0005, 0x0001, 0x0005, 0x0005, 0x8005, 0x0005, 0x8005, 0x0001, 0x0001, 0x0001, 0x0005 }; static int s_bFastMemory = 0; void SetFastMemory(int bSetFast) { s_bFastMemory = bSetFast; if( bSetFast) { g_MemMasks0[0] = 0x00f0; g_MemMasks0[1] = 0x80f1; g_MemMasks0[2] = 0x00f0; g_MemMasks0[3] = 0x00f1; g_MemMasks8[0] = 0x0080; g_MemMasks8[1] = 0x8081; g_MemMasks8[2] = 0x0080; g_MemMasks8[3] = 0x0081; g_MemMasks16[0] = 0x0000; g_MemMasks16[1] = 0x8001; g_MemMasks16[2] = 0x0000; g_MemMasks16[3] = 0x0001; } else { g_MemMasks0[0] = 0x00f0; g_MemMasks0[1] = 0x80f1; g_MemMasks0[2] = 0x00f2; g_MemMasks0[3] = 0x00f3; g_MemMasks8[0] = 0x0080; g_MemMasks8[1] = 0x8081; g_MemMasks8[2] = 0x0082; g_MemMasks8[3] = 0x0083; g_MemMasks16[0] = 0x0000; g_MemMasks16[1] = 0x8001; g_MemMasks16[2] = 0x0002; g_MemMasks16[3] = 0x0003; } } void assertmem() { __asm mov s_tempaddr, ecx __asm mov s_bCachingMem, edx SysPrintf("%x(%x) not mem write!\n", s_tempaddr, s_bCachingMem); assert(0); } int _eePrepareReg(int gprreg) { int mmreg = _checkXMMreg(XMMTYPE_GPRREG, gprreg, MODE_READ); if( mmreg >= 0 && (xmmregs[mmreg].mode&MODE_WRITE) ) { mmreg |= MEM_XMMTAG; } else if( (mmreg = _checkMMXreg(MMX_GPR+gprreg, MODE_READ)) >= 0 ) { if( mmxregs[mmreg].mode&MODE_WRITE ) mmreg |= MEM_MMXTAG; else { mmxregs[mmreg].needed = 0; // coX can possibly use all regs mmreg = 0; } } else { mmreg = 0; } return mmreg; } int _eePrepareReg_coX(int gprreg, int num) { int mmreg = _eePrepareReg(gprreg); if( (mmreg&MEM_MMXTAG) && num == 7 ) { if( mmxregs[mmreg&0xf].mode & MODE_WRITE ) { MOVQRtoM((u32)&cpuRegs.GPR.r[gprreg], mmreg&0xf); mmxregs[mmreg&0xf].mode &= ~MODE_WRITE; mmxregs[mmreg&0xf].needed = 0; } } return mmreg; } // returns true if should also include harware writes int recSetMemLocation(int regs, int imm, int mmreg, int msize, int j32) { s_bCachingMem = j32 ? 2 : 0; s_nAddMemOffset = 0; //int num; if( mmreg >= 0 && (mmreg & MEM_XMMTAG) ) { SSE2_MOVD_XMM_to_R(ECX, mmreg&0xf); } else if( mmreg >= 0 && (mmreg & MEM_MMXTAG) ) { MOVD32MMXtoR(ECX, mmreg&0xf); SetMMXstate(); } else { MOV32MtoR( ECX, (int)&cpuRegs.GPR.r[ regs ].UL[ 0 ] ); } if ( imm != 0 ) ADD32ItoR( ECX, imm ); LoadCW(); #ifdef _DEBUG //CALLFunc((u32)testaddrs); #endif // 32bit version (faster?) // MOV32RtoR(EAX, ECX); // ROR32ItoR(ECX, 28); // SHR32ItoR(EAX, 28); // MOV32RmSOffsettoR(EAX, EAX, msize == 2 ? (u32)&g_MemMasks16[0] : (msize == 1 ? (u32)&g_MemMasks8[0] : (u32)&g_MemMasks0[0]), 2); // AND8RtoR(ECX, EAX); // ROR32ItoR(ECX, 4); // // do extra alignment masks here // OR32RtoR(EAX, EAX); if( _eeIsMemWrite() ) { u8* ptr; CMP32ItoR(ECX, 0x40000000); ptr = JB8(0); if( msize == 1 ) AND32ItoR(ECX, 0x5ffffff8); else if( msize == 2 ) AND32ItoR(ECX, 0x5ffffff0); else AND32ItoR(ECX, 0x5fffffff); x86SetJ8(ptr); if( msize == 1 ) AND8ItoR(ECX, 0xf8); else if( msize == 2 ) AND8ItoR(ECX, 0xf0); #ifdef _DEBUG MOV32RtoR(EAX, ECX); SHR32ItoR(EAX, 28); CMP32ItoR(EAX, 1); ptr = JNE8(0); MOV32ItoR(EDX, _Rs_); CALLFunc((u32)assertmem); x86SetJ8(ptr); #endif return 0; } else { // 16 bit version MOV32RtoR(EAX, ECX); ROR32ItoR(ECX, 28); SHR32ItoR(EAX, 28); MOV16RmSOffsettoR(EAX, EAX, msize == 2 ? (u32)&g_MemMasks16[0] : (msize == 1 ? (u32)&g_MemMasks8[0] : (u32)&g_MemMasks0[0]), 1); AND8RtoR(ECX, EAX); ROR32ItoR(ECX, 4); OR16RtoR(EAX, EAX); if( s_bCachingMem & 2 ) j32Ptr[2] = j32Ptr[3] = JS32(0); else j8Ptr[0] = j8Ptr[3] = JS8(0); } return 1; } void recLoad32(u32 bit, u32 imm, u32 sign) { int mmreg = -1; #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { // do const processing int ineax = 0; _eeOnLoadWrite(_Rt_); if( bit == 32 ) { mmreg = _allocCheckGPRtoMMX(g_pCurInstInfo, _Rt_, MODE_WRITE); if( mmreg >= 0 ) mmreg |= MEM_MMXTAG; else mmreg = EAX; } else { _deleteEEreg(_Rt_, 0); mmreg = EAX; } switch(bit) { case 8: ineax = recMemConstRead8(mmreg, g_cpuConstRegs[_Rs_].UL[0]+imm, sign); break; case 16: assert( (g_cpuConstRegs[_Rs_].UL[0]+imm) % 2 == 0 ); ineax = recMemConstRead16(mmreg, g_cpuConstRegs[_Rs_].UL[0]+imm, sign); break; case 32: // used by LWL/LWR //assert( (g_cpuConstRegs[_Rs_].UL[0]+imm) % 4 == 0 ); ineax = recMemConstRead32(mmreg, g_cpuConstRegs[_Rs_].UL[0]+imm); break; } if( ineax || !(mmreg&MEM_MMXTAG) ) { if( mmreg&MEM_MMXTAG ) mmxregs[mmreg&0xf].inuse = 0; recTransferX86ToReg(EAX, _Rt_, sign); } else { assert( mmxregs[mmreg&0xf].mode & MODE_WRITE ); if( sign ) _signExtendGPRtoMMX(mmreg&0xf, _Rt_, 32-bit); else if( bit < 32 ) PSRLDItoR(mmreg&0xf, 32-bit); } } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); _eeOnLoadWrite(_Rt_); if( REC_FORCEMMX ) mmreg = _allocCheckGPRtoMMX(g_pCurInstInfo, _Rt_, MODE_WRITE); else _deleteEEreg(_Rt_, 0); dohw = recSetMemLocation(_Rs_, imm, mmregs, 0, 0); if( mmreg >= 0 ) { MOVD32RmOffsettoMMX(mmreg, ECX, PS2MEM_BASE_+s_nAddMemOffset-(32-bit)/8); if( sign ) _signExtendGPRtoMMX(mmreg&0xf, _Rt_, 32-bit); else if( bit < 32 ) PSRLDItoR(mmreg&0xf, 32-bit); } else { switch(bit) { case 8: if( sign ) MOVSX32Rm8toROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); else MOVZX32Rm8toROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); break; case 16: if( sign ) MOVSX32Rm16toROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); else MOVZX32Rm16toROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); break; case 32: MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); break; } if ( _Rt_ ) recTransferX86ToReg(EAX, _Rt_, sign); } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); switch(bit) { case 8: CALLFunc( (int)recMemRead8 ); if( sign ) MOVSX32R8toR(EAX, EAX); else MOVZX32R8toR(EAX, EAX); break; case 16: CALLFunc( (int)recMemRead16 ); if( sign ) MOVSX32R16toR(EAX, EAX); else MOVZX32R16toR(EAX, EAX); break; case 32: iMemRead32Check(); CALLFunc( (int)recMemRead32 ); break; } if ( _Rt_ ) recTransferX86ToReg(EAX, _Rt_, sign); if( mmreg >= 0 ) { if( EEINST_ISLIVE1(_Rt_) ) MOVQMtoR(mmreg, (u32)&cpuRegs.GPR.r[_Rt_]); else MOVD32RtoMMX(mmreg, EAX); } if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } } } void recLoad32_co(u32 bit, u32 sign) { int nextrt = ((*(u32*)(PSM(pc)) >> 16) & 0x1F); int mmreg1 = -1, mmreg2 = -1; #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { int ineax = 0; u32 written = 0; _eeOnLoadWrite(_Rt_); _eeOnLoadWrite(nextrt); if( bit == 32 ) { mmreg1 = _allocCheckGPRtoMMX(g_pCurInstInfo, _Rt_, MODE_WRITE); if( mmreg1 >= 0 ) mmreg1 |= MEM_MMXTAG; else mmreg1 = EBX; mmreg2 = _allocCheckGPRtoMMX(g_pCurInstInfo+1, nextrt, MODE_WRITE); if( mmreg2 >= 0 ) mmreg2 |= MEM_MMXTAG; else mmreg2 = EAX; } else { _deleteEEreg(_Rt_, 0); _deleteEEreg(nextrt, 0); mmreg1 = EBX; mmreg2 = EAX; } // do const processing switch(bit) { case 8: if( recMemConstRead8(mmreg1, g_cpuConstRegs[_Rs_].UL[0]+_Imm_, sign) ) { if( mmreg1&MEM_MMXTAG ) mmxregs[mmreg1&0xf].inuse = 0; if ( _Rt_ ) recTransferX86ToReg(EAX, _Rt_, sign); written = 1; } ineax = recMemConstRead8(mmreg2, g_cpuConstRegs[_Rs_].UL[0]+_Imm_co_, sign); break; case 16: if( recMemConstRead16(mmreg1, g_cpuConstRegs[_Rs_].UL[0]+_Imm_, sign) ) { if( mmreg1&MEM_MMXTAG ) mmxregs[mmreg1&0xf].inuse = 0; if ( _Rt_ ) recTransferX86ToReg(EAX, _Rt_, sign); written = 1; } ineax = recMemConstRead16(mmreg2, g_cpuConstRegs[_Rs_].UL[0]+_Imm_co_, sign); break; case 32: assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_) % 4 == 0 ); if( recMemConstRead32(mmreg1, g_cpuConstRegs[_Rs_].UL[0]+_Imm_) ) { if( mmreg1&MEM_MMXTAG ) mmxregs[mmreg1&0xf].inuse = 0; if ( _Rt_ ) recTransferX86ToReg(EAX, _Rt_, sign); written = 1; } ineax = recMemConstRead32(mmreg2, g_cpuConstRegs[_Rs_].UL[0]+_Imm_co_); break; } if( !written && _Rt_ ) { if( mmreg1&MEM_MMXTAG ) { assert( mmxregs[mmreg1&0xf].mode & MODE_WRITE ); if( sign ) _signExtendGPRtoMMX(mmreg1&0xf, _Rt_, 32-bit); else if( bit < 32 ) PSRLDItoR(mmreg1&0xf, 32-bit); } else recTransferX86ToReg(mmreg1, _Rt_, sign); } if( nextrt ) { g_pCurInstInfo++; if( !ineax && (mmreg2 & MEM_MMXTAG) ) { assert( mmxregs[mmreg2&0xf].mode & MODE_WRITE ); if( sign ) _signExtendGPRtoMMX(mmreg2&0xf, nextrt, 32-bit); else if( bit < 32 ) PSRLDItoR(mmreg2&0xf, 32-bit); } else { if( mmreg2&MEM_MMXTAG ) mmxregs[mmreg2&0xf].inuse = 0; recTransferX86ToReg(mmreg2, nextrt, sign); } g_pCurInstInfo--; } } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); assert( !REC_FORCEMMX ); _eeOnLoadWrite(_Rt_); _eeOnLoadWrite(nextrt); _deleteEEreg(_Rt_, 0); _deleteEEreg(nextrt, 0); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 0, 0); switch(bit) { case 8: if( sign ) { MOVSX32Rm8toROffset(EBX, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOVSX32Rm8toROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } else { MOVZX32Rm8toROffset(EBX, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOVZX32Rm8toROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } break; case 16: if( sign ) { MOVSX32Rm16toROffset(EBX, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOVSX32Rm16toROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } else { MOVZX32Rm16toROffset(EBX, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOVZX32Rm16toROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } break; case 32: MOV32RmtoROffset(EBX, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); break; } if ( _Rt_ ) recTransferX86ToReg(EBX, _Rt_, sign); if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); switch(bit) { case 8: MOV32RtoM((u32)&s_tempaddr, ECX); CALLFunc( (int)recMemRead8 ); if( sign ) MOVSX32R8toR(EAX, EAX); MOV32MtoR(ECX, (u32)&s_tempaddr); if ( _Rt_ ) recTransferX86ToReg(EAX, _Rt_, sign); ADD32ItoR(ECX, _Imm_co_-_Imm_); CALLFunc( (int)recMemRead8 ); if( sign ) MOVSX32R8toR(EAX, EAX); break; case 16: MOV32RtoM((u32)&s_tempaddr, ECX); CALLFunc( (int)recMemRead16 ); if( sign ) MOVSX32R16toR(EAX, EAX); MOV32MtoR(ECX, (u32)&s_tempaddr); if ( _Rt_ ) recTransferX86ToReg(EAX, _Rt_, sign); ADD32ItoR(ECX, _Imm_co_-_Imm_); CALLFunc( (int)recMemRead16 ); if( sign ) MOVSX32R16toR(EAX, EAX); break; case 32: MOV32RtoM((u32)&s_tempaddr, ECX); iMemRead32Check(); CALLFunc( (int)recMemRead32 ); MOV32MtoR(ECX, (u32)&s_tempaddr); if ( _Rt_ ) recTransferX86ToReg(EAX, _Rt_, sign); ADD32ItoR(ECX, _Imm_co_-_Imm_); iMemRead32Check(); CALLFunc( (int)recMemRead32 ); break; } if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } if( nextrt ) { g_pCurInstInfo++; recTransferX86ToReg(EAX, nextrt, sign); g_pCurInstInfo--; } } } void recLB( void ) { recLoad32(8, _Imm_, 1); } void recLB_co( void ) { recLoad32_co(8, 1); } void recLBU( void ) { recLoad32(8, _Imm_, 0); } void recLBU_co( void ) { recLoad32_co(8, 0); } void recLH( void ) { recLoad32(16, _Imm_, 1); } void recLH_co( void ) { recLoad32_co(16, 1); } void recLHU( void ) { recLoad32(16, _Imm_, 0); } void recLHU_co( void ) { recLoad32_co(16, 0); } void recLW( void ) { recLoad32(32, _Imm_, 1); } void recLW_co( void ) { recLoad32_co(32, 1); } void recLWU( void ) { recLoad32(32, _Imm_, 0); } void recLWU_co( void ) { recLoad32_co(32, 0); } //////////////////////////////////////////////////// // paired with LWR void recLWL_co(void) { recLoad32(32, _Imm_-3, 1); } void recLWL( void ) { #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); recMemConstRead32(EAX, (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~3); if( _Rt_ ) { u32 shift = (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&3; _eeMoveGPRtoR(ECX, _Rt_); SHL32ItoR(EAX, 24-shift*8); AND32ItoR(ECX, (0xffffff>>(shift*8))); OR32RtoR(EAX, ECX); if ( _Rt_ ) recTransferX86ToReg(EAX, _Rt_, 1); } } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 0, 0); MOV32ItoR(EDX, 0x3); AND32RtoR(EDX, ECX); AND32ItoR(ECX, ~3); SHL32ItoR(EDX, 3); // *8 MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); if( dohw ) { j8Ptr[1] = JMP8(0); SET_HWLOC(); iMemRead32Check(); // repeat MOV32ItoR(EDX, 0x3); AND32RtoR(EDX, ECX); AND32ItoR(ECX, ~3); SHL32ItoR(EDX, 3); // *8 PUSH32R(EDX); CALLFunc( (int)recMemRead32 ); POP32R(EDX); x86SetJ8(j8Ptr[1]); } if ( _Rt_ ) { // mem << LWL_SHIFT[shift] MOV32ItoR(ECX, 24); SUB32RtoR(ECX, EDX); SHL32CLtoR(EAX); // mov temp and compute _rt_ & LWL_MASK[shift] MOV32RtoR(ECX, EDX); MOV32ItoR(EDX, 0xffffff); SAR32CLtoR(EDX); _eeMoveGPRtoR(ECX, _Rt_); AND32RtoR(EDX, ECX); // combine OR32RtoR(EAX, EDX); recTransferX86ToReg(EAX, _Rt_, 1); } } } //////////////////////////////////////////////////// // paired with LWL void recLWR_co(void) { recLoad32(32, _Imm_, 1); } void recLWR( void ) { #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); recMemConstRead32(EAX, (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~3); if( _Rt_ ) { u32 shift = (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&3; _eeMoveGPRtoR(ECX, _Rt_); SHL32ItoR(EAX, shift*8); AND32ItoR(ECX, (0xffffff00<<(24-shift*8))); OR32RtoR(EAX, ECX); recTransferX86ToReg(EAX, _Rt_, 1); } } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 0, 0); MOV32RtoR(EDX, ECX); AND32ItoR(ECX, ~3); MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); if( dohw ) { j8Ptr[1] = JMP8(0); SET_HWLOC(); iMemRead32Check(); PUSH32R(ECX); AND32ItoR(ECX, ~3); CALLFunc( (int)recMemRead32 ); POP32R(EDX); x86SetJ8(j8Ptr[1]); } if ( _Rt_ ) { // mem << LWL_SHIFT[shift] MOV32RtoR(ECX, EDX); AND32ItoR(ECX, 3); SHL32ItoR(ECX, 3); // *8 SHR32CLtoR(EAX); // mov temp and compute _rt_ & LWL_MASK[shift] MOV32RtoR(EDX, ECX); MOV32ItoR(ECX, 24); SUB32RtoR(ECX, EDX); MOV32ItoR(EDX, 0xffffff00); SHL32CLtoR(EDX); _eeMoveGPRtoR(ECX, _Rt_); AND32RtoR(ECX, EDX); // combine OR32RtoR(EAX, ECX); recTransferX86ToReg(EAX, _Rt_, 1); } } } //////////////////////////////////////////////////// void recLoad64(u32 imm, int align) { int mmreg; int mask = align ? ~7 : ~0; #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { // also used by LDL/LDR //assert( (g_cpuConstRegs[_Rs_].UL[0]+imm) % 8 == 0 ); mmreg = _allocCheckGPRtoMMX(g_pCurInstInfo, _Rt_, MODE_WRITE); if( _Rt_ && mmreg >= 0 ) { recMemConstRead64((g_cpuConstRegs[_Rs_].UL[0]+imm)&mask, mmreg); assert( mmxregs[mmreg&0xf].mode & MODE_WRITE ); } else if( _Rt_ && (mmreg = _allocCheckGPRtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE|MODE_READ)) >= 0 ) { recMemConstRead64((g_cpuConstRegs[_Rs_].UL[0]+imm)&mask, mmreg|0x8000); assert( xmmregs[mmreg&0xf].mode & MODE_WRITE ); } else { if( !_hasFreeMMXreg() && _hasFreeXMMreg() ) { mmreg = _allocGPRtoXMMreg(-1, _Rt_, MODE_READ|MODE_WRITE); recMemConstRead64((g_cpuConstRegs[_Rs_].UL[0]+imm)&mask, mmreg|0x8000); assert( xmmregs[mmreg&0xf].mode & MODE_WRITE ); } else { int t0reg = _allocMMXreg(-1, MMX_TEMP, 0); recMemConstRead64((g_cpuConstRegs[_Rs_].UL[0]+imm)&mask, t0reg); if( _Rt_ ) { SetMMXstate(); MOVQRtoM((u32)&cpuRegs.GPR.r[_Rt_].UD[0], t0reg); } _freeMMXreg(t0reg); } } } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); if( _Rt_ && (mmreg = _allocCheckGPRtoMMX(g_pCurInstInfo, _Rt_, MODE_WRITE)) >= 0 ) { dohw = recSetMemLocation(_Rs_, imm, mmregs, align, 0); MOVQRmtoROffset(mmreg, ECX, PS2MEM_BASE_+s_nAddMemOffset); if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ] ); CALLFunc( (int)recMemRead64 ); MOVQMtoR(mmreg, (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ]); ADD32ItoR(ESP, 4); } SetMMXstate(); } else if( _Rt_ && (mmreg = _allocCheckGPRtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE|MODE_READ)) >= 0 ) { dohw = recSetMemLocation(_Rs_, imm, mmregs, align, 0); SSE_MOVLPSRmtoROffset(mmreg, ECX, PS2MEM_BASE_+s_nAddMemOffset); if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ] ); CALLFunc( (int)recMemRead64 ); SSE_MOVLPS_M64_to_XMM(mmreg, (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ]); ADD32ItoR(ESP, 4); } } else { int t0reg = _Rt_ ? _allocMMXreg(-1, MMX_GPR+_Rt_, MODE_WRITE) : -1; dohw = recSetMemLocation(_Rs_, imm, mmregs, align, 0); if( t0reg >= 0 ) { MOVQRmtoROffset(t0reg, ECX, PS2MEM_BASE_+s_nAddMemOffset); SetMMXstate(); } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); if( _Rt_ ) { //_deleteEEreg(_Rt_, 0); PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ] ); } else PUSH32I( (int)&retValues[0] ); CALLFunc( (int)recMemRead64 ); ADD32ItoR(ESP, 4); if( t0reg >= 0 ) MOVQMtoR(t0reg, (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ]); } } if( dohw ) { if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } } _clearNeededMMXregs(); _clearNeededXMMregs(); if( _Rt_ ) _eeOnWriteReg(_Rt_, 0); } void recLD(void) { recLoad64(_Imm_, 1); } void recLD_co( void ) { #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { recLD(); g_pCurInstInfo++; cpuRegs.code = *(u32*)PSM(pc); recLD(); g_pCurInstInfo--; // incremented later } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); int mmreg1 = -1, mmreg2 = -1, t0reg = -1, t1reg = -1; int nextrt = ((*(u32*)(PSM(pc)) >> 16) & 0x1F); if( _Rt_ ) _eeOnWriteReg(_Rt_, 0); if( nextrt ) _eeOnWriteReg(nextrt, 0); if( _Rt_ ) { mmreg1 = _allocCheckGPRtoMMX(g_pCurInstInfo, _Rt_, MODE_WRITE); if( mmreg1 < 0 ) { mmreg1 = _allocCheckGPRtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE|MODE_READ); if( mmreg1 >= 0 ) mmreg1 |= 0x8000; } if( mmreg1 < 0 && _hasFreeMMXreg() ) mmreg1 = _allocMMXreg(-1, MMX_GPR+_Rt_, MODE_WRITE); } if( nextrt ) { mmreg2 = _allocCheckGPRtoMMX(g_pCurInstInfo+1, nextrt, MODE_WRITE); if( mmreg2 < 0 ) { mmreg2 = _allocCheckGPRtoXMM(g_pCurInstInfo+1, nextrt, MODE_WRITE|MODE_READ); if( mmreg2 >= 0 ) mmreg2 |= 0x8000; } if( mmreg2 < 0 && _hasFreeMMXreg() ) mmreg2 = _allocMMXreg(-1, MMX_GPR+nextrt, MODE_WRITE); } if( mmreg1 < 0 || mmreg2 < 0 ) { t0reg = _allocMMXreg(-1, MMX_TEMP, 0); if( mmreg1 < 0 && mmreg2 < 0 && _hasFreeMMXreg() ) { t1reg = _allocMMXreg(-1, MMX_TEMP, 0); } else t1reg = t0reg; } dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 1, 0); if( mmreg1 >= 0 ) { if( mmreg1 & 0x8000 ) SSE_MOVLPSRmtoROffset(mmreg1&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset); else MOVQRmtoROffset(mmreg1, ECX, PS2MEM_BASE_+s_nAddMemOffset); } else { if( _Rt_ ) { MOVQRmtoROffset(t0reg, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOVQRtoM((int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ], t0reg); } } if( mmreg2 >= 0 ) { if( mmreg2 & 0x8000 ) SSE_MOVLPSRmtoROffset(mmreg2&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); else MOVQRmtoROffset(mmreg2, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } else { if( nextrt ) { MOVQRmtoROffset(t1reg, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); MOVQRtoM((int)&cpuRegs.GPR.r[ nextrt ].UL[ 0 ], t1reg); } } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); if( mmreg1 >= 0 ) { PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ] ); CALLFunc( (int)recMemRead64 ); if( mmreg1 & 0x8000 ) SSE_MOVLPS_M64_to_XMM(mmreg1&0xf, (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ]); else MOVQMtoR(mmreg1, (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ]); } else { if( _Rt_ ) { _deleteEEreg(_Rt_, 0); PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ] ); } else PUSH32I( (int)&retValues[0] ); CALLFunc( (int)recMemRead64 ); } MOV32MtoR(ECX, (u32)&s_tempaddr); if( mmreg2 >= 0 ) { MOV32ItoRmOffset(ESP, (int)&cpuRegs.GPR.r[ nextrt ].UD[ 0 ], 0 ); ADD32ItoR(ECX, _Imm_co_-_Imm_); CALLFunc( (int)recMemRead64 ); if( mmreg2 & 0x8000 ) SSE_MOVLPS_M64_to_XMM(mmreg2&0xf, (int)&cpuRegs.GPR.r[ nextrt ].UD[ 0 ]); else MOVQMtoR(mmreg2, (int)&cpuRegs.GPR.r[ nextrt ].UD[ 0 ]); } else { if( nextrt ) { _deleteEEreg(nextrt, 0); MOV32ItoRmOffset(ESP, (int)&cpuRegs.GPR.r[ nextrt ].UD[ 0 ], 0 ); } else MOV32ItoRmOffset(ESP, (int)&retValues[0], 0 ); ADD32ItoR(ECX, _Imm_co_-_Imm_); CALLFunc( (int)recMemRead64 ); } ADD32ItoR(ESP, 4); if( s_bCachingMem & 2 ) x86SetJ32A(j32Ptr[4]); else x86SetJ8A(j8Ptr[2]); } if( mmreg1 < 0 || mmreg2 < 0 || !(mmreg1&0x8000) || !(mmreg2&0x8000) ) SetMMXstate(); if( t0reg >= 0 ) _freeMMXreg(t0reg); if( t0reg != t1reg && t1reg >= 0 ) _freeMMXreg(t1reg); _clearNeededMMXregs(); _clearNeededXMMregs(); } } void recLD_coX( int num ) { int i; int mmreg = -1; int mmregs[XMMREGS]; int nextrts[XMMREGS]; assert( num > 1 && num < XMMREGS ); #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { recLD(); for(i = 0; i < num; ++i) { g_pCurInstInfo++; cpuRegs.code = *(u32*)PSM(pc+i*4); recLD(); } g_pCurInstInfo -= num; // incremented later } else #endif { int dohw; int mmregS = _eePrepareReg_coX(_Rs_, num); if( _Rt_ ) _eeOnWriteReg(_Rt_, 0); for(i = 0; i < num; ++i) { nextrts[i] = ((*(u32*)(PSM(pc+i*4)) >> 16) & 0x1F); _eeOnWriteReg(nextrts[i], 0); } if( _Rt_ ) { mmreg = _allocCheckGPRtoMMX(g_pCurInstInfo, _Rt_, MODE_WRITE); if( mmreg < 0 ) { mmreg = _allocCheckGPRtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE|MODE_READ); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG; else mmreg = _allocMMXreg(-1, MMX_GPR+_Rt_, MODE_WRITE)|MEM_MMXTAG; } else mmreg |= MEM_MMXTAG; } for(i = 0; i < num; ++i) { mmregs[i] = _allocCheckGPRtoMMX(g_pCurInstInfo+i+1, nextrts[i], MODE_WRITE); if( mmregs[i] < 0 ) { mmregs[i] = _allocCheckGPRtoXMM(g_pCurInstInfo+i+1, nextrts[i], MODE_WRITE|MODE_READ); if( mmregs[i] >= 0 ) mmregs[i] |= MEM_XMMTAG; else mmregs[i] = _allocMMXreg(-1, MMX_GPR+nextrts[i], MODE_WRITE)|MEM_MMXTAG; } else mmregs[i] |= MEM_MMXTAG; } dohw = recSetMemLocation(_Rs_, _Imm_, mmregS, 1, 0); if( mmreg >= 0 ) { if( mmreg & MEM_XMMTAG ) SSE_MOVLPSRmtoROffset(mmreg&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset); else MOVQRmtoROffset(mmreg&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset); } for(i = 0; i < num; ++i) { u32 off = PS2MEM_BASE_+s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_; if( mmregs[i] >= 0 ) { if( mmregs[i] & MEM_XMMTAG ) SSE_MOVLPSRmtoROffset(mmregs[i]&0xf, ECX, off); else MOVQRmtoROffset(mmregs[i]&0xf, ECX, off); } } if( dohw ) { if( (s_bCachingMem & 2) || num > 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); if( mmreg >= 0 ) { PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ] ); CALLFunc( (int)recMemRead64 ); if( mmreg & MEM_XMMTAG ) SSE_MOVLPS_M64_to_XMM(mmreg&0xf, (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ]); else MOVQMtoR(mmreg&0xf, (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ]); } else { PUSH32I( (int)&retValues[0] ); CALLFunc( (int)recMemRead64 ); } for(i = 0; i < num; ++i ) { MOV32MtoR(ECX, (u32)&s_tempaddr); ADD32ItoR(ECX, (*(s16*)PSM(pc+i*4))-_Imm_); if( mmregs[i] >= 0 ) { MOV32ItoRmOffset(ESP, (int)&cpuRegs.GPR.r[nextrts[i]].UL[0], 0); CALLFunc( (int)recMemRead64 ); if( mmregs[i] & MEM_XMMTAG ) SSE_MOVLPS_M64_to_XMM(mmregs[i]&0xf, (int)&cpuRegs.GPR.r[ nextrts[i] ].UD[ 0 ]); else MOVQMtoR(mmregs[i]&0xf, (int)&cpuRegs.GPR.r[ nextrts[i] ].UD[ 0 ]); } else { MOV32ItoRmOffset(ESP, (int)&retValues[0], 0); CALLFunc( (int)recMemRead64 ); } } ADD32ItoR(ESP, 4); if( (s_bCachingMem & 2) || num > 2 ) x86SetJ32A(j32Ptr[4]); else x86SetJ8A(j8Ptr[2]); } _clearNeededMMXregs(); _clearNeededXMMregs(); } } //////////////////////////////////////////////////// void recLDL_co(void) { recLoad64(_Imm_-7, 0); } void recLDL( void ) { iFlushCall(FLUSH_NOCONST); if( GPR_IS_CONST1( _Rs_ ) ) { // flush temporarily MOV32ItoM((int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ], g_cpuConstRegs[_Rs_].UL[0]); //MOV32ItoM((int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 1 ], g_cpuConstRegs[_Rs_].UL[1]); } else { _deleteGPRtoXMMreg(_Rs_, 1); _deleteMMXreg(MMX_GPR+_Rs_, 1); } if( _Rt_ ) _deleteEEreg(_Rt_, _Rt_==_Rs_); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)LDL ); } //////////////////////////////////////////////////// void recLDR_co(void) { recLoad64(_Imm_, 0); } void recLDR( void ) { iFlushCall(FLUSH_NOCONST); if( GPR_IS_CONST1( _Rs_ ) ) { // flush temporarily MOV32ItoM((int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ], g_cpuConstRegs[_Rs_].UL[0]); //MOV32ItoM((int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 1 ], g_cpuConstRegs[_Rs_].UL[1]); } else { _deleteGPRtoXMMreg(_Rs_, 1); _deleteMMXreg(MMX_GPR+_Rs_, 1); } if( _Rt_ ) _deleteEEreg(_Rt_, _Rt_==_Rs_); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)LDR ); } //////////////////////////////////////////////////// void recLQ( void ) { int mmreg = -1; #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( cpucaps.hasStreamingSIMDExtensions && GPR_IS_CONST1( _Rs_ ) ) { // malice hits this assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_) % 16 == 0 ); if( _Rt_ ) { if( (g_pCurInstInfo->regs[_Rt_]&EEINST_XMM) || !(g_pCurInstInfo->regs[_Rt_]&EEINST_MMX) ) { _deleteMMXreg(MMX_GPR+_Rt_, 2); _eeOnWriteReg(_Rt_, 0); mmreg = _allocGPRtoXMMreg(-1, _Rt_, MODE_WRITE); } else { int t0reg; _deleteGPRtoXMMreg(_Rt_, 2); _eeOnWriteReg(_Rt_, 0); mmreg = _allocMMXreg(-1, MMX_GPR+_Rt_, MODE_WRITE)|MEM_MMXTAG; t0reg = _allocMMXreg(-1, MMX_TEMP, 0); mmreg |= t0reg<<4; } } else { mmreg = _allocTempXMMreg(XMMT_INT, -1); } recMemConstRead128((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~15, mmreg); if( !_Rt_ ) _freeXMMreg(mmreg); if( IS_MMXREG(mmreg) ) { // flush temp assert( mmxregs[mmreg&0xf].mode & MODE_WRITE ); MOVQRtoM((u32)&cpuRegs.GPR.r[_Rt_].UL[2], (mmreg>>4)&0xf); _freeMMXreg((mmreg>>4)&0xf); } else assert( xmmregs[mmreg&0xf].mode & MODE_WRITE ); } else #endif { int dohw; int mmregs; int t0reg = -1; if( !cpucaps.hasStreamingSIMDExtensions && GPR_IS_CONST1( _Rs_ ) ) _flushConstReg(_Rs_); mmregs = _eePrepareReg(_Rs_); if( _Rt_ ) { _eeOnWriteReg(_Rt_, 0); // check if can process mmx if( _hasFreeMMXreg() ) { mmreg = _allocCheckGPRtoMMX(g_pCurInstInfo, _Rt_, MODE_WRITE); if( mmreg >= 0 ) { mmreg |= MEM_MMXTAG; t0reg = _allocMMXreg(-1, MMX_TEMP, 0); } } else _deleteMMXreg(MMX_GPR+_Rt_, 2); if( mmreg < 0 ) { mmreg = _allocGPRtoXMMreg(-1, _Rt_, MODE_WRITE); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG; } } if( mmreg < 0 ) { _deleteEEreg(_Rt_, 1); } dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 2, 0); if( _Rt_ ) { if( mmreg >= 0 && (mmreg & MEM_MMXTAG) ) { MOVQRmtoROffset(t0reg, ECX, PS2MEM_BASE_+s_nAddMemOffset+8); MOVQRmtoROffset(mmreg&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOVQRtoM((u32)&cpuRegs.GPR.r[_Rt_].UL[2], t0reg); } else if( mmreg >= 0 && (mmreg & MEM_XMMTAG) ) { SSEX_MOVDQARmtoROffset(mmreg&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset); } else { _recMove128RmOffsettoM((u32)&cpuRegs.GPR.r[_Rt_].UL[0], PS2MEM_BASE_+s_nAddMemOffset); } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); CALLFunc( (int)recMemRead128 ); if( mmreg >= 0 && (mmreg & MEM_MMXTAG) ) MOVQMtoR(mmreg&0xf, (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ]); else if( mmreg >= 0 && (mmreg & MEM_XMMTAG) ) SSEX_MOVDQA_M128_to_XMM(mmreg&0xf, (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); ADD32ItoR(ESP, 4); } } else { if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); PUSH32I( (int)&retValues[0] ); CALLFunc( (int)recMemRead128 ); ADD32ItoR(ESP, 4); } } if( dohw ) { if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } if( t0reg >= 0 ) _freeMMXreg(t0reg); } _clearNeededXMMregs(); // needed since allocing } void recLQ_co( void ) { #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { recLQ(); g_pCurInstInfo++; cpuRegs.code = *(u32*)PSM(pc); recLQ(); g_pCurInstInfo--; // incremented later } else #endif { int dohw; int t0reg = -1; int mmregs = _eePrepareReg(_Rs_); int nextrt = ((*(u32*)(PSM(pc)) >> 16) & 0x1F); int mmreg1 = -1, mmreg2 = -1; if( _Rt_ ) { _eeOnWriteReg(_Rt_, 0); if( _hasFreeMMXreg() ) { mmreg1 = _allocCheckGPRtoMMX(g_pCurInstInfo, _Rt_, MODE_WRITE); if( mmreg1 >= 0 ) { mmreg1 |= MEM_MMXTAG; if( t0reg < 0 ) t0reg = _allocMMXreg(-1, MMX_TEMP, 0); } } else _deleteMMXreg(MMX_GPR+_Rt_, 2); if( mmreg1 < 0 ) { mmreg1 = _allocGPRtoXMMreg(-1, _Rt_, MODE_WRITE); if( mmreg1 >= 0 ) mmreg1 |= MEM_XMMTAG; } } if( nextrt ) { _eeOnWriteReg(nextrt, 0); if( _hasFreeMMXreg() ) { mmreg2 = _allocCheckGPRtoMMX(g_pCurInstInfo+1, nextrt, MODE_WRITE); if( mmreg2 >= 0 ) { mmreg2 |= MEM_MMXTAG; if( t0reg < 0 ) t0reg = _allocMMXreg(-1, MMX_TEMP, 0); } } else _deleteMMXreg(MMX_GPR+nextrt, 2); if( mmreg2 < 0 ) { mmreg2 = _allocGPRtoXMMreg(-1, nextrt, MODE_WRITE); if( mmreg2 >= 0 ) mmreg2 |= MEM_XMMTAG; } } dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 2, 0); if( _Rt_ ) { if( mmreg1 >= 0 && (mmreg1 & MEM_MMXTAG) ) { MOVQRmtoROffset(t0reg, ECX, PS2MEM_BASE_+s_nAddMemOffset+8); MOVQRmtoROffset(mmreg1&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOVQRtoM((u32)&cpuRegs.GPR.r[_Rt_].UL[2], t0reg); } else if( mmreg1 >= 0 && (mmreg1 & MEM_XMMTAG) ) { SSEX_MOVDQARmtoROffset(mmreg1&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset); } else { _recMove128RmOffsettoM((u32)&cpuRegs.GPR.r[_Rt_].UL[0], PS2MEM_BASE_+s_nAddMemOffset); } } if( nextrt ) { if( mmreg2 >= 0 && (mmreg2 & MEM_MMXTAG) ) { MOVQRmtoROffset(t0reg, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_+8); MOVQRmtoROffset(mmreg2&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); MOVQRtoM((u32)&cpuRegs.GPR.r[nextrt].UL[2], t0reg); } else if( mmreg2 >= 0 && (mmreg2 & MEM_XMMTAG) ) { SSEX_MOVDQARmtoROffset(mmreg2&0xf, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } else { _recMove128RmOffsettoM((u32)&cpuRegs.GPR.r[nextrt].UL[0], PS2MEM_BASE_+s_nAddMemOffset); } } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); if( _Rt_ ) PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); else PUSH32I( (int)&retValues[0] ); CALLFunc( (int)recMemRead128 ); MOV32MtoR(ECX, (u32)&s_tempaddr); if( nextrt ) MOV32ItoRmOffset(ESP, (int)&cpuRegs.GPR.r[nextrt].UL[0], 0); else MOV32ItoRmOffset(ESP, (int)&retValues[0], 0); ADD32ItoR(ECX, _Imm_co_-_Imm_); CALLFunc( (int)recMemRead128 ); if( _Rt_) { if( mmreg1 >= 0 && (mmreg1 & MEM_MMXTAG) ) MOVQMtoR(mmreg1&0xf, (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ]); else if( mmreg1 >= 0 && (mmreg1 & MEM_XMMTAG) ) SSEX_MOVDQA_M128_to_XMM(mmreg1&0xf, (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); } if( nextrt ) { if( mmreg2 >= 0 && (mmreg2 & MEM_MMXTAG) ) MOVQMtoR(mmreg2&0xf, (int)&cpuRegs.GPR.r[ nextrt ].UL[ 0 ]); else if( mmreg2 >= 0 && (mmreg2 & MEM_XMMTAG) ) SSEX_MOVDQA_M128_to_XMM(mmreg2&0xf, (int)&cpuRegs.GPR.r[ nextrt ].UL[ 0 ] ); } ADD32ItoR(ESP, 4); if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } if( t0reg >= 0 ) _freeMMXreg(t0reg); } } // coissues more than 2 LQs void recLQ_coX(int num) { int i; int mmreg = -1; int mmregs[XMMREGS]; int nextrts[XMMREGS]; assert( num > 1 && num < XMMREGS ); #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { recLQ(); for(i = 0; i < num; ++i) { g_pCurInstInfo++; cpuRegs.code = *(u32*)PSM(pc+i*4); recLQ(); } g_pCurInstInfo -= num; // incremented later } else #endif { int dohw; int mmregS = _eePrepareReg_coX(_Rs_, num); if( _Rt_ ) _deleteMMXreg(MMX_GPR+_Rt_, 2); for(i = 0; i < num; ++i) { nextrts[i] = ((*(u32*)(PSM(pc+i*4)) >> 16) & 0x1F); if( nextrts[i] ) _deleteMMXreg(MMX_GPR+nextrts[i], 2); } if( _Rt_ ) { _eeOnWriteReg(_Rt_, 0); mmreg = _allocGPRtoXMMreg(-1, _Rt_, MODE_WRITE); } for(i = 0; i < num; ++i) { if( nextrts[i] ) { _eeOnWriteReg(nextrts[i], 0); mmregs[i] = _allocGPRtoXMMreg(-1, nextrts[i], MODE_WRITE); } else mmregs[i] = -1; } dohw = recSetMemLocation(_Rs_, _Imm_, mmregS, 2, 1); if( _Rt_ ) SSEX_MOVDQARmtoROffset(mmreg, ECX, PS2MEM_BASE_+s_nAddMemOffset); for(i = 0; i < num; ++i) { u32 off = s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_; if( nextrts[i] ) SSEX_MOVDQARmtoROffset(mmregs[i], ECX, PS2MEM_BASE_+off&~0xf); } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); if( _Rt_ ) PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); else PUSH32I( (int)&retValues[0] ); CALLFunc( (int)recMemRead128 ); if( _Rt_) SSEX_MOVDQA_M128_to_XMM(mmreg, (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); for(i = 0; i < num; ++i) { MOV32MtoR(ECX, (u32)&s_tempaddr); ADD32ItoR(ECX, (*(s16*)PSM(pc+i*4))-_Imm_); if( nextrts[i] ) MOV32ItoRmOffset(ESP, (int)&cpuRegs.GPR.r[nextrts[i]].UL[0], 0); else MOV32ItoRmOffset(ESP, (int)&retValues[0], 0); CALLFunc( (int)recMemRead128 ); if( nextrts[i] ) SSEX_MOVDQA_M128_to_XMM(mmregs[i], (int)&cpuRegs.GPR.r[ nextrts[i] ].UL[ 0 ] ); } ADD32ItoR(ESP, 4); if( s_bCachingMem & 2 ) x86SetJ32A(j32Ptr[4]); else x86SetJ8A(j8Ptr[2]); } } } //////////////////////////////////////////////////// extern void recClear64(BASEBLOCK* p); extern void recClear128(BASEBLOCK* p); // check if clearing executable code, size is in dwords void recMemConstClear(u32 mem, u32 size) { // NOTE! This assumes recLUT never changes its mapping if( !recLUT[mem>>16] ) return; //iFlushCall(0); // just in case // check if mem is executable, and clear it //CMP32ItoM((u32)&maxrecmem, mem); //j8Ptr[5] = JBE8(0); // can clear now if( size == 1 ) { CMP32ItoM((u32)PC_GETBLOCK(mem), 0); j8Ptr[6] = JE8(0); PUSH32I((u32)PC_GETBLOCK(mem)); CALLFunc((u32)recClearMem); ADD32ItoR(ESP, 4); x86SetJ8(j8Ptr[6]); } else if( size == 2 ) { // need to clear 8 bytes CMP32I8toM((u32)PC_GETBLOCK(mem), 0); j8Ptr[6] = JNE8(0); CMP32I8toM((u32)PC_GETBLOCK(mem)+8, 0); j8Ptr[7] = JNE8(0); j8Ptr[8] = JMP8(0); // call clear x86SetJ8( j8Ptr[7] ); x86SetJ8( j8Ptr[6] ); PUSH32I((u32)PC_GETBLOCK(mem)); CALLFunc((u32)recClear64); ADD32ItoR(ESP, 4); x86SetJ8( j8Ptr[8] ); } else { assert( size == 4 ); // need to clear 16 bytes CMP32I8toM((u32)PC_GETBLOCK(mem), 0); j8Ptr[6] = JNE8(0); CMP32I8toM((u32)PC_GETBLOCK(mem)+sizeof(BASEBLOCK), 0); j8Ptr[7] = JNE8(0); CMP32I8toM((u32)PC_GETBLOCK(mem)+sizeof(BASEBLOCK)*2, 0); j8Ptr[8] = JNE8(0); CMP32I8toM((u32)PC_GETBLOCK(mem)+sizeof(BASEBLOCK)*3, 0); j8Ptr[9] = JNE8(0); j8Ptr[10] = JMP8(0); // call clear x86SetJ8( j8Ptr[6] ); x86SetJ8( j8Ptr[7] ); x86SetJ8( j8Ptr[8] ); x86SetJ8( j8Ptr[9] ); PUSH32I((u32)PC_GETBLOCK(mem)); CALLFunc((u32)recClear128); ADD32ItoR(ESP, 4); x86SetJ8( j8Ptr[10] ); } //x86SetJ8(j8Ptr[5]); } // check if mem is executable, and clear it __declspec(naked) void recWriteMemClear32() { _asm { mov edx, ecx shr edx, 14 and dl, 0xfc add edx, recLUT test dword ptr [edx], 0xffffffff jnz Clear32 ret Clear32: // recLUT[mem>>16] + (mem&0xfffc) mov edx, dword ptr [edx] mov eax, ecx and eax, 0xfffc // edx += 2*eax shl eax, 1 add edx, eax cmp dword ptr [edx], 0 je ClearRet sub esp, 4 mov dword ptr [esp], edx call recClearMem add esp, 4 ClearRet: ret } } // check if mem is executable, and clear it __declspec(naked) void recWriteMemClear64() { __asm { // check if mem is executable, and clear it mov edx, ecx shr edx, 14 and edx, 0xfffffffc add edx, recLUT cmp dword ptr [edx], 0 jne Clear64 ret Clear64: // recLUT[mem>>16] + (mem&0xffff) mov edx, dword ptr [edx] mov eax, ecx and eax, 0xfffc // edx += 2*eax shl eax, 1 add edx, eax // note: have to check both blocks cmp dword ptr [edx], 0 jne DoClear0 cmp dword ptr [edx+8], 0 jne DoClear1 ret DoClear1: add edx, 8 DoClear0: sub esp, 4 mov dword ptr [esp], edx call recClear64 add esp, 4 ret } } // check if mem is executable, and clear it __declspec(naked) void recWriteMemClear128() { __asm { // check if mem is executable, and clear it mov edx, ecx shr edx, 14 and edx, 0xfffffffc add edx, recLUT cmp dword ptr [edx], 0 jne Clear128 ret Clear128: // recLUT[mem>>16] + (mem&0xffff) mov edx, dword ptr [edx] mov eax, ecx and eax, 0xfffc // edx += 2*eax shl eax, 1 add edx, eax // note: have to check all 4 blocks cmp dword ptr [edx], 0 jne DoClear add edx, 8 cmp dword ptr [edx], 0 jne DoClear add edx, 8 cmp dword ptr [edx], 0 jne DoClear add edx, 8 cmp dword ptr [edx], 0 jne DoClear ret DoClear: sub esp, 4 mov dword ptr [esp], edx call recClear128 add esp, 4 ret } } void recStore_raw(EEINST* pinst, int bit, int x86reg, int gprreg, u32 offset) { if( bit == 128 ) { int mmreg; if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, gprreg, MODE_READ)) >= 0) { SSEX_MOVDQARtoRmOffset(ECX, mmreg, PS2MEM_BASE_+offset); } else if( (mmreg = _checkMMXreg(MMX_GPR+gprreg, MODE_READ)) >= 0) { if( _hasFreeMMXreg() ) { int t0reg = _allocMMXreg(-1, MMX_TEMP, 0); MOVQMtoR(t0reg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 2 ]); MOVQRtoRmOffset(ECX, mmreg, PS2MEM_BASE_+offset); MOVQRtoRmOffset(ECX, t0reg, PS2MEM_BASE_+offset+8); _freeMMXreg(t0reg); } else { MOV32MtoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 2 ]); MOV32MtoR(EDX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 3 ]); MOVQRtoRmOffset(ECX, mmreg, PS2MEM_BASE_+offset); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+offset+8); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+offset+12); } SetMMXstate(); } else { if( GPR_IS_CONST1( gprreg ) ) { assert( _checkXMMreg(XMMTYPE_GPRREG, gprreg, MODE_READ) == -1 ); if( _hasFreeMMXreg() ) { int t0reg = _allocMMXreg(-1, MMX_TEMP, 0); SetMMXstate(); MOVQMtoR(t0reg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 2 ]); MOV32ItoRmOffset(ECX, g_cpuConstRegs[gprreg].UL[0], PS2MEM_BASE_+offset); MOV32ItoRmOffset(ECX, g_cpuConstRegs[gprreg].UL[1], PS2MEM_BASE_+offset+4); MOVQRtoRmOffset(ECX, t0reg, PS2MEM_BASE_+offset+8); _freeMMXreg(t0reg); } else { MOV32MtoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 2 ]); MOV32MtoR(EDX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 3 ]); MOV32ItoRmOffset(ECX, g_cpuConstRegs[gprreg].UL[0], PS2MEM_BASE_+offset); MOV32ItoRmOffset(ECX, g_cpuConstRegs[gprreg].UL[1], PS2MEM_BASE_+offset+4); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+offset+8); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+offset+12); } } else { if( _hasFreeXMMreg() ) { mmreg = _allocGPRtoXMMreg(-1, gprreg, MODE_READ); SSEX_MOVDQARtoRmOffset(ECX, mmreg, PS2MEM_BASE_+offset); _freeXMMreg(mmreg); } else if( _hasFreeMMXreg() ) { mmreg = _allocMMXreg(-1, MMX_TEMP, 0); if( _hasFreeMMXreg() ) { int t0reg; t0reg = _allocMMXreg(-1, MMX_TEMP, 0); MOVQMtoR(mmreg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); MOVQMtoR(t0reg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 2 ]); MOVQRtoRmOffset(ECX, mmreg, PS2MEM_BASE_+offset); MOVQRtoRmOffset(ECX, t0reg, PS2MEM_BASE_+offset+8); _freeMMXreg(t0reg); } else { MOVQMtoR(mmreg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); MOV32MtoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 2 ]); MOV32MtoR(EDX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 3 ]); MOVQRtoRmOffset(ECX, mmreg, PS2MEM_BASE_+offset); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+offset+8); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+offset+12); // MOVQMtoR(mmreg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 2 ]); // MOVQRtoRmOffset(ECX, mmreg, PS2MEM_BASE_+offset+8); } SetMMXstate(); _freeMMXreg(mmreg); } else { MOV32MtoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); MOV32MtoR(EDX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 1 ]); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+offset); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+offset+4); MOV32MtoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 2 ]); MOV32MtoR(EDX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 3 ]); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+offset+8); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+offset+12); } } } return; } if( GPR_IS_CONST1( gprreg ) ) { switch(bit) { case 8: MOV8ItoRmOffset(ECX, g_cpuConstRegs[gprreg].UL[0], PS2MEM_BASE_+offset); break; case 16: MOV16ItoRmOffset(ECX, g_cpuConstRegs[gprreg].UL[0], PS2MEM_BASE_+offset); break; case 32: MOV32ItoRmOffset(ECX, g_cpuConstRegs[gprreg].UL[0], PS2MEM_BASE_+offset); break; case 64: MOV32ItoRmOffset(ECX, g_cpuConstRegs[gprreg].UL[0], PS2MEM_BASE_+offset); MOV32ItoRmOffset(ECX, g_cpuConstRegs[gprreg].UL[1], PS2MEM_BASE_+offset+4); break; } } else { int mmreg = _checkMMXreg(MMX_GPR+gprreg, MODE_READ); if( mmreg < 0 ) { mmreg = _checkXMMreg(XMMTYPE_GPRREG, gprreg, MODE_READ); if( mmreg >= 0 ) mmreg |= 0x8000; } if( bit == 64 ) { //sd if( mmreg >= 0 ) { if( mmreg & 0x8000 ) { SSE_MOVLPSRtoRmOffset(ECX, mmreg&0xf, PS2MEM_BASE_+offset); } else { MOVQRtoRmOffset(ECX, mmreg&0xf, PS2MEM_BASE_+offset); SetMMXstate(); } } else { if( (mmreg = _allocCheckGPRtoMMX(pinst, gprreg, MODE_READ)) >= 0 ) { MOVQRtoRmOffset(ECX, mmreg, PS2MEM_BASE_+offset); SetMMXstate(); _freeMMXreg(mmreg); } else if( _hasFreeMMXreg() ) { mmreg = _allocMMXreg(-1, MMX_GPR+gprreg, MODE_READ); MOVQRtoRmOffset(ECX, mmreg, PS2MEM_BASE_+offset); SetMMXstate(); _freeMMXreg(mmreg); } else { MOV32MtoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); MOV32MtoR(EDX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 1 ]); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+offset); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+offset+4); } } } else if( bit == 32 ) { // sw if( mmreg >= 0 ) { if( mmreg & 0x8000) { SSEX_MOVD_XMM_to_RmOffset(ECX, mmreg&0xf, PS2MEM_BASE_+offset); } else { MOVD32MMXtoRmOffset(ECX, mmreg&0xf, PS2MEM_BASE_+offset); SetMMXstate(); } } else { MOV32MtoR(x86reg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); MOV32RtoRmOffset(ECX, x86reg, PS2MEM_BASE_+offset); } } else { // sb, sh if( mmreg >= 0) { if( mmreg & 0x8000) { if( !(xmmregs[mmreg&0xf].mode&MODE_WRITE) ) mmreg = -1; } else { if( !(mmxregs[mmreg&0xf].mode&MODE_WRITE) ) mmreg = -1; } } if( mmreg >= 0) { if( mmreg & 0x8000 ) SSE2_MOVD_XMM_to_R(x86reg, mmreg&0xf); else { MOVD32MMXtoR(x86reg, mmreg&0xf); SetMMXstate(); } } else { switch(bit) { case 8: MOV8MtoR(x86reg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); break; case 16: MOV16MtoR(x86reg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); break; case 32: MOV32MtoR(x86reg, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); break; } } switch(bit) { case 8: MOV8RtoRmOffset(ECX, x86reg, PS2MEM_BASE_+offset); break; case 16: MOV16RtoRmOffset(ECX, x86reg, PS2MEM_BASE_+offset); break; case 32: MOV32RtoRmOffset(ECX, x86reg, PS2MEM_BASE_+offset); break; } } } } void recStore_call(int bit, int gprreg, u32 offset) { // some type of hardware write if( GPR_IS_CONST1( gprreg ) ) { if( bit == 128 ) { if( gprreg > 0 ) { assert( _checkXMMreg(XMMTYPE_GPRREG, gprreg, MODE_READ) == -1 ); MOV32ItoM((int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ], g_cpuConstRegs[gprreg].UL[0]); MOV32ItoM((int)&cpuRegs.GPR.r[ gprreg ].UL[ 1 ], g_cpuConstRegs[gprreg].UL[1]); } MOV32ItoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); } else if( bit == 64 ) { if( !(g_cpuFlushedConstReg&(1<<gprreg)) ) { // write to a temp loc, trick u32* ptr = (u32*)recAllocStackMem(8, 4); ptr[0] = g_cpuConstRegs[gprreg].UL[0]; ptr[1] = g_cpuConstRegs[gprreg].UL[1]; MOV32ItoR(EAX, (u32)ptr); } else { MOV32ItoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); } } else { switch(bit) { case 8: MOV8ItoR(EAX, g_cpuConstRegs[gprreg].UL[0]); break; case 16: MOV16ItoR(EAX, g_cpuConstRegs[gprreg].UL[0]); break; case 32: MOV32ItoR(EAX, g_cpuConstRegs[gprreg].UL[0]); break; } } } else { int mmreg; if( bit == 128 ) { if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, gprreg, MODE_READ)) >= 0) { if( xmmregs[mmreg].mode & MODE_WRITE ) { SSEX_MOVDQA_XMM_to_M128((int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ], mmreg); } } else if( (mmreg = _checkMMXreg(MMX_GPR+gprreg, MODE_READ)) >= 0) { if( mmxregs[mmreg].mode & MODE_WRITE ) { MOVQRtoM((int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ], mmreg); } } MOV32ItoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); } else if( bit == 64 ) { // sd if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, gprreg, MODE_READ)) >= 0) { if( xmmregs[mmreg].mode & MODE_WRITE ) { SSE_MOVLPS_XMM_to_M64((int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ], mmreg); } } else if( (mmreg = _checkMMXreg(MMX_GPR+gprreg, MODE_READ)) >= 0) { if( mmxregs[mmreg].mode & MODE_WRITE ) { MOVQRtoM((int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ], mmreg); SetMMXstate(); } } MOV32ItoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); } else { // sb, sh, sw if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, gprreg, MODE_READ)) >= 0 && (xmmregs[mmreg].mode&MODE_WRITE) ) { SSE2_MOVD_XMM_to_R(EAX, mmreg); } else if( (mmreg = _checkMMXreg(MMX_GPR+gprreg, MODE_READ)) >= 0 && (mmxregs[mmreg].mode&MODE_WRITE)) { MOVD32MMXtoR(EAX, mmreg); SetMMXstate(); } else { switch(bit) { case 8: MOV8MtoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); break; case 16: MOV16MtoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); break; case 32: MOV32MtoR(EAX, (int)&cpuRegs.GPR.r[ gprreg ].UL[ 0 ]); break; } } } } if( offset != 0 ) ADD32ItoR(ECX, offset); // some type of hardware write switch(bit) { case 8: CALLFunc( (int)recMemWrite8 ); break; case 16: CALLFunc( (int)recMemWrite16 ); break; case 32: CALLFunc( (int)recMemWrite32 ); break; case 64: CALLFunc( (int)recMemWrite64 ); break; case 128: CALLFunc( (int)recMemWrite128 ); break; } } int _eePrepConstWrite128(int gprreg) { int mmreg = 0; if( GPR_IS_CONST1(gprreg) ) { if( gprreg ) { mmreg = _allocMMXreg(-1, MMX_TEMP, 0); MOVQMtoR(mmreg, (u32)&cpuRegs.GPR.r[gprreg].UL[2]); _freeMMXreg(mmreg); mmreg |= (gprreg<<16)|MEM_EECONSTTAG; } else { mmreg = _allocTempXMMreg(XMMT_INT, -1); SSEX_PXOR_XMM_to_XMM(mmreg, mmreg); _freeXMMreg(mmreg); mmreg |= MEM_XMMTAG; } } else { if( (mmreg = _checkMMXreg(MMX_GPR+gprreg, MODE_READ)) >= 0 ) { int mmregtemp = _allocMMXreg(-1, MMX_TEMP, 0); MOVQMtoR(mmregtemp, (u32)&cpuRegs.GPR.r[gprreg].UL[2]); mmreg |= (mmregtemp<<4)|MEM_MMXTAG; _freeMMXreg(mmregtemp); } else mmreg = _allocGPRtoXMMreg(-1, gprreg, MODE_READ)|MEM_XMMTAG; } return mmreg; } void recStore(int bit, u32 imm, int align) { int mmreg; #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( cpucaps.hasStreamingSIMDExtensions && GPR_IS_CONST1( _Rs_ ) ) { u32 addr = g_cpuConstRegs[_Rs_].UL[0]+imm; int doclear = 0; StopPerfCounter(); switch(bit) { case 8: if( GPR_IS_CONST1(_Rt_) ) doclear = recMemConstWrite8(addr, MEM_EECONSTTAG|(_Rt_<<16)); else { _eeMoveGPRtoR(EAX, _Rt_); doclear = recMemConstWrite8(addr, EAX); } if( doclear ) { recMemConstClear((addr)&~3, 1); } break; case 16: assert( (addr)%2 == 0 ); if( GPR_IS_CONST1(_Rt_) ) doclear = recMemConstWrite16(addr, MEM_EECONSTTAG|(_Rt_<<16)); else { _eeMoveGPRtoR(EAX, _Rt_); doclear = recMemConstWrite16(addr, EAX); } if( doclear ) { recMemConstClear((addr)&~3, 1); } break; case 32: // used by SWL/SWR //assert( (addr)%4 == 0 ); if( GPR_IS_CONST1(_Rt_) ) doclear = recMemConstWrite32(addr, MEM_EECONSTTAG|(_Rt_<<16)); else if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, _Rt_, MODE_READ)) >= 0 ) { doclear = recMemConstWrite32(addr, mmreg|MEM_XMMTAG|(_Rt_<<16)); } else if( (mmreg = _checkMMXreg(MMX_GPR+_Rt_, MODE_READ)) >= 0 ) { doclear = recMemConstWrite32(addr, mmreg|MEM_MMXTAG|(_Rt_<<16)); } else { _eeMoveGPRtoR(EAX, _Rt_); doclear = recMemConstWrite32(addr, EAX); } if( doclear ) { recMemConstClear((addr)&~3, 1); } break; case 64: { //assert( (addr)%8 == 0 ); int mask = align ? ~7 : ~0; if( GPR_IS_CONST1(_Rt_) ) doclear = recMemConstWrite64(addr, MEM_EECONSTTAG|(_Rt_<<16)); else if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, _Rt_, MODE_READ)) >= 0 ) { doclear = recMemConstWrite64(addr&mask, mmreg|MEM_XMMTAG|(_Rt_<<16)); } else { mmreg = _allocMMXreg(-1, MMX_GPR+_Rt_, MODE_READ); doclear = recMemConstWrite64(addr&mask, mmreg|MEM_MMXTAG|(_Rt_<<16)); } if( doclear ) { recMemConstClear((addr)&~7, 2); } break; } case 128: //assert( (addr)%16 == 0 ); if( recMemConstWrite128((addr)&~15, _eePrepConstWrite128(_Rt_)) ) { CMP32ItoM((u32)&maxrecmem, addr); j8Ptr[0] = JB8(0); recMemConstClear((addr)&~15, 4); x86SetJ8(j8Ptr[0]); } break; } StartPerfCounter(); } else #endif { int dohw; int mmregs; if( !cpucaps.hasStreamingSIMDExtensions && GPR_IS_CONST1( _Rs_ ) ) { _flushConstReg(_Rs_); } mmregs = _eePrepareReg(_Rs_); dohw = recSetMemLocation(_Rs_, imm, mmregs, align ? bit/64 : 0, 0); recStore_raw(g_pCurInstInfo, bit, EAX, _Rt_, s_nAddMemOffset); if( s_nAddMemOffset ) ADD32ItoR(ECX, s_nAddMemOffset); CMP32MtoR(ECX, (u32)&maxrecmem); if( s_bCachingMem & 2 ) j32Ptr[4] = JAE32(0); else j8Ptr[1] = JAE8(0); if( bit < 32 || !align ) AND8ItoR(ECX, 0xfc); if( bit <= 32 ) CALLFunc((u32)recWriteMemClear32); else if( bit == 64 ) CALLFunc((u32)recWriteMemClear64); else CALLFunc((u32)recWriteMemClear128); if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[5] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); StopPerfCounter(); recStore_call(bit, _Rt_, s_nAddMemOffset); StartPerfCounter(); if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[5]); else x86SetJ8(j8Ptr[2]); } if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[1]); } _clearNeededMMXregs(); // needed since allocing _clearNeededXMMregs(); // needed since allocing } void recStore_co(int bit, int align) { int nextrt = ((*(u32*)(PSM(pc)) >> 16) & 0x1F); #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { u32 addr = g_cpuConstRegs[_Rs_].UL[0]+_Imm_; u32 coaddr = g_cpuConstRegs[_Rs_].UL[0]+_Imm_co_; int mmreg, t0reg = -1, mmreg2; int doclear = 0; switch(bit) { case 8: if( GPR_IS_CONST1(_Rt_) ) doclear |= recMemConstWrite8(addr, MEM_EECONSTTAG|(_Rt_<<16)); else { _eeMoveGPRtoR(EAX, _Rt_); doclear |= recMemConstWrite8(addr, EAX); } if( GPR_IS_CONST1(nextrt) ) doclear |= recMemConstWrite8(coaddr, MEM_EECONSTTAG|(nextrt<<16)); else { _eeMoveGPRtoR(EAX, nextrt); doclear |= recMemConstWrite8(coaddr, EAX); } break; case 16: assert( (addr)%2 == 0 ); assert( (coaddr)%2 == 0 ); if( GPR_IS_CONST1(_Rt_) ) doclear |= recMemConstWrite16(addr, MEM_EECONSTTAG|(_Rt_<<16)); else { _eeMoveGPRtoR(EAX, _Rt_); doclear |= recMemConstWrite16(addr, EAX); } if( GPR_IS_CONST1(nextrt) ) doclear |= recMemConstWrite16(coaddr, MEM_EECONSTTAG|(nextrt<<16)); else { _eeMoveGPRtoR(EAX, nextrt); doclear |= recMemConstWrite16(coaddr, EAX); } break; case 32: assert( (addr)%4 == 0 ); if( GPR_IS_CONST1(_Rt_) ) doclear = recMemConstWrite32(addr, MEM_EECONSTTAG|(_Rt_<<16)); else if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, _Rt_, MODE_READ)) >= 0 ) { doclear = recMemConstWrite32(addr, mmreg|MEM_XMMTAG|(_Rt_<<16)); } else if( (mmreg = _checkMMXreg(MMX_GPR+_Rt_, MODE_READ)) >= 0 ) { doclear = recMemConstWrite32(addr, mmreg|MEM_MMXTAG|(_Rt_<<16)); } else { _eeMoveGPRtoR(EAX, _Rt_); doclear = recMemConstWrite32(addr, EAX); } if( GPR_IS_CONST1(nextrt) ) doclear |= recMemConstWrite32(coaddr, MEM_EECONSTTAG|(nextrt<<16)); else if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, nextrt, MODE_READ)) >= 0 ) { doclear |= recMemConstWrite32(coaddr, mmreg|MEM_XMMTAG|(nextrt<<16)); } else if( (mmreg = _checkMMXreg(MMX_GPR+nextrt, MODE_READ)) >= 0 ) { doclear |= recMemConstWrite32(coaddr, mmreg|MEM_MMXTAG|(nextrt<<16)); } else { _eeMoveGPRtoR(EAX, nextrt); doclear |= recMemConstWrite32(coaddr, EAX); } break; case 64: { int mask = align ? ~7 : ~0; //assert( (addr)%8 == 0 ); if( GPR_IS_CONST1(_Rt_) ) mmreg = MEM_EECONSTTAG|(_Rt_<<16); else if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, _Rt_, MODE_READ)) >= 0 ) { mmreg |= MEM_XMMTAG|(_Rt_<<16); } else mmreg = _allocMMXreg(-1, MMX_GPR+_Rt_, MODE_READ)|MEM_MMXTAG|(_Rt_<<16); if( GPR_IS_CONST1(nextrt) ) mmreg2 = MEM_EECONSTTAG|(nextrt<<16); else if( (mmreg2 = _checkXMMreg(XMMTYPE_GPRREG, nextrt, MODE_READ)) >= 0 ) { mmreg2 |= MEM_XMMTAG|(nextrt<<16); } else mmreg2 = _allocMMXreg(-1, MMX_GPR+nextrt, MODE_READ)|MEM_MMXTAG|(nextrt<<16); doclear = recMemConstWrite64((addr)&mask, mmreg); doclear |= recMemConstWrite64((coaddr)&mask, mmreg2); doclear <<= 1; break; } case 128: assert( (addr)%16 == 0 ); mmreg = _eePrepConstWrite128(_Rt_); mmreg2 = _eePrepConstWrite128(nextrt); doclear = recMemConstWrite128((addr)&~15, mmreg); doclear |= recMemConstWrite128((coaddr)&~15, mmreg2); doclear <<= 2; break; } if( doclear ) { u8* ptr; CMP32ItoM((u32)&maxrecmem, g_cpuConstRegs[_Rs_].UL[0]+(_Imm_ < _Imm_co_ ? _Imm_ : _Imm_co_)); ptr = JB8(0); recMemConstClear((addr)&~(doclear*4-1), doclear); recMemConstClear((coaddr)&~(doclear*4-1), doclear); x86SetJ8A(ptr); } } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); int off = _Imm_co_-_Imm_; dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, align ? bit/64 : 0, bit==128); recStore_raw(g_pCurInstInfo, bit, EAX, _Rt_, s_nAddMemOffset); recStore_raw(g_pCurInstInfo+1, bit, EBX, nextrt, s_nAddMemOffset+off); // clear the writes, do only one camera (with the lowest addr) if( off < 0 ) ADD32ItoR(ECX, s_nAddMemOffset+off); else if( s_nAddMemOffset ) ADD32ItoR(ECX, s_nAddMemOffset); CMP32MtoR(ECX, (u32)&maxrecmem); if( s_bCachingMem & 2 ) j32Ptr[5] = JAE32(0); else j8Ptr[1] = JAE8(0); MOV32RtoM((u32)&s_tempaddr, ECX); if( bit < 32 ) AND8ItoR(ECX, 0xfc); if( bit <= 32 ) CALLFunc((u32)recWriteMemClear32); else if( bit == 64 ) CALLFunc((u32)recWriteMemClear64); else CALLFunc((u32)recWriteMemClear128); MOV32MtoR(ECX, (u32)&s_tempaddr); if( off < 0 ) ADD32ItoR(ECX, -off); else ADD32ItoR(ECX, off); if( bit < 32 ) AND8ItoR(ECX, 0xfc); if( bit <= 32 ) CALLFunc((u32)recWriteMemClear32); else if( bit == 64 ) CALLFunc((u32)recWriteMemClear64); else CALLFunc((u32)recWriteMemClear128); if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); recStore_call(bit, _Rt_, s_nAddMemOffset); MOV32MtoR(ECX, (u32)&s_tempaddr); recStore_call(bit, nextrt, s_nAddMemOffset+_Imm_co_-_Imm_); if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[5]); else x86SetJ8(j8Ptr[1]); } _clearNeededMMXregs(); // needed since allocing _clearNeededXMMregs(); // needed since allocing } void recSB( void ) { recStore(8, _Imm_, 1); } void recSB_co( void ) { recStore_co(8, 1); } void recSH( void ) { recStore(16, _Imm_, 1); } void recSH_co( void ) { recStore_co(16, 1); } void recSW( void ) { recStore(32, _Imm_, 1); } void recSW_co( void ) { recStore_co(32, 1); } //////////////////////////////////////////////////// void recSWL_co(void) { recStore(32, _Imm_-3, 0); } void recSWL( void ) { #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { int shift = (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&3; recMemConstRead32(EAX, (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~3); _eeMoveGPRtoR(ECX, _Rt_); AND32ItoR(EAX, 0xffffff00<<(shift*8)); SHR32ItoR(ECX, 24-shift*8); OR32RtoR(EAX, ECX); if( recMemConstWrite32((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~3, EAX) ) recMemConstClear((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~3, 1); } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 0, 0); MOV32ItoR(EDX, 0x3); AND32RtoR(EDX, ECX); AND32ItoR(ECX, ~3); SHL32ItoR(EDX, 3); // *8 PUSH32R(ECX); XOR32RtoR(EDI, EDI); MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); if( dohw ) { j8Ptr[1] = JMP8(0); SET_HWLOC(); // repeat MOV32ItoR(EDX, 0x3); AND32RtoR(EDX, ECX); AND32ItoR(ECX, ~3); SHL32ItoR(EDX, 3); // *8 PUSH32R(ECX); PUSH32R(EDX); CALLFunc( (int)recMemRead32 ); POP32R(EDX); MOV8ItoR(EDI, 0xff); x86SetJ8(j8Ptr[1]); } _eeMoveGPRtoR(EBX, _Rt_); // oldmem is in EAX // mem >> SWL_SHIFT[shift] MOV32ItoR(ECX, 24); SUB32RtoR(ECX, EDX); SHR32CLtoR(EBX); // mov temp and compute _rt_ & SWL_MASK[shift] MOV32RtoR(ECX, EDX); MOV32ItoR(EDX, 0xffffff00); SHL32CLtoR(EDX); AND32RtoR(EAX, EDX); // combine OR32RtoR(EAX, EBX); POP32R(ECX); // read the old mem again TEST32RtoR(EDI, EDI); j8Ptr[0] = JNZ8(0); // manual write MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset); j8Ptr[1] = JMP8(0); x86SetJ8(j8Ptr[0]); CALLFunc( (int)recMemWrite32 ); x86SetJ8(j8Ptr[1]); } } //////////////////////////////////////////////////// void recSWR_co(void) { recStore(32, _Imm_, 0); } void recSWR( void ) { #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { int shift = (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&3; recMemConstRead32(EAX, (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~3); _eeMoveGPRtoR(ECX, _Rt_); AND32ItoR(EAX, 0x00ffffff>>(24-shift*8)); SHL32ItoR(ECX, shift*8); OR32RtoR(EAX, ECX); if( recMemConstWrite32((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~3, EAX) ) recMemConstClear((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~3, 1); } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 0, 0); MOV32ItoR(EDX, 0x3); AND32RtoR(EDX, ECX); AND32ItoR(ECX, ~3); SHL32ItoR(EDX, 3); // *8 PUSH32R(ECX); XOR32RtoR(EDI, EDI); MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); if( dohw ) { j8Ptr[1] = JMP8(0); SET_HWLOC(); // repeat MOV32ItoR(EDX, 0x3); AND32RtoR(EDX, ECX); AND32ItoR(ECX, ~3); SHL32ItoR(EDX, 3); // *8 PUSH32R(ECX); PUSH32R(EDX); CALLFunc( (int)recMemRead32 ); POP32R(EDX); MOV8ItoR(EDI, 0xff); x86SetJ8(j8Ptr[1]); } _eeMoveGPRtoR(EBX, _Rt_); // oldmem is in EAX // mem << SWR_SHIFT[shift] MOV32RtoR(ECX, EDX); SHL32CLtoR(EBX); // mov temp and compute _rt_ & SWR_MASK[shift] MOV32ItoR(ECX, 24); SUB32RtoR(ECX, EDX); MOV32ItoR(EDX, 0x00ffffff); SHR32CLtoR(EDX); AND32RtoR(EAX, EDX); // combine OR32RtoR(EAX, EBX); POP32R(ECX); // read the old mem again TEST32RtoR(EDI, EDI); j8Ptr[0] = JNZ8(0); // manual write MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset); j8Ptr[1] = JMP8(0); x86SetJ8(j8Ptr[0]); CALLFunc( (int)recMemWrite32 ); x86SetJ8(j8Ptr[1]); } } void recSD( void ) { recStore(64, _Imm_, 1); } void recSD_co( void ) { recStore_co(64, 1); } // coissues more than 2 SDs void recSD_coX(int num, int align) { int i; int mmreg = -1; int nextrts[XMMREGS]; u32 mask = align ? ~7 : ~0; assert( num > 1 && num < XMMREGS ); for(i = 0; i < num; ++i) { nextrts[i] = ((*(u32*)(PSM(pc+i*4)) >> 16) & 0x1F); } #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { int minimm = _Imm_; int t0reg = -1; int doclear = 0; if( GPR_IS_CONST1(_Rt_) ) mmreg = MEM_EECONSTTAG|(_Rt_<<16); else if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, _Rt_, MODE_READ)) >= 0 ) { mmreg |= MEM_XMMTAG|(_Rt_<<16); } else mmreg = _allocMMXreg(-1, MMX_GPR+_Rt_, MODE_READ)|MEM_MMXTAG|(_Rt_<<16); doclear |= recMemConstWrite64((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&mask, mmreg); for(i = 0; i < num; ++i) { int imm = (*(s16*)PSM(pc+i*4)); if( minimm > imm ) minimm = imm; if( GPR_IS_CONST1(nextrts[i]) ) mmreg = MEM_EECONSTTAG|(nextrts[i]<<16); else if( (mmreg = _checkXMMreg(XMMTYPE_GPRREG, nextrts[i], MODE_READ)) >= 0 ) { mmreg |= MEM_XMMTAG|(nextrts[i]<<16); } else mmreg = _allocMMXreg(-1, MMX_GPR+nextrts[i], MODE_READ)|MEM_MMXTAG|(nextrts[i]<<16); doclear |= recMemConstWrite64((g_cpuConstRegs[_Rs_].UL[0]+(*(s16*)PSM(pc+i*4)))&mask, mmreg); } if( doclear ) { u32* ptr; CMP32ItoM((u32)&maxrecmem, g_cpuConstRegs[_Rs_].UL[0]+minimm); ptr = JB32(0); recMemConstClear((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~7, 4); for(i = 0; i < num; ++i) { recMemConstClear((g_cpuConstRegs[_Rs_].UL[0]+(*(s16*)PSM(pc+i*4)))&~7, 2); } x86SetJ32A(ptr); } } else #endif { int dohw; int mmregs = _eePrepareReg_coX(_Rs_, num); int minoff = 0; dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, align, 1); recStore_raw(g_pCurInstInfo, 64, EAX, _Rt_, s_nAddMemOffset); for(i = 0; i < num; ++i) { recStore_raw(g_pCurInstInfo+i+1, 64, EAX, nextrts[i], s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_); } // clear the writes minoff = _Imm_; for(i = 0; i < num; ++i) { if( minoff > (*(s16*)PSM(pc+i*4)) ) minoff = (*(s16*)PSM(pc+i*4)); } if( s_nAddMemOffset || minoff != _Imm_ ) ADD32ItoR(ECX, s_nAddMemOffset+minoff-_Imm_); CMP32MtoR(ECX, (u32)&maxrecmem); if( s_bCachingMem & 2 ) j32Ptr[5] = JAE32(0); else j8Ptr[1] = JAE8(0); MOV32RtoM((u32)&s_tempaddr, ECX); if( minoff != _Imm_ ) ADD32ItoR(ECX, _Imm_-minoff); CALLFunc((u32)recWriteMemClear64); for(i = 0; i < num; ++i) { MOV32MtoR(ECX, (u32)&s_tempaddr); if( minoff != (*(s16*)PSM(pc+i*4)) ) ADD32ItoR(ECX, (*(s16*)PSM(pc+i*4))-minoff); CALLFunc((u32)recWriteMemClear64); } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); recStore_call(64, _Rt_, s_nAddMemOffset); for(i = 0; i < num; ++i) { MOV32MtoR(ECX, (u32)&s_tempaddr); recStore_call(64, nextrts[i], s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_); } if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[5]); else x86SetJ8(j8Ptr[1]); _clearNeededMMXregs(); // needed since allocing _clearNeededXMMregs(); // needed since allocing } } //////////////////////////////////////////////////// void recSDL_co(void) { recStore(64, _Imm_-7, 0); } void recSDL( void ) { iFlushCall(FLUSH_NOCONST); if( GPR_IS_CONST1( _Rs_ ) ) { // flush temporarily MOV32ItoM((int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ], g_cpuConstRegs[_Rs_].UL[0]); //MOV32ItoM((int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 1 ], g_cpuConstRegs[_Rs_].UL[1]); } if( GPR_IS_CONST1( _Rt_ ) && !(g_cpuFlushedConstReg&(1<<_Rt_)) ) { MOV32ItoM((int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ], g_cpuConstRegs[_Rt_].UL[0]); MOV32ItoM((int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 1 ], g_cpuConstRegs[_Rt_].UL[1]); g_cpuFlushedConstReg |= (1<<_Rt_); } MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)SDL ); } //////////////////////////////////////////////////// void recSDR_co(void) { recStore(64, _Imm_, 0); } void recSDR( void ) { iFlushCall(FLUSH_NOCONST); if( GPR_IS_CONST1( _Rs_ ) ) { // flush temporarily MOV32ItoM((int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ], g_cpuConstRegs[_Rs_].UL[0]); //MOV32ItoM((int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 1 ], g_cpuConstRegs[_Rs_].UL[1]); } if( GPR_IS_CONST1( _Rt_ ) && !(g_cpuFlushedConstReg&(1<<_Rt_)) ) { MOV32ItoM((int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ], g_cpuConstRegs[_Rt_].UL[0]); MOV32ItoM((int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 1 ], g_cpuConstRegs[_Rt_].UL[1]); g_cpuFlushedConstReg |= (1<<_Rt_); } MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)SDR ); } //////////////////////////////////////////////////// void recSQ( void ) { recStore(128, _Imm_, 1); } void recSQ_co( void ) { recStore_co(128, 1); } // coissues more than 2 SQs void recSQ_coX(int num) { int i; int mmreg = -1; int nextrts[XMMREGS]; assert( num > 1 && num < XMMREGS ); for(i = 0; i < num; ++i) { nextrts[i] = ((*(u32*)(PSM(pc+i*4)) >> 16) & 0x1F); } #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { int minimm = _Imm_; int t0reg = -1; int doclear = 0; mmreg = _eePrepConstWrite128(_Rt_); doclear |= recMemConstWrite128((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~15, mmreg); for(i = 0; i < num; ++i) { int imm = (*(s16*)PSM(pc+i*4)); if( minimm > imm ) minimm = imm; mmreg = _eePrepConstWrite128(nextrts[i]); doclear |= recMemConstWrite128((g_cpuConstRegs[_Rs_].UL[0]+imm)&~15, mmreg); } if( doclear ) { u32* ptr; CMP32ItoM((u32)&maxrecmem, g_cpuConstRegs[_Rs_].UL[0]+minimm); ptr = JB32(0); recMemConstClear((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~15, 4); for(i = 0; i < num; ++i) { recMemConstClear((g_cpuConstRegs[_Rs_].UL[0]+(*(s16*)PSM(pc+i*4)))&~15, 4); } x86SetJ32A(ptr); } } else #endif { int dohw; int mmregs = _eePrepareReg_coX(_Rs_, num); int minoff = 0; dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 2, 1); recStore_raw(g_pCurInstInfo, 128, EAX, _Rt_, s_nAddMemOffset); for(i = 0; i < num; ++i) { recStore_raw(g_pCurInstInfo+i+1, 128, EAX, nextrts[i], s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_); } // clear the writes minoff = _Imm_; for(i = 0; i < num; ++i) { if( minoff > (*(s16*)PSM(pc+i*4)) ) minoff = (*(s16*)PSM(pc+i*4)); } if( s_nAddMemOffset || minoff != _Imm_ ) ADD32ItoR(ECX, s_nAddMemOffset+minoff-_Imm_); CMP32MtoR(ECX, (u32)&maxrecmem); if( s_bCachingMem & 2 ) j32Ptr[5] = JAE32(0); else j8Ptr[1] = JAE8(0); MOV32RtoM((u32)&s_tempaddr, ECX); if( minoff != _Imm_ ) ADD32ItoR(ECX, _Imm_-minoff); CALLFunc((u32)recWriteMemClear128); for(i = 0; i < num; ++i) { MOV32MtoR(ECX, (u32)&s_tempaddr); if( minoff != (*(s16*)PSM(pc+i*4)) ) ADD32ItoR(ECX, (*(s16*)PSM(pc+i*4))-minoff); CALLFunc((u32)recWriteMemClear128); } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); recStore_call(128, _Rt_, s_nAddMemOffset); for(i = 0; i < num; ++i) { MOV32MtoR(ECX, (u32)&s_tempaddr); recStore_call(128, nextrts[i], s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_); } if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[5]); else x86SetJ8(j8Ptr[1]); _clearNeededMMXregs(); // needed since allocing _clearNeededXMMregs(); // needed since allocing } } /********************************************************* * Load and store for COP1 * * Format: OP rt, offset(base) * *********************************************************/ //////////////////////////////////////////////////// void recLWC1( void ) { #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { int mmreg; assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_) % 4 == 0 ); mmreg = _allocCheckFPUtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG; else mmreg = EAX; if( recMemConstRead32(mmreg, g_cpuConstRegs[_Rs_].UL[0]+_Imm_) ) { if( mmreg&MEM_XMMTAG ) xmmregs[mmreg&0xf].inuse = 0; mmreg = EAX; } if( !(mmreg&MEM_XMMTAG) ) MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EAX ); } else #endif { int dohw; int regt = _allocCheckFPUtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE); int mmregs = _eePrepareReg(_Rs_); _deleteMMXreg(MMX_FPU+_Rt_, 2); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 0, 0); if( regt >= 0 ) { SSEX_MOVD_RmOffset_to_XMM(regt, ECX, PS2MEM_BASE_+s_nAddMemOffset); } else { MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EAX ); } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); iMemRead32Check(); CALLFunc( (int)recMemRead32 ); if( regt >= 0 ) SSE2_MOVD_R_to_XMM(regt, EAX); else MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EAX ); if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } } } void recLWC1_co( void ) { int nextrt = ((*(u32*)(PSM(pc)) >> 16) & 0x1F); #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { u32 written = 0; int ineax, mmreg1, mmreg2; mmreg1 = _allocCheckFPUtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE); if( mmreg1 >= 0 ) mmreg1 |= MEM_XMMTAG; else mmreg1 = EBX; mmreg2 = _allocCheckFPUtoXMM(g_pCurInstInfo+1, nextrt, MODE_WRITE); if( mmreg2 >= 0 ) mmreg2 |= MEM_XMMTAG; else mmreg2 = EAX; assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_) % 4 == 0 ); if( recMemConstRead32(mmreg1, g_cpuConstRegs[_Rs_].UL[0]+_Imm_) ) { if( mmreg1&MEM_XMMTAG ) xmmregs[mmreg1&0xf].inuse = 0; MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EBX ); written = 1; } ineax = recMemConstRead32(mmreg2, g_cpuConstRegs[_Rs_].UL[0]+_Imm_co_); if( !written ) { if( !(mmreg1&MEM_XMMTAG) ) MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EBX ); } if( ineax || !(mmreg2 & MEM_XMMTAG) ) { if( mmreg2&MEM_XMMTAG ) xmmregs[mmreg2&0xf].inuse = 0; MOV32RtoM( (int)&fpuRegs.fpr[ nextrt ].UL, EAX ); } } else #endif { int dohw; int regt, regtnext; int mmregs = _eePrepareReg(_Rs_); _deleteMMXreg(MMX_FPU+_Rt_, 2); regt = _allocCheckFPUtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE); regtnext = _allocCheckFPUtoXMM(g_pCurInstInfo+1, nextrt, MODE_WRITE); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 0, 0); if( regt >= 0 ) { SSEX_MOVD_RmOffset_to_XMM(regt, ECX, PS2MEM_BASE_+s_nAddMemOffset); } else { MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EAX ); } if( regtnext >= 0 ) { SSEX_MOVD_RmOffset_to_XMM(regtnext, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } else { MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); MOV32RtoM( (int)&fpuRegs.fpr[ nextrt ].UL, EAX ); } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); PUSH32R(ECX); CALLFunc( (int)recMemRead32 ); POP32R(ECX); if( regt >= 0 ) { SSE2_MOVD_R_to_XMM(regt, EAX); } else { MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EAX ); } ADD32ItoR(ECX, _Imm_co_-_Imm_); CALLFunc( (int)recMemRead32 ); if( regtnext >= 0 ) { SSE2_MOVD_R_to_XMM(regtnext, EAX); } else { MOV32RtoM( (int)&fpuRegs.fpr[ nextrt ].UL, EAX ); } if( s_bCachingMem & 2 ) x86SetJ32A(j32Ptr[4]); else x86SetJ8A(j8Ptr[2]); } } } void recLWC1_coX(int num) { int i; int mmreg = -1; int mmregs[XMMREGS]; int nextrts[XMMREGS]; assert( num > 1 && num < XMMREGS ); #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { int ineax; u32 written = 0; mmreg = _allocCheckFPUtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG; else mmreg = EAX; assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_) % 4 == 0 ); if( recMemConstRead32(mmreg, g_cpuConstRegs[_Rs_].UL[0]+_Imm_) ) { if( mmreg&MEM_XMMTAG ) xmmregs[mmreg&0xf].inuse = 0; MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EBX ); written = 1; } else if( !IS_XMMREG(mmreg) ) MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EAX ); // recompile two at a time for(i = 0; i < num-1; i += 2) { nextrts[0] = ((*(u32*)(PSM(pc+i*4)) >> 16) & 0x1F); nextrts[1] = ((*(u32*)(PSM(pc+i*4+4)) >> 16) & 0x1F); written = 0; mmregs[0] = _allocCheckFPUtoXMM(g_pCurInstInfo+i+1, nextrts[0], MODE_WRITE); if( mmregs[0] >= 0 ) mmregs[0] |= MEM_XMMTAG; else mmregs[0] = EBX; mmregs[1] = _allocCheckFPUtoXMM(g_pCurInstInfo+i+2, nextrts[1], MODE_WRITE); if( mmregs[1] >= 0 ) mmregs[1] |= MEM_XMMTAG; else mmregs[1] = EAX; assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_) % 4 == 0 ); if( recMemConstRead32(mmregs[0], g_cpuConstRegs[_Rs_].UL[0]+(*(s16*)PSM(pc+i*4))) ) { if( mmregs[0]&MEM_XMMTAG ) xmmregs[mmregs[0]&0xf].inuse = 0; MOV32RtoM( (int)&fpuRegs.fpr[ nextrts[0] ].UL, EBX ); written = 1; } ineax = recMemConstRead32(mmregs[1], g_cpuConstRegs[_Rs_].UL[0]+(*(s16*)PSM(pc+i*4+4))); if( !written ) { if( !(mmregs[0]&MEM_XMMTAG) ) MOV32RtoM( (int)&fpuRegs.fpr[ nextrts[0] ].UL, EBX ); } if( ineax || !(mmregs[1] & MEM_XMMTAG) ) { if( mmregs[1]&MEM_XMMTAG ) xmmregs[mmregs[1]&0xf].inuse = 0; MOV32RtoM( (int)&fpuRegs.fpr[ nextrts[1] ].UL, EAX ); } } if( i < num ) { // one left int nextrt = ((*(u32*)(PSM(pc+i*4)) >> 16) & 0x1F); mmreg = _allocCheckFPUtoXMM(g_pCurInstInfo+i+1, nextrt, MODE_WRITE); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG; else mmreg = EAX; assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_) % 4 == 0 ); if( recMemConstRead32(mmreg, g_cpuConstRegs[_Rs_].UL[0]+(*(s16*)PSM(pc+i*4))) ) { if( mmreg&MEM_XMMTAG ) xmmregs[mmreg&0xf].inuse = 0; MOV32RtoM( (int)&fpuRegs.fpr[ nextrt ].UL, EBX ); written = 1; } else if( !IS_XMMREG(mmreg) ) MOV32RtoM( (int)&fpuRegs.fpr[ nextrt ].UL, EAX ); } } else #endif { int dohw; int mmregS = _eePrepareReg_coX(_Rs_, num); _deleteMMXreg(MMX_FPU+_Rt_, 2); for(i = 0; i < num; ++i) { nextrts[i] = ((*(u32*)(PSM(pc+i*4)) >> 16) & 0x1F); _deleteMMXreg(MMX_FPU+nextrts[i], 2); } mmreg = _allocCheckFPUtoXMM(g_pCurInstInfo, _Rt_, MODE_WRITE); for(i = 0; i < num; ++i) { mmregs[i] = _allocCheckFPUtoXMM(g_pCurInstInfo+i+1, nextrts[i], MODE_WRITE); } dohw = recSetMemLocation(_Rs_, _Imm_, mmregS, 0, 1); if( mmreg >= 0 ) { SSEX_MOVD_RmOffset_to_XMM(mmreg, ECX, PS2MEM_BASE_+s_nAddMemOffset); } else { MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset); MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EAX ); } for(i = 0; i < num; ++i) { if( mmregs[i] >= 0 ) { SSEX_MOVD_RmOffset_to_XMM(mmregs[i], ECX, PS2MEM_BASE_+s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_); } else { MOV32RmtoROffset(EAX, ECX, PS2MEM_BASE_+s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_); MOV32RtoM( (int)&fpuRegs.fpr[ nextrts[i] ].UL, EAX ); } } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); CALLFunc( (int)recMemRead32 ); if( mmreg >= 0 ) SSE2_MOVD_R_to_XMM(mmreg, EAX); else MOV32RtoM( (int)&fpuRegs.fpr[ _Rt_ ].UL, EAX ); for(i = 0; i < num; ++i) { MOV32MtoR(ECX, (u32)&s_tempaddr); ADD32ItoR(ECX, (*(s16*)PSM(pc+i*4))-_Imm_); CALLFunc( (int)recMemRead32 ); if( mmregs[i] >= 0 ) SSE2_MOVD_R_to_XMM(mmregs[i], EAX); else MOV32RtoM( (int)&fpuRegs.fpr[ nextrts[i] ].UL, EAX ); } if( s_bCachingMem & 2 ) x86SetJ32A(j32Ptr[4]); else x86SetJ8A(j8Ptr[2]); } } } //////////////////////////////////////////////////// void recSWC1( void ) { int mmreg; #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)%4 == 0 ); mmreg = _checkXMMreg(XMMTYPE_FPREG, _Rt_, MODE_READ); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG|(_Rt_<<16); else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); mmreg = EAX; } recMemConstWrite32(g_cpuConstRegs[_Rs_].UL[0]+_Imm_, mmreg); } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); assert( _checkMMXreg(MMX_FPU+_Rt_, MODE_READ) == -1 ); mmreg = _checkXMMreg(XMMTYPE_FPREG, _Rt_, MODE_READ); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 0, 0); if( mmreg >= 0) { SSEX_MOVD_XMM_to_RmOffset(ECX, mmreg, PS2MEM_BASE_+s_nAddMemOffset); } else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset); } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); // some type of hardware write if( mmreg >= 0) SSE2_MOVD_XMM_to_R(EAX, mmreg); else MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); CALLFunc( (int)recMemWrite32 ); if( s_bCachingMem & 2 ) x86SetJ32(j32Ptr[4]); else x86SetJ8(j8Ptr[2]); } } } void recSWC1_co( void ) { int nextrt = ((*(u32*)(PSM(pc)) >> 16) & 0x1F); #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { int mmreg; assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)%4 == 0 ); mmreg = _checkXMMreg(XMMTYPE_FPREG, _Rt_, MODE_READ); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG|(_Rt_<<16); else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); mmreg = EAX; } recMemConstWrite32(g_cpuConstRegs[_Rs_].UL[0]+_Imm_, mmreg); mmreg = _checkXMMreg(XMMTYPE_FPREG, nextrt, MODE_READ); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG|(nextrt<<16); else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ nextrt ].UL); mmreg = EAX; } recMemConstWrite32(g_cpuConstRegs[_Rs_].UL[0]+_Imm_co_, mmreg); } else #endif { int dohw; int mmregs = _eePrepareReg(_Rs_); int mmreg1, mmreg2; assert( _checkMMXreg(MMX_FPU+_Rt_, MODE_READ) == -1 ); assert( _checkMMXreg(MMX_FPU+nextrt, MODE_READ) == -1 ); mmreg1 = _checkXMMreg(XMMTYPE_FPREG, _Rt_, MODE_READ); mmreg2 = _checkXMMreg(XMMTYPE_FPREG, nextrt, MODE_READ); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 0, 0); if(mmreg1 >= 0 ) { if( mmreg2 >= 0 ) { SSEX_MOVD_XMM_to_RmOffset(ECX, mmreg1, PS2MEM_BASE_+s_nAddMemOffset); SSEX_MOVD_XMM_to_RmOffset(ECX, mmreg2, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ nextrt ].UL); SSEX_MOVD_XMM_to_RmOffset(ECX, mmreg1, PS2MEM_BASE_+s_nAddMemOffset); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } } else { if( mmreg2 >= 0 ) { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); SSEX_MOVD_XMM_to_RmOffset(ECX, mmreg2, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset); } else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); MOV32MtoR(EDX, (int)&fpuRegs.fpr[ nextrt ].UL); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); // some type of hardware write if( mmreg1 >= 0) SSE2_MOVD_XMM_to_R(EAX, mmreg1); else MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); CALLFunc( (int)recMemWrite32 ); MOV32MtoR(ECX, (u32)&s_tempaddr); ADD32ItoR(ECX, _Imm_co_-_Imm_); if( mmreg2 >= 0) SSE2_MOVD_XMM_to_R(EAX, mmreg2); else MOV32MtoR(EAX, (int)&fpuRegs.fpr[ nextrt ].UL); CALLFunc( (int)recMemWrite32 ); if( s_bCachingMem & 2 ) x86SetJ32A(j32Ptr[4]); else x86SetJ8A(j8Ptr[2]); } } } void recSWC1_coX(int num) { int i; int mmreg = -1; int mmregs[XMMREGS]; int nextrts[XMMREGS]; assert( num > 1 && num < XMMREGS ); for(i = 0; i < num; ++i) { nextrts[i] = ((*(u32*)(PSM(pc+i*4)) >> 16) & 0x1F); } #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)%4 == 0 ); mmreg = _checkXMMreg(XMMTYPE_FPREG, _Rt_, MODE_READ); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG|(_Rt_<<16); else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); mmreg = EAX; } recMemConstWrite32(g_cpuConstRegs[_Rs_].UL[0]+_Imm_, mmreg); for(i = 0; i < num; ++i) { mmreg = _checkXMMreg(XMMTYPE_FPREG, nextrts[i], MODE_READ); if( mmreg >= 0 ) mmreg |= MEM_XMMTAG|(nextrts[i]<<16); else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ nextrts[i] ].UL); mmreg = EAX; } recMemConstWrite32(g_cpuConstRegs[_Rs_].UL[0]+(*(s16*)PSM(pc+i*4)), mmreg); } } else #endif { int dohw; int mmregS = _eePrepareReg_coX(_Rs_, num); assert( _checkMMXreg(MMX_FPU+_Rt_, MODE_READ) == -1 ); mmreg = _checkXMMreg(XMMTYPE_FPREG, _Rt_, MODE_READ); for(i = 0; i < num; ++i) { assert( _checkMMXreg(MMX_FPU+nextrts[i], MODE_READ) == -1 ); mmregs[i] = _checkXMMreg(XMMTYPE_FPREG, nextrts[i], MODE_READ); } dohw = recSetMemLocation(_Rs_, _Imm_, mmregS, 0, 1); if( mmreg >= 0) { SSEX_MOVD_XMM_to_RmOffset(ECX, mmreg, PS2MEM_BASE_+s_nAddMemOffset); } else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset); } for(i = 0; i < num; ++i) { if( mmregs[i] >= 0) { SSEX_MOVD_XMM_to_RmOffset(ECX, mmregs[i], PS2MEM_BASE_+s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_); } else { MOV32MtoR(EAX, (int)&fpuRegs.fpr[ nextrts[i] ].UL); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset+(*(s16*)PSM(pc+i*4))-_Imm_); } } if( dohw ) { if( s_bCachingMem & 2 ) j32Ptr[4] = JMP32(0); else j8Ptr[2] = JMP8(0); SET_HWLOC(); MOV32RtoM((u32)&s_tempaddr, ECX); // some type of hardware write if( mmreg >= 0) SSE2_MOVD_XMM_to_R(EAX, mmreg); else MOV32MtoR(EAX, (int)&fpuRegs.fpr[ _Rt_ ].UL); CALLFunc( (int)recMemWrite32 ); for(i = 0; i < num; ++i) { MOV32MtoR(ECX, (u32)&s_tempaddr); ADD32ItoR(ECX, (*(s16*)PSM(pc+i*4))-_Imm_); if( mmregs[i] >= 0 && (xmmregs[mmregs[i]].mode&MODE_WRITE) ) SSE2_MOVD_XMM_to_R(EAX, mmregs[i]); else MOV32MtoR(EAX, (int)&fpuRegs.fpr[ nextrts[i] ].UL); CALLFunc( (int)recMemWrite32 ); } if( s_bCachingMem & 2 ) x86SetJ32A(j32Ptr[4]); else x86SetJ8A(j8Ptr[2]); } } } //////////////////////////////////////////////////// #define _Ft_ _Rt_ #define _Fs_ _Rd_ #define _Fd_ _Sa_ void recLQC2( void ) { int mmreg; #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( cpucaps.hasStreamingSIMDExtensions && GPR_IS_CONST1( _Rs_ ) ) { assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_) % 16 == 0 ); if( _Ft_ ) mmreg = _allocVFtoXMMreg(&VU0, -1, _Ft_, MODE_WRITE); else mmreg = _allocTempXMMreg(XMMT_FPS, -1); recMemConstRead128((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~15, mmreg); if( !_Ft_ ) _freeXMMreg(mmreg); } else #endif { int dohw, mmregs; if( !cpucaps.hasStreamingSIMDExtensions && GPR_IS_CONST1( _Rs_ ) ) { _flushConstReg(_Rs_); } mmregs = _eePrepareReg(_Rs_); if( _Ft_ ) mmreg = _allocVFtoXMMreg(&VU0, -1, _Ft_, MODE_WRITE); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 2, 0); if( _Ft_ ) { s8* rawreadptr = x86Ptr; if( mmreg >= 0 ) { SSEX_MOVDQARmtoROffset(mmreg, ECX, PS2MEM_BASE_+s_nAddMemOffset); } else { _recMove128RmOffsettoM((u32)&VU0.VF[_Ft_].UL[0], PS2MEM_BASE_+s_nAddMemOffset); } if( dohw ) { j8Ptr[1] = JMP8(0); SET_HWLOC(); // check if writing to VUs CMP32ItoR(ECX, 0x11000000); JAE8(rawreadptr - (x86Ptr+2)); PUSH32I( (int)&VU0.VF[_Ft_].UD[0] ); CALLFunc( (int)recMemRead128 ); if( mmreg >= 0 ) SSEX_MOVDQA_M128_to_XMM(mmreg, (int)&VU0.VF[_Ft_].UD[0] ); ADD32ItoR(ESP, 4); x86SetJ8(j8Ptr[1]); } } else { if( dohw ) { j8Ptr[1] = JMP8(0); SET_HWLOC(); PUSH32I( (int)&retValues[0] ); CALLFunc( (int)recMemRead128 ); ADD32ItoR(ESP, 4); x86SetJ8(j8Ptr[1]); } } } _clearNeededXMMregs(); // needed since allocing } void recLQC2_co( void ) { int mmreg1 = -1, mmreg2 = -1, t0reg = -1; int nextrt = ((*(u32*)(PSM(pc)) >> 16) & 0x1F); #ifdef REC_SLOWREAD _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_) % 16 == 0 ); if( _Ft_ ) mmreg1 = _allocVFtoXMMreg(&VU0, -1, _Ft_, MODE_WRITE); else t0reg = _allocTempXMMreg(XMMT_FPS, -1); recMemConstRead128((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~15, mmreg1 >= 0 ? mmreg1 : t0reg); if( nextrt ) mmreg2 = _allocVFtoXMMreg(&VU0, -1, nextrt, MODE_WRITE); else if( t0reg < 0 ) t0reg = _allocTempXMMreg(XMMT_FPS, -1); recMemConstRead128((g_cpuConstRegs[_Rs_].UL[0]+_Imm_co_)&~15, mmreg2 >= 0 ? mmreg2 : t0reg); if( t0reg >= 0 ) _freeXMMreg(t0reg); } else #endif { s8* rawreadptr; int dohw; int mmregs = _eePrepareReg(_Rs_); if( _Ft_ ) mmreg1 = _allocVFtoXMMreg(&VU0, -1, _Ft_, MODE_WRITE); if( nextrt ) mmreg2 = _allocVFtoXMMreg(&VU0, -1, nextrt, MODE_WRITE); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 2, 0); rawreadptr = x86Ptr; if( mmreg1 >= 0 ) SSEX_MOVDQARmtoROffset(mmreg1, ECX, PS2MEM_BASE_+s_nAddMemOffset); if( mmreg2 >= 0 ) SSEX_MOVDQARmtoROffset(mmreg2, ECX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); if( dohw ) { j8Ptr[1] = JMP8(0); SET_HWLOC(); // check if writing to VUs CMP32ItoR(ECX, 0x11000000); JAE8(rawreadptr - (x86Ptr+2)); MOV32RtoM((u32)&s_tempaddr, ECX); if( _Ft_ ) PUSH32I( (int)&VU0.VF[_Ft_].UD[0] ); else PUSH32I( (int)&retValues[0] ); CALLFunc( (int)recMemRead128 ); if( mmreg1 >= 0 ) SSEX_MOVDQA_M128_to_XMM(mmreg1, (int)&VU0.VF[_Ft_].UD[0] ); MOV32MtoR(ECX, (u32)&s_tempaddr); ADD32ItoR(ECX, _Imm_co_-_Imm_); if( nextrt ) MOV32ItoRmOffset(ESP, (int)&VU0.VF[nextrt].UD[0], 0 ); else MOV32ItoRmOffset(ESP, (int)&retValues[0], 0 ); CALLFunc( (int)recMemRead128 ); if( mmreg2 >= 0 ) SSEX_MOVDQA_M128_to_XMM(mmreg2, (int)&VU0.VF[nextrt].UD[0] ); ADD32ItoR(ESP, 4); x86SetJ8(j8Ptr[1]); } } _clearNeededXMMregs(); // needed since allocing } //////////////////////////////////////////////////// void recSQC2( void ) { int mmreg; #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( cpucaps.hasStreamingSIMDExtensions && GPR_IS_CONST1( _Rs_ ) ) { assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)%16 == 0 ); mmreg = _allocVFtoXMMreg(&VU0, -1, _Ft_, MODE_READ)|MEM_XMMTAG; recMemConstWrite128((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~15, mmreg); } else #endif { s8* rawreadptr; int dohw, mmregs; if( cpucaps.hasStreamingSIMDExtensions && GPR_IS_CONST1( _Rs_ ) ) { _flushConstReg(_Rs_); } mmregs = _eePrepareReg(_Rs_); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 2, 0); rawreadptr = x86Ptr; if( (mmreg = _checkXMMreg(XMMTYPE_VFREG, _Ft_, MODE_READ)) >= 0) { SSEX_MOVDQARtoRmOffset(ECX, mmreg, PS2MEM_BASE_+s_nAddMemOffset); } else { if( _hasFreeXMMreg() ) { mmreg = _allocTempXMMreg(XMMT_FPS, -1); SSEX_MOVDQA_M128_to_XMM(mmreg, (int)&VU0.VF[_Ft_].UD[0]); SSEX_MOVDQARtoRmOffset(ECX, mmreg, PS2MEM_BASE_+s_nAddMemOffset); _freeXMMreg(mmreg); } else if( _hasFreeMMXreg() ) { mmreg = _allocMMXreg(-1, MMX_TEMP, 0); MOVQMtoR(mmreg, (int)&VU0.VF[_Ft_].UD[0]); MOVQRtoRmOffset(ECX, mmreg, PS2MEM_BASE_+s_nAddMemOffset); MOVQMtoR(mmreg, (int)&VU0.VF[_Ft_].UL[2]); MOVQRtoRmOffset(ECX, mmreg, PS2MEM_BASE_+s_nAddMemOffset+8); SetMMXstate(); _freeMMXreg(mmreg); } else { MOV32MtoR(EAX, (int)&VU0.VF[_Ft_].UL[0]); MOV32MtoR(EDX, (int)&VU0.VF[_Ft_].UL[1]); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+s_nAddMemOffset+4); MOV32MtoR(EAX, (int)&VU0.VF[_Ft_].UL[2]); MOV32MtoR(EDX, (int)&VU0.VF[_Ft_].UL[3]); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset+8); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+s_nAddMemOffset+12); } } if( dohw ) { j8Ptr[1] = JMP8(0); SET_HWLOC(); // check if writing to VUs CMP32ItoR(ECX, 0x11000000); JAE8(rawreadptr - (x86Ptr+2)); // some type of hardware write if( (mmreg = _checkXMMreg(XMMTYPE_VFREG, _Ft_, MODE_READ)) >= 0) { if( xmmregs[mmreg].mode & MODE_WRITE ) { SSEX_MOVDQA_XMM_to_M128((int)&VU0.VF[_Ft_].UD[0], mmreg); } } MOV32ItoR(EAX, (int)&VU0.VF[_Ft_].UD[0]); CALLFunc( (int)recMemWrite128 ); x86SetJ8A(j8Ptr[1]); } } } void recSQC2_co( void ) { int nextrt = ((*(u32*)(PSM(pc)) >> 16) & 0x1F); int mmreg1, mmreg2; #ifdef REC_SLOWWRITE _flushConstReg(_Rs_); #else if( GPR_IS_CONST1( _Rs_ ) ) { assert( (g_cpuConstRegs[_Rs_].UL[0]+_Imm_)%16 == 0 ); mmreg1 = _allocVFtoXMMreg(&VU0, -1, _Ft_, MODE_READ)|MEM_XMMTAG; mmreg2 = _allocVFtoXMMreg(&VU0, -1, nextrt, MODE_READ)|MEM_XMMTAG; recMemConstWrite128((g_cpuConstRegs[_Rs_].UL[0]+_Imm_)&~15, mmreg1); recMemConstWrite128((g_cpuConstRegs[_Rs_].UL[0]+_Imm_co_)&~15, mmreg2); } else #endif { s8* rawreadptr; int dohw; int mmregs = _eePrepareReg(_Rs_); mmreg1 = _checkXMMreg(XMMTYPE_VFREG, _Ft_, MODE_READ); mmreg2 = _checkXMMreg(XMMTYPE_VFREG, nextrt, MODE_READ); dohw = recSetMemLocation(_Rs_, _Imm_, mmregs, 2, 0); rawreadptr = x86Ptr; if( mmreg1 >= 0 ) { SSEX_MOVDQARtoRmOffset(ECX, mmreg1, PS2MEM_BASE_+s_nAddMemOffset); } else { if( _hasFreeXMMreg() ) { mmreg1 = _allocTempXMMreg(XMMT_FPS, -1); SSEX_MOVDQA_M128_to_XMM(mmreg1, (int)&VU0.VF[_Ft_].UD[0]); SSEX_MOVDQARtoRmOffset(ECX, mmreg1, PS2MEM_BASE_+s_nAddMemOffset); _freeXMMreg(mmreg1); } else if( _hasFreeMMXreg() ) { mmreg1 = _allocMMXreg(-1, MMX_TEMP, 0); MOVQMtoR(mmreg1, (int)&VU0.VF[_Ft_].UD[0]); MOVQRtoRmOffset(ECX, mmreg1, PS2MEM_BASE_+s_nAddMemOffset); MOVQMtoR(mmreg1, (int)&VU0.VF[_Ft_].UL[2]); MOVQRtoRmOffset(ECX, mmreg1, PS2MEM_BASE_+s_nAddMemOffset+8); SetMMXstate(); _freeMMXreg(mmreg1); } else { MOV32MtoR(EAX, (int)&VU0.VF[_Ft_].UL[0]); MOV32MtoR(EDX, (int)&VU0.VF[_Ft_].UL[1]); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+s_nAddMemOffset+4); MOV32MtoR(EAX, (int)&VU0.VF[_Ft_].UL[2]); MOV32MtoR(EDX, (int)&VU0.VF[_Ft_].UL[3]); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset+8); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+s_nAddMemOffset+12); } } if( mmreg2 >= 0 ) { SSEX_MOVDQARtoRmOffset(ECX, mmreg2, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); } else { if( _hasFreeXMMreg() ) { mmreg2 = _allocTempXMMreg(XMMT_FPS, -1); SSEX_MOVDQA_M128_to_XMM(mmreg2, (int)&VU0.VF[nextrt].UD[0]); SSEX_MOVDQARtoRmOffset(ECX, mmreg2, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); _freeXMMreg(mmreg2); } else if( _hasFreeMMXreg() ) { mmreg2 = _allocMMXreg(-1, MMX_TEMP, 0); MOVQMtoR(mmreg2, (int)&VU0.VF[nextrt].UD[0]); MOVQRtoRmOffset(ECX, mmreg2, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); MOVQMtoR(mmreg2, (int)&VU0.VF[nextrt].UL[2]); MOVQRtoRmOffset(ECX, mmreg2, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_+8); SetMMXstate(); _freeMMXreg(mmreg2); } else { MOV32MtoR(EAX, (int)&VU0.VF[nextrt].UL[0]); MOV32MtoR(EDX, (int)&VU0.VF[nextrt].UL[1]); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_+4); MOV32MtoR(EAX, (int)&VU0.VF[nextrt].UL[2]); MOV32MtoR(EDX, (int)&VU0.VF[nextrt].UL[3]); MOV32RtoRmOffset(ECX, EAX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_+8); MOV32RtoRmOffset(ECX, EDX, PS2MEM_BASE_+s_nAddMemOffset+_Imm_co_-_Imm_+12); } } if( dohw ) { j8Ptr[1] = JMP8(0); SET_HWLOC(); // check if writing to VUs CMP32ItoR(ECX, 0x11000000); JAE8(rawreadptr - (x86Ptr+2)); // some type of hardware write if( mmreg1 >= 0) { if( xmmregs[mmreg1].mode & MODE_WRITE ) { SSEX_MOVDQA_XMM_to_M128((int)&VU0.VF[_Ft_].UD[0], mmreg1); } } MOV32RtoM((u32)&s_tempaddr, ECX); MOV32ItoR(EAX, (int)&VU0.VF[_Ft_].UD[0]); CALLFunc( (int)recMemWrite128 ); if( mmreg2 >= 0) { if( xmmregs[mmreg2].mode & MODE_WRITE ) { SSEX_MOVDQA_XMM_to_M128((int)&VU0.VF[nextrt].UD[0], mmreg2); } } MOV32MtoR(ECX, (u32)&s_tempaddr); ADD32ItoR(ECX, _Imm_co_-_Imm_); MOV32ItoR(EAX, (int)&VU0.VF[nextrt].UD[0]); CALLFunc( (int)recMemWrite128 ); x86SetJ8A(j8Ptr[1]); } } } #else PCSX2_ALIGNED16(u32 dummyValue[4]); void SetFastMemory(int bSetFast) { // nothing } //////////////////////////////////////////////////// void recLB( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32I( (int)&dummyValue[0] ); PUSH32R( EAX ); CALLFunc( (int)memRead8 ); ADD32ItoR( ESP, 8 ); if ( _Rt_ ) { u8* linkEnd; TEST32RtoR( EAX, EAX ); linkEnd = JNZ8( 0 ); MOV32MtoR( EAX, (int)&dummyValue[0] ); MOVSX32R8toR( EAX, EAX ); CDQ( ); MOV32RtoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ], EAX ); MOV32RtoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 1 ], EDX ); x86SetJ8( linkEnd ); } } //////////////////////////////////////////////////// void recLBU( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32I( (int)&dummyValue[0] ); PUSH32R( EAX ); CALLFunc( (int)memRead8 ); ADD32ItoR( ESP, 8 ); if ( _Rt_ ) { u8* linkEnd; TEST32RtoR( EAX, EAX ); linkEnd = JNZ8( 0 ); MOV32MtoR( EAX, (int)&dummyValue[0] ); MOVZX32R8toR( EAX, EAX ); MOV32RtoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ], EAX ); MOV32ItoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 1 ], 0 ); x86SetJ8( linkEnd ); } } //////////////////////////////////////////////////// void recLH( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32I( (int)&dummyValue[0] ); PUSH32R( EAX ); CALLFunc( (int)memRead16 ); ADD32ItoR( ESP, 8 ); if ( _Rt_ ) { u8* linkEnd; TEST32RtoR( EAX, EAX ); linkEnd = JNZ8( 0 ); MOV32MtoR( EAX, (int)&dummyValue[0]); MOVSX32R16toR( EAX, EAX ); CDQ( ); MOV32RtoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ], EAX ); MOV32RtoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 1 ], EDX ); x86SetJ8( linkEnd ); } } //////////////////////////////////////////////////// void recLHU( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32I( (int)&dummyValue[0] ); PUSH32R( EAX ); CALLFunc( (int)memRead16 ); ADD32ItoR( ESP, 8 ); if ( _Rt_ ) { u8* linkEnd; TEST32RtoR( EAX, EAX ); linkEnd = JNZ8( 0 ); MOV32MtoR( EAX, (int)&dummyValue[0] ); MOVZX32R16toR( EAX, EAX ); MOV32RtoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ], EAX ); MOV32ItoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 1 ], 0 ); x86SetJ8( linkEnd ); } } //////////////////////////////////////////////////// void recLW( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32I( (int)&dummyValue[0]); PUSH32R( EAX ); CALLFunc( (int)memRead32 ); ADD32ItoR( ESP, 8 ); if ( _Rt_ ) { u8* linkEnd; TEST32RtoR( EAX, EAX ); linkEnd = JNZ8( 0 ); MOV32MtoR( EAX, (int)&dummyValue[0]); CDQ( ); MOV32RtoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ], EAX ); MOV32RtoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 1 ], EDX ); x86SetJ8( linkEnd ); } } //////////////////////////////////////////////////// void recLWU( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32I( (int)&dummyValue[0]); PUSH32R( EAX ); CALLFunc( (int)memRead32 ); ADD32ItoR( ESP, 8 ); if ( _Rt_ ) { u8* linkEnd; TEST32RtoR( EAX, EAX ); linkEnd = JNZ8( 0 ); MOV32MtoR( EAX, (int)&dummyValue[0]); MOV32RtoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ], EAX ); MOV32ItoM( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 1 ], 0 ); x86SetJ8( linkEnd ); } } //////////////////////////////////////////////////// void recLWL( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); _deleteEEreg(_Rt_, 0); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)LWL ); } //////////////////////////////////////////////////// void recLWR( void ) { iFlushCall(FLUSH_EVERYTHING); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)LWR ); } //////////////////////////////////////////////////// extern void MOV64RmtoR( x86IntRegType to, x86IntRegType from ); void recLD( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); EEINST_RESETSIGNEXT(_Rt_); // remove the sign extension _deleteEEreg(_Rt_, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } if ( _Rt_ ) { PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ] ); } else { PUSH32I( (int)&dummyValue[0] ); } PUSH32R( EAX ); CALLFunc( (int)memRead64 ); ADD32ItoR( ESP, 8 ); } //////////////////////////////////////////////////// void recLDL( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); EEINST_RESETSIGNEXT(_Rt_); // remove the sign extension _deleteEEreg(_Rt_, 0); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)LDL ); } //////////////////////////////////////////////////// void recLDR( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); EEINST_RESETSIGNEXT(_Rt_); // remove the sign extension _deleteEEreg(_Rt_, 0); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)LDR ); } //////////////////////////////////////////////////// void recLQ( void ) { _deleteEEreg(_Rs_, 1); _eeOnLoadWrite(_Rt_); EEINST_RESETSIGNEXT(_Rt_); // remove the sign extension _deleteEEreg(_Rt_, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_); } AND32ItoR( EAX, ~0xf ); if ( _Rt_ ) { PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ] ); } else { PUSH32I( (int)&dummyValue[0] ); } PUSH32R( EAX ); CALLFunc( (int)memRead128 ); ADD32ItoR( ESP, 8 ); } //////////////////////////////////////////////////// void recSB( void ) { _deleteEEreg(_Rs_, 1); _deleteEEreg(_Rt_, 1); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_); } PUSH32M( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); PUSH32R( EAX ); CALLFunc( (int)memWrite8 ); ADD32ItoR( ESP, 8 ); } //////////////////////////////////////////////////// void recSH( void ) { _deleteEEreg(_Rs_, 1); _deleteEEreg(_Rt_, 1); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32M( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); PUSH32R( EAX ); CALLFunc( (int)memWrite16 ); ADD32ItoR( ESP, 8 ); } //////////////////////////////////////////////////// void recSW( void ) { _deleteEEreg(_Rs_, 1); _deleteEEreg(_Rt_, 1); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32M( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); PUSH32R( EAX ); CALLFunc( (int)memWrite32 ); ADD32ItoR( ESP, 8 ); } //////////////////////////////////////////////////// void recSWL( void ) { _deleteEEreg(_Rs_, 1); _deleteEEreg(_Rt_, 1); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)SWL ); } //////////////////////////////////////////////////// void recSWR( void ) { _deleteEEreg(_Rs_, 1); _deleteEEreg(_Rt_, 1); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)SWR ); } //////////////////////////////////////////////////// void recSD( void ) { _deleteEEreg(_Rs_, 1); _deleteEEreg(_Rt_, 1); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32M( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 1 ] ); PUSH32M( (int)&cpuRegs.GPR.r[ _Rt_ ].UL[ 0 ] ); PUSH32R( EAX ); CALLFunc( (int)memWrite64 ); ADD32ItoR( ESP, 12 ); } //////////////////////////////////////////////////// void recSDL( void ) { _deleteEEreg(_Rs_, 1); _deleteEEreg(_Rt_, 1); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)SDL ); } //////////////////////////////////////////////////// void recSDR( void ) { _deleteEEreg(_Rs_, 1); _deleteEEreg(_Rt_, 1); MOV32ItoM( (int)&cpuRegs.code, cpuRegs.code ); MOV32ItoM( (int)&cpuRegs.pc, pc ); CALLFunc( (int)SDR ); } //////////////////////////////////////////////////// void recSQ( void ) { _deleteEEreg(_Rs_, 1); _deleteEEreg(_Rt_, 1); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } AND32ItoR( EAX, ~0xf ); PUSH32I( (int)&cpuRegs.GPR.r[ _Rt_ ].UD[ 0 ] ); PUSH32R( EAX ); CALLFunc( (int)memWrite128 ); ADD32ItoR( ESP, 8 ); } /********************************************************* * Load and store for COP1 * * Format: OP rt, offset(base) * *********************************************************/ //////////////////////////////////////////////////// void recLWC1( void ) { _deleteEEreg(_Rs_, 1); _deleteFPtoXMMreg(_Rt_, 2); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32I( (int)&fpuRegs.fpr[ _Rt_ ].UL ); PUSH32R( EAX ); CALLFunc( (int)memRead32 ); ADD32ItoR( ESP, 8 ); } //////////////////////////////////////////////////// void recSWC1( void ) { _deleteEEreg(_Rs_, 1); _deleteFPtoXMMreg(_Rt_, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32M( (int)&fpuRegs.fpr[ _Rt_ ].UL ); PUSH32R( EAX ); CALLFunc( (int)memWrite32 ); ADD32ItoR( ESP, 8 ); } //////////////////////////////////////////////////// #define _Ft_ _Rt_ #define _Fs_ _Rd_ #define _Fd_ _Sa_ void recLQC2( void ) { _deleteEEreg(_Rs_, 1); _deleteVFtoXMMreg(_Ft_, 0, 2); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_); } if ( _Rt_ ) { PUSH32I( (int)&VU0.VF[_Ft_].UD[0] ); } else { PUSH32I( (int)&dummyValue[0] ); } PUSH32R( EAX ); CALLFunc( (int)memRead128 ); ADD32ItoR( ESP, 8 ); } //////////////////////////////////////////////////// void recSQC2( void ) { _deleteEEreg(_Rs_, 1); _deleteVFtoXMMreg(_Ft_, 0, 0); MOV32MtoR( EAX, (int)&cpuRegs.GPR.r[ _Rs_ ].UL[ 0 ] ); if ( _Imm_ != 0 ) { ADD32ItoR( EAX, _Imm_ ); } PUSH32I( (int)&VU0.VF[_Ft_].UD[0] ); PUSH32R( EAX ); CALLFunc( (int)memWrite128 ); ADD32ItoR( ESP, 8 ); } #endif #endif
[ "saqibakhtar@23c756db-88ba-2448-99d7-e6e4c676ec84" ]
[ [ [ 1, 4291 ] ] ]
97e0cc929848eef8366fe9ae4e23b01161caec31
8a2e417c772eba9cf4653d0c688dd3ac96590964
/prop-src/datatype.cc
42b1ef08b6da7021661781f4c8abf10afe6539b5
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
romix/prop-cc
1a190ba6ed8922428352826de38efb736e464f50
3f7f2e4a4d0b717f4e4f3dbd4c7f9d1f35572f8f
refs/heads/master
2023-08-30T12:55:00.192286
2011-07-19T20:56:39
2011-07-19T20:56:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
47,936
cc
/////////////////////////////////////////////////////////////////////////////// // This file is generated automatically using Prop (version 2.4.0), // last updated on Jul 1, 2011. // The original source file is "..\..\prop-src\datatype.pcc". /////////////////////////////////////////////////////////////////////////////// #define PROP_QUARK_USED #include <propdefs.h> /////////////////////////////////////////////////////////////////////////////// // Quark literals /////////////////////////////////////////////////////////////////////////////// static const Quark cocofmcocofm_p_r_o_pcn_s_r_cfm_d_a_t_a_t_y_p_eco_c_c_Q1("a_"); #line 1 "../../prop-src/datatype.pcc" ///////////////////////////////////////////////////////////////////////////// // // This file implements the DatatypeClass // ////////////////////////////////////////////////////////////////////////////// #include <AD/strings/quark.h> #include "datatype.h" #include "ast.h" #include "ir.h" #include "type.h" #include "options.h" #include "list.h" #include "datagen.h" ////////////////////////////////////////////////////////////////////////////// // // Constructor for DatatypeClass // ////////////////////////////////////////////////////////////////////////////// DatatypeClass::DatatypeClass (CLASS_TYPE my_class_type, Id cid, Id id, TyVars p, Inherits i, TyQual q, Decls d, Cons c, DatatypeHierarchy * r) : ClassDefinition(my_class_type,id,p,i,q,d), constructor_name(cid), cons(c), root(r), generating_list_special_forms(false), cons_arg_ty(NOty), has_destructor(false) { is_const = (qualifiers & QUALconst) ? "const " : ""; is_list = is_list_constructor(constructor_name); is_array = is_array_constructor(constructor_name); } DatatypeClass::~DatatypeClass() {} ////////////////////////////////////////////////////////////////////////////// // // Method to update the qualifiers and other // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::get_info() { if (got_info) return; got_info = true; /* match (lookup_ty(datatype_name)) { DATATYPEty({ qualifiers = q, body = b, unit, arg, terms ... },_): { qualifiers = q; class_body = b; for (int i = 0; i < number_of_subclasses; i++) { match (subclasses[i]->cons) { ONEcons { inherit, qual, body ... }: { // subclasses[i]->inherited_classes = inherit; subclasses[i]->qualifiers |= qual; subclasses[i]->class_body = body; } | _: // skip } } } | _: // skip } */ // // Construct the inheritance list and fix it up if necessary // build_inheritance_list(); // // Use inline methods if we are not in space saving mode // or if the user specificately specified the inline qualifier // Bool must_inline = (qualifiers & QUALinline); Bool must_not_inline = (qualifiers & QUALextern); if (must_inline && must_not_inline) { error( "%Ldatatype %s%V cannot be inline and external at the same time", datatype_name, parameters ); } if (must_inline) inline_methods = true; else if (must_not_inline) inline_methods = false; else inline_methods = !options.save_space; // // Use a variant tag if we have subclasses in our hierarchy // and if the tag is not embedded into the pointer representation // has_variant_tag = ((optimizations & OPTtagless) == 0); has_destructor = (qualifiers & QUALvirtualdestr) || (cons && is_array); } ////////////////////////////////////////////////////////////////////////////// // // Constructor for DatatypeHierarchy // ////////////////////////////////////////////////////////////////////////////// DatatypeHierarchy::DatatypeHierarchy (Id id, TyVars p, Inherits i, TyQual q, TermDefs t, Decls d) : DatatypeClass(DATATYPE_CLASS,id, #line 117 "../../prop-src/datatype.pcc" #line 117 "../../prop-src/datatype.pcc" cocofmcocofm_p_r_o_pcn_s_r_cfm_d_a_t_a_t_y_p_eco_c_c_Q1 #line 117 "../../prop-src/datatype.pcc" #line 117 "../../prop-src/datatype.pcc" + id,p,i,q,d,NOcons,this), datatype_name(id), term_defs(t), subclasses(0), number_of_subclasses(0), datatype_ty(NOty) { unit_constructors = 0; arg_constructors = 0; constructor_terms = 0; use_persist_base = false; use_gc_base = false; got_info = false; // // Build the class hierarchy // build_class_hierarchy(); } DatatypeHierarchy::~DatatypeHierarchy() { delete [] subclasses; } ////////////////////////////////////////////////////////////////////////////// // // Method to build the class hierarchy given a datatype. // We'll create a DatatypeClass object for each subclass. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::build_class_hierarchy() { // don't bother building the class hierarchy for views if (is_view()) return; // construct class hierarchy #line 154 "../../prop-src/datatype.pcc" #line 197 "../../prop-src/datatype.pcc" { Ty _V1 = lookup_ty(datatype_name); if (_V1) { switch (_V1->tag__) { case a_Ty::tag_TYCONty: { if (boxed(_TYCONty(_V1)->_1)) { switch (_TYCONty(_V1)->_1->tag__) { case a_TyCon::tag_DATATYPEtycon: { #line 157 "../../prop-src/datatype.pcc" arity = _DATATYPEtycon(_TYCONty(_V1)->_1)->unit + _DATATYPEtycon(_TYCONty(_V1)->_1)->arg; unit_constructors = _DATATYPEtycon(_TYCONty(_V1)->_1)->unit; arg_constructors = _DATATYPEtycon(_TYCONty(_V1)->_1)->arg; constructor_terms = _DATATYPEtycon(_TYCONty(_V1)->_1)->terms; optimizations = _DATATYPEtycon(_TYCONty(_V1)->_1)->opt; datatype_ty = _V1; _DATATYPEtycon(_TYCONty(_V1)->_1)->hierarchy = this; if (_DATATYPEtycon(_TYCONty(_V1)->_1)->arg > 0) // build class hierarchy only if we have more than // one variants { if (_DATATYPEtycon(_TYCONty(_V1)->_1)->opt & OPTsubclassless) // no subclass { number_of_subclasses = 0; for (int i = 0; i < arity; i++) { if (_DATATYPEtycon(_TYCONty(_V1)->_1)->terms[i]->ty != NOty) { cons = _DATATYPEtycon(_TYCONty(_V1)->_1)->terms[i]; constructor_name = cons->name; is_list = is_list_constructor(constructor_name); is_array = is_array_constructor(constructor_name); class_body = append(class_body, _DATATYPEtycon(_TYCONty(_V1)->_1)->terms[i]->body); } } } else // use subclass { number_of_subclasses = _DATATYPEtycon(_TYCONty(_V1)->_1)->arg; subclasses = new DatatypeClass * [number_of_subclasses]; for (int i = 0, j = 0; i < arity; i++) { if (_DATATYPEtycon(_TYCONty(_V1)->_1)->terms[i]->ty != NOty) subclasses[j++] = build_one_subclass(_DATATYPEtycon(_TYCONty(_V1)->_1)->terms[i]); } } } #line 195 "../../prop-src/datatype.pcc" } break; default: { L1:; } break; } } else { goto L1; } } break; default: { goto L1; } break; } } else { goto L1; } } #line 197 "../../prop-src/datatype.pcc" #line 197 "../../prop-src/datatype.pcc" } ////////////////////////////////////////////////////////////////////////////// // // Method to build one subclass in the hierarchy. // ////////////////////////////////////////////////////////////////////////////// DatatypeClass *DatatypeHierarchy::build_one_subclass( Cons cons) { #line 208 "../../prop-src/datatype.pcc" #line 223 "../../prop-src/datatype.pcc" { if (cons) { #line 211 "../../prop-src/datatype.pcc" return cons->class_def = new DatatypeClass( DATATYPE_SUBCLASS, cons->name, Quark(mangle(datatype_name),"_",mangle(cons->name)), parameters, add_inherit(class_name,parameters,cons->inherit), cons->qual, cons->body, cons, this); #line 222 "../../prop-src/datatype.pcc" } else { #line 223 "../../prop-src/datatype.pcc" return 0; #line 223 "../../prop-src/datatype.pcc" } } #line 224 "../../prop-src/datatype.pcc" #line 224 "../../prop-src/datatype.pcc" } ////////////////////////////////////////////////////////////////////////////// // // Method to build the inheritance list of the class hierachy. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::build_inheritance_list() { if (qualifiers & QUALrelation) append_base_class("Fact"); if (qualifiers & QUALrewritable) append_base_class("TermObj"); if (qualifiers & QUALpersistent) append_base_class("PObject"); if (qualifiers & QUALcollectable) { // Make sure we are only inheriting from one collectable object // Make sure virtual inheritance is not used. // Make sure that the collectable object is the first base class. int pos = 0; int count = 0; for_each (Inherit, inh, inherited_classes) { if((inh->qualifiers & QUALcollectable) || is_gc_ty(inh->super_class)) { count++; if (pos != 0) { msg("%!%wcollectable object %T must be first base class\n", inh->loc(), inh->super_class); } } if (inh->qualifiers & QUALvirtual) { msg( "%!%wvirtual inheritance of %T may fail" " with garbage collection\n", inh->loc(), inh->super_class ); } pos++; } if (count >= 2) error("%Linheritance of multiple collectable object will fail\n"); if (count == 0) add_base_class("GCObject"); } } ////////////////////////////////////////////////////////////////////////////// // // Method to generate a class constructor // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_class_constructor( CodeGen& C, Tys tys, DefKind k) { ClassDefinition::gen_class_constructor( C, tys, k); if (is_list) { generating_list_special_forms = true; ClassDefinition::gen_class_constructor( C, tys, k); generating_list_special_forms = false; } } ////////////////////////////////////////////////////////////////////////////// // // Method to generate the constructor parameters. // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_class_constructor_parameters (CodeGen& C, Tys tys, DefKind k) { Ty arg_ty = cons_arg_ty; #line 302 "../../prop-src/datatype.pcc" #line 307 "../../prop-src/datatype.pcc" { Ty _V2 = deref(arg_ty); if (_V2) { switch (_V2->tag__) { case a_Ty::tag_TYCONty: { if (boxed(_TYCONty(_V2)->_1)) { L2:; } else { switch ((int)_TYCONty(_V2)->_1) { case ((int)v_TUPLEtycon): { if (_TYCONty(_V2)->_2) { if (_TYCONty(_V2)->_2->_2) { if (_TYCONty(_V2)->_2->_2->_2) { goto L2; } else { if ( #line 304 "../../prop-src/datatype.pcc" generating_list_special_forms #line 304 "../../prop-src/datatype.pcc" ) { #line 305 "../../prop-src/datatype.pcc" arg_ty = mktuplety( #line 305 "../../prop-src/datatype.pcc" #line 305 "../../prop-src/datatype.pcc" list_1_(_TYCONty(_V2)->_2->_1) #line 305 "../../prop-src/datatype.pcc" #line 305 "../../prop-src/datatype.pcc" ); #line 305 "../../prop-src/datatype.pcc" } else { goto L2; } } } else { goto L2; } } else { goto L2; } } break; default: { goto L2; } break; } } } break; default: { goto L2; } break; } } else { goto L2; } } #line 307 "../../prop-src/datatype.pcc" #line 307 "../../prop-src/datatype.pcc" Parameter param; switch (k) { case EXTERNAL_IMPLEMENTATION: case EXTERNAL_INSTANTIATION: param = TYsimpleformal; break; default: param = TYformal; break; } C.pr( "%b", arg_ty, cons->name, param); } ////////////////////////////////////////////////////////////////////////////// // // Method to generate the constructor initializers. // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_class_constructor_initializers (CodeGen& C, Tys tys, DefKind k) { #line 329 "../../prop-src/datatype.pcc" #line 351 "../../prop-src/datatype.pcc" { if (cons) { #line 332 "../../prop-src/datatype.pcc" Id colon = " : "; Id comma = ""; C.pr( "%^"); // First generate the tag initializer if (root->has_variant_tag) { if (k == EXTERNAL_INSTANTIATION) C.pr( " : %s%P(tag_%S)", root->class_name, tys, constructor_name); else C.pr( " : %s%V(tag_%S)", root->class_name, parameters, constructor_name); colon = ""; comma = ", "; } // Now generate the initializers for the arguments gen_constructor_initializers( C, tys, k, cons_arg_ty, colon, comma); #line 349 "../../prop-src/datatype.pcc" } else {} } #line 351 "../../prop-src/datatype.pcc" #line 351 "../../prop-src/datatype.pcc" } ////////////////////////////////////////////////////////////////////////////// // // Method to generate the constructor initializers. // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_constructor_initializers (CodeGen& C, Tys tys, DefKind k, Ty ty, Id colon, Id comma) { if (is_array) { C.pr( "%s%slen_(x__len_)", colon, comma); colon = ""; comma = ", "; ty = mkarrayty( ty, IDexp( "len_")); } #line 371 "../../prop-src/datatype.pcc" #line 423 "../../prop-src/datatype.pcc" { Ty _V3 = deref(ty); if (_V3) { switch (_V3->tag__) { case a_Ty::tag_TYCONty: { if (boxed(_TYCONty(_V3)->_1)) { switch (_TYCONty(_V3)->_1->tag__) { case a_TyCon::tag_RECORDtycon: { #line 403 "../../prop-src/datatype.pcc" Ids l; Tys t; for (l = _RECORDtycon(_TYCONty(_V3)->_1)->_1, t = _TYCONty(_V3)->_2; l && t; l = l->_2, t = t->_2) { if (! is_array_ty(t->_1)) { C.pr( "%s%s%s(x_%s)", colon, comma, l->_1, l->_1); colon = ""; comma = ", "; } } #line 414 "../../prop-src/datatype.pcc" } break; default: { L3:; #line 416 "../../prop-src/datatype.pcc" if (! is_array_ty(_V3)) { C.pr( "%s%s%S(x_%S)", colon, comma, constructor_name, constructor_name); colon = ""; comma = ", "; } #line 423 "../../prop-src/datatype.pcc" } break; } } else { switch ((int)_TYCONty(_V3)->_1) { case ((int)v_TUPLEtycon): { if (_TYCONty(_V3)->_2) { #line 375 "../../prop-src/datatype.pcc" int i = 1; for_each(Ty, t, _TYCONty(_V3)->_2) { if (generating_list_special_forms && i == 2) { if (k == EXTERNAL_INSTANTIATION) C.pr( "%s%s_%i((%s%P *)0)", colon, comma, i, root->class_name, tys, i); else C.pr("%s%s_%i((%s%V *)0)", colon, comma, i, root->class_name, parameters, i); colon = ""; comma = ", "; } else { if (! is_array_ty(t)) { C.pr("%s%s_%i(x_%i)", colon, comma, i, i); colon = ""; comma = ", "; } } i++; } #line 401 "../../prop-src/datatype.pcc" } else {} } break; default: { goto L3; } break; } } } break; default: { goto L3; } break; } } else { goto L3; } } #line 424 "../../prop-src/datatype.pcc" #line 424 "../../prop-src/datatype.pcc" } ////////////////////////////////////////////////////////////////////////////// // // Methods to generate body of a constructor // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_class_constructor_body( CodeGen& C, Tys tys, DefKind k) { if (cons == NOcons) return; Ty ty = cons_arg_ty; if (is_array) ty = mkarrayty( ty, IDexp( "len_")); // Now generate the initializers for array arguments #line 443 "../../prop-src/datatype.pcc" #line 464 "../../prop-src/datatype.pcc" { Ty _V4 = deref(ty); if (_V4) { switch (_V4->tag__) { case a_Ty::tag_TYCONty: { if (boxed(_TYCONty(_V4)->_1)) { switch (_TYCONty(_V4)->_1->tag__) { case a_TyCon::tag_RECORDtycon: { #line 456 "../../prop-src/datatype.pcc" Ids ls; Tys ts; for(ls = _RECORDtycon(_TYCONty(_V4)->_1)->_1, ts = _TYCONty(_V4)->_2; ls && ts; ls = ls->_2, ts = ts->_2) { gen_array_initializer( C, _TYCONty(_V4)->_2, k, ls->_1, ts->_1, "x_"); } #line 462 "../../prop-src/datatype.pcc" } break; default: { L4:; #line 464 "../../prop-src/datatype.pcc" gen_array_initializer( C, tys, k, mangle( cons->name), _V4, "x_"); #line 464 "../../prop-src/datatype.pcc" } break; } } else { switch ((int)_TYCONty(_V4)->_1) { case ((int)v_TUPLEtycon): { if (_TYCONty(_V4)->_2) { #line 447 "../../prop-src/datatype.pcc" int i = 1; for_each(Ty, t, _TYCONty(_V4)->_2) { gen_array_initializer( C, tys, k, index_of(i), t, "x"); i++; } #line 454 "../../prop-src/datatype.pcc" } else {} } break; default: { goto L4; } break; } } } break; default: { goto L4; } break; } } else { goto L4; } } #line 465 "../../prop-src/datatype.pcc" #line 465 "../../prop-src/datatype.pcc" } ////////////////////////////////////////////////////////////////////////////// // // Methods to generate body of a constructor // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_array_initializer (CodeGen& C, Tys tys, DefKind k, Id exp, Ty ty, Id prefix) { #line 477 "../../prop-src/datatype.pcc" #line 498 "../../prop-src/datatype.pcc" { Ty _V5 = deref(ty); if (_V5) { switch (_V5->tag__) { case a_Ty::tag_TYCONty: { if (boxed(_TYCONty(_V5)->_1)) { switch (_TYCONty(_V5)->_1->tag__) { case a_TyCon::tag_ARRAYtycon: { if (_TYCONty(_V5)->_2) { if (_TYCONty(_V5)->_2->_2) { L5:; } else { #line 480 "../../prop-src/datatype.pcc" C.pr( "%^{%+" "%^for (int i__ = 0; i__ < (%e); i__++)" "%^{%+", _ARRAYtycon(_TYCONty(_V5)->_1)->ARRAYtycon); if (is_array) { C.pr( "%^typedef %t ELEMENT_TYPE__;" "%^new (%S + i__) ELEMENT_TYPE__ (%s%S[i__]);", _TYCONty(_V5)->_2->_1, "", exp, prefix, exp); } else { C.pr( "%^%S[i__] = %s%S[i__];", exp, prefix, exp); } C.pr("%-%^}" "%-%^}"); #line 496 "../../prop-src/datatype.pcc" } } else { goto L5; } } break; default: { goto L5; } break; } } else { goto L5; } } break; default: { goto L5; } break; } } else { goto L5; } } #line 498 "../../prop-src/datatype.pcc" #line 498 "../../prop-src/datatype.pcc" } ////////////////////////////////////////////////////////////////////////////// // // Methods to generate array initialization code. // ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // // Methods to generate destructor code. // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_class_destructor_body( CodeGen& C, Tys tys, DefKind) { if (is_array && cons) { C.pr( "%^{%+" "%^for (int i__; i__ < len_; i__++)" "%^{%+" "%^typedef %t ELEMENT_TYPE;" "%^(%S+i__)->~ELEMENT_TYPE();" "%-%^}" "%-%^}", cons_arg_ty, "", constructor_name ); } } ////////////////////////////////////////////////////////////////////////////// // // Methods to generate the forward declarations for a datatype. // These include unit constructors for the class. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_forward_declarations( CodeGen& C) { // don't generate code for views if (is_view()) return; get_info(); generate_forward_class_declarations(C); generate_forward_constructor_declarations(C); // don't generate code for forward definitions if (term_defs == #line 546 "../../prop-src/datatype.pcc" #line 546 "../../prop-src/datatype.pcc" nil_1_ #line 546 "../../prop-src/datatype.pcc" #line 546 "../../prop-src/datatype.pcc" ) return; generate_unit_constructors(C); } ////////////////////////////////////////////////////////////////////////////// // // Method to generate forward class declarations. // If the datatype is monomorphic, generate a typedef. // Otherwise, generate a forward template declaration // and a #define. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_forward_class_declarations( CodeGen& C) { // Generate forward declarations only if we have at least one variant if (arg_constructors == 0 && term_defs != #line 562 "../../prop-src/datatype.pcc" #line 562 "../../prop-src/datatype.pcc" nil_1_ #line 562 "../../prop-src/datatype.pcc" #line 562 "../../prop-src/datatype.pcc" ) return; C.pr( "%^%/" "%^//" "%^// Forward class definition for %s%V" "%^//" "%^%/" "%n#ifndef datatype_%S_defined" "%n#define datatype_%S_defined", datatype_name, parameters, datatype_name, datatype_name ); if (is_polymorphic()) { // Polymorphic datatypes C.pr( "%^%Hclass %s;", parameters, class_name); C.pr( "%n#define %s%v %s%s%V *\n", datatype_name, parameters, is_const, class_name, parameters); } else { // Monomorphic datatypes C.pr( "%^ class %s;", class_name); C.pr( "%^ typedef %s%s * %s;", is_const, class_name, datatype_name); } C.pr( "%n#endif\n\n"); } ////////////////////////////////////////////////////////////////////////////// // // Method to generate forward declarations for datatype constructors. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_forward_constructor_declarations( CodeGen& C) { } ////////////////////////////////////////////////////////////////////////////// // // Method to generate code for the definition of a datatype // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_datatype_definitions( CodeGen& C) { // don't generate code for views if (is_view()) return; // don't generate code for forward definitions if (term_defs == #line 613 "../../prop-src/datatype.pcc" #line 613 "../../prop-src/datatype.pcc" nil_1_ #line 613 "../../prop-src/datatype.pcc" #line 613 "../../prop-src/datatype.pcc" ) return; // If there are no argument constructors, don't generate code get_info(); if (arg_constructors == 0) gen_class_postdefinition(C); else { // Otherwise generate code for all the classes. gen_class_definition(C); for (int i = 0; i < number_of_subclasses; i++) subclasses[i]->gen_class_definition(C); // Generate datatype constructors DefKind kind = inline_methods ? INLINE_IMPLEMENTATION : INTERFACE_DEFINITION; generate_datatype_constructors(C, #line 631 "../../prop-src/datatype.pcc" #line 631 "../../prop-src/datatype.pcc" nil_1_ #line 631 "../../prop-src/datatype.pcc" #line 631 "../../prop-src/datatype.pcc" ,kind); if (options.inline_casts == false || parameters != #line 633 "../../prop-src/datatype.pcc" #line 633 "../../prop-src/datatype.pcc" nil_1_ #line 633 "../../prop-src/datatype.pcc" #line 633 "../../prop-src/datatype.pcc" ) generate_downcasting_functions(C); C.pr("\n\n"); } } ////////////////////////////////////////////////////////////////////////////// // // Method to generate the unit constructor names. // If there are no argument constructors, represent the constructors as // enum's. Otherwise, represent them as #define constants. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_unit_constructors( CodeGen& C) { if (unit_constructors == 0) return; if (arg_constructors == 0) generate_constructor_tags( C, "", "", unit_constructors, constructor_terms); else generate_define_tags( C, unit_constructors, constructor_terms); C.pr( "\n\n"); } ////////////////////////////////////////////////////////////////////////////// // // Method to generate the constructor tags as enum's. // Constructor tags are used to represent unit constructors // and variant tags. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_constructor_tags (CodeGen& C, Id enum_prefix, Id tag_prefix, int n, Cons terms[]) { C.pr("%^enum %s%s {%+", enum_prefix, datatype_name); Bool comma = false; for (int i = 0; i < n; i++) { if (comma) C.pr ( ", "); if (i % 3 == 0) C.pr( "%^"); C.pr( "%s%S = %i", tag_prefix, terms[i]->name, tag_of(terms[i])); comma = true; } C.pr( "%-%^};\n\n"); } ////////////////////////////////////////////////////////////////////////////// // // Method to generate the unit constructor tags as #define constants. // This is necessary if we have both unit and argument constructors // for a type. If polymorphic types are used, the #define constants // are not given a type. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_define_tags( CodeGen& C, int n, Cons terms[]) { for (int i = 0; i < n; i++) { C.pr("%n# define v_%S %i", terms[i]->name, tag_of(terms[i])); } C.pr("\n\n"); for (int i = 0; i < n; i++) { if (is_polymorphic()) C.pr("%n# define %S v_%S", terms[i]->name, terms[i]->name); else C.pr("%n# define %S (%s)v_%S", terms[i]->name, datatype_name, terms[i]->name); } } ////////////////////////////////////////////////////////////////////////////// // // Method to generate datatype constructor functions for a datatype. // Datatype constructor functions are just external functions. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_datatype_constructors (CodeGen& C, Tys tys, DefKind kind) { C.pr( "%^%/" "%^//" "%^// Datatype constructor functions for %s%V" "%^//" "%^%/", datatype_name, parameters ); generate_datatype_constructor( C, tys, kind); for (int i = 0; i < number_of_subclasses; i++) subclasses[i]->generate_datatype_constructor( C, tys, kind); } ////////////////////////////////////////////////////////////////////////////// // // Method to generate a datatype constructor function. // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::generate_datatype_constructor (CodeGen& C, Tys tys, DefKind kind) { // No datatype descriptor, then no datatype constructor function if (cons == NOcons) return; Id prefix = ""; switch (kind) { case INLINE_IMPLEMENTATION: prefix = "inline "; break; case INTERFACE_DEFINITION: case EXTERNAL_DEFINITION: prefix = "extern "; break; case EXTERNAL_IMPLEMENTATION: case EXTERNAL_INSTANTIATION: prefix = ""; break; } // Generate special form constructors for lists and vectors int special_forms = 1; if (is_list) special_forms = 2; else if (is_array) special_forms = options.max_vector_len + 2; Tys params = #line 763 "../../prop-src/datatype.pcc" #line 763 "../../prop-src/datatype.pcc" nil_1_ #line 763 "../../prop-src/datatype.pcc" #line 763 "../../prop-src/datatype.pcc" ; Ids labels = #line 764 "../../prop-src/datatype.pcc" #line 764 "../../prop-src/datatype.pcc" nil_1_ #line 764 "../../prop-src/datatype.pcc" #line 764 "../../prop-src/datatype.pcc" ; for (int form = 1; form <= special_forms; form++) { Ty formals_ty = cons_arg_ty; Ty actuals_ty = cons_arg_ty; Id formals_name = constructor_name; // If it is a list special form, fake the second argument if (is_list && form == 2) { #line 776 "../../prop-src/datatype.pcc" #line 781 "../../prop-src/datatype.pcc" { Ty _V6 = deref(formals_ty); if (_V6) { switch (_V6->tag__) { case a_Ty::tag_TYCONty: { if (boxed(_TYCONty(_V6)->_1)) { L6:; #line 781 "../../prop-src/datatype.pcc" bug("%LDatatypeClass::generate_datatype_constructor: %T\n", _V6); #line 781 "../../prop-src/datatype.pcc" } else { switch ((int)_TYCONty(_V6)->_1) { case ((int)v_TUPLEtycon): { if (_TYCONty(_V6)->_2) { if (_TYCONty(_V6)->_2->_2) { if (_TYCONty(_V6)->_2->_2->_2) { goto L6; } else { #line 779 "../../prop-src/datatype.pcc" formals_ty = actuals_ty = mktuplety( #line 779 "../../prop-src/datatype.pcc" #line 779 "../../prop-src/datatype.pcc" list_1_(_TYCONty(_V6)->_2->_1) #line 779 "../../prop-src/datatype.pcc" #line 779 "../../prop-src/datatype.pcc" ); #line 779 "../../prop-src/datatype.pcc" } } else { goto L6; } } else { goto L6; } } break; default: { goto L6; } break; } } } break; default: { goto L6; } break; } } else { goto L6; } } #line 782 "../../prop-src/datatype.pcc" #line 782 "../../prop-src/datatype.pcc" } // If it is an array special form, fake the parameter arguments if (is_array && form >= 2) { if (form >= 3) { params = #line 791 "../../prop-src/datatype.pcc" #line 791 "../../prop-src/datatype.pcc" list_1_(cons_arg_ty,params) #line 791 "../../prop-src/datatype.pcc" #line 791 "../../prop-src/datatype.pcc" ; labels = append( labels, #line 792 "../../prop-src/datatype.pcc" #line 792 "../../prop-src/datatype.pcc" list_1_(index_of((form - 2))) #line 792 "../../prop-src/datatype.pcc" #line 792 "../../prop-src/datatype.pcc" ); } formals_ty = mkrecordty( labels, params, false); formals_name = mangle( constructor_name); } switch (kind) { case EXTERNAL_INSTANTIATION: case EXTERNAL_DEFINITION: C.pr( "%^%s%s%P * %S %b", prefix, root->class_name, tys, constructor_name, formals_ty, formals_name, TYsimpleformal ); break; default: C.pr( "%^%H%s%s%V * %S %b", parameters, prefix, root->class_name, parameters, constructor_name, formals_ty, formals_name, TYformal ); break; } // Don't generate code for interface definitions if (kind == INTERFACE_DEFINITION || kind == EXTERNAL_DEFINITION) { C.pr( ";"); continue; } C.pr( "%^{%+"); // // Generate a temporary array // if (is_array && form >= 2) { C.pr( "%^const int x__len_ = %i;", form - 2); C.pr( "%^%t x_%S[%i];", cons_arg_ty, "", constructor_name, form - 2); for (int i = 0; i < form - 2; i++) C.pr( "%^x_%S[%i] = x__%i;", constructor_name, i, i+1); } C.pr( "%^return "); // // In the tagged pointer representation, the variant tag is embedded // within the data address. // if (root->optimizations & OPTtaggedpointer) { switch (kind) { case EXTERNAL_INSTANTIATION: C.pr ( "(%s%P*)((unsigned long)(", root->class_name, tys); break; default: C.pr ( "(%s%V*)((unsigned long)(", root->class_name, parameters); break; } } // // In the unboxed representation, the argument is embedded within // the address. // if (root->optimizations & OPTunboxed) { int tag_bits = DatatypeCompiler::max_embedded_bits; for (int i = root->unit_constructors; i >= DatatypeCompiler::max_embedded_tags; i >>= 1) tag_bits++; C.pr( "(%s *)(((unsigned long)%b<<(%i+1))|%i)", root->class_name, actuals_ty, constructor_name, TYactual, tag_bits, (1 << tag_bits) ); } // // The usual boxed implementation // else { C.pr ("new "); switch (kind) { case EXTERNAL_INSTANTIATION: if (is_array) C.pr( "(sizeof(%s%P)+sizeof(%t)*x__len_) ", class_name, tys, cons_arg_ty, ""); C.pr ("%s%P %b", class_name, tys, actuals_ty, constructor_name, TYactual); break; default: if (is_array) C.pr( "(sizeof(%s%V)+sizeof(%t)*x__len_) ", class_name, parameters, cons_arg_ty, ""); C.pr( "%s%V %b", class_name, parameters, actuals_ty, constructor_name, TYactual); break; } } if (root->optimizations & OPTtaggedpointer) { switch (kind) { case EXTERNAL_INSTANTIATION: C.pr( ")|%s%P::tag_%S)", root->class_name, tys, constructor_name); break; default: C.pr( ")|%s%V::tag_%S)", root->class_name, parameters, constructor_name); break; } } C.pr( ";%-%^}\n"); } } ////////////////////////////////////////////////////////////////////////////// // // Method to generate code before the interface // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_class_predefinition( CodeGen& C) { #line 925 "../../prop-src/datatype.pcc" #line 949 "../../prop-src/datatype.pcc" { if (cons) { #line 928 "../../prop-src/datatype.pcc" cons_arg_ty = cons->ty; C.pr( "%^%/" "%^//" "%^// Class for datatype constructor %s%V::%s" "%^//" "%^%/", root->datatype_name, parameters, cons->name ); #line 938 "../../prop-src/datatype.pcc" } else { #line 940 "../../prop-src/datatype.pcc" cons_arg_ty = NOty; C.pr( "%^%/" "%^//" "%^// Base class for datatype %s%V" "%^//" "%^%/", root->datatype_name, parameters); #line 949 "../../prop-src/datatype.pcc" } } #line 950 "../../prop-src/datatype.pcc" #line 950 "../../prop-src/datatype.pcc" } ////////////////////////////////////////////////////////////////////////////// // // Method to generate the interface of a class // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_class_interface( CodeGen& C) { // Generate the internal representation // if there is a constructor descripter and the // argument is not represented in unboxed form. C.pr( "%-%^public:%+"); #line 967 "../../prop-src/datatype.pcc" #line 978 "../../prop-src/datatype.pcc" { if (cons) { #line 970 "../../prop-src/datatype.pcc" if ((cons->opt & OPTunboxed) == 0) { C.pr( "%#%^%b\n", cons->location->begin_line, cons->location->file_name, cons->ty, cons->name, TYbody); } #line 976 "../../prop-src/datatype.pcc" } else {} } #line 978 "../../prop-src/datatype.pcc" #line 978 "../../prop-src/datatype.pcc" DefKind kind = root->inline_methods ? INLINE_IMPLEMENTATION : INTERFACE_DEFINITION; // Generate the constructor of the class if (cons != NOcons) gen_class_constructor( C, #line 985 "../../prop-src/datatype.pcc" #line 985 "../../prop-src/datatype.pcc" nil_1_ #line 985 "../../prop-src/datatype.pcc" #line 985 "../../prop-src/datatype.pcc" , kind); // Generate the destructor of the class if ((root->qualifiers & QUALvirtualdestr) || (qualifiers & QUALvirtualdestr) || (cons && is_array)) gen_class_destructor( C, #line 992 "../../prop-src/datatype.pcc" #line 992 "../../prop-src/datatype.pcc" nil_1_ #line 992 "../../prop-src/datatype.pcc" #line 992 "../../prop-src/datatype.pcc" , kind); // Generate the method declarations for all different types // of extra functionality if (root->qualifiers & QUALpersistent) generate_persistence_interface(C); //if (root->qualifiers & QUALvariable) generate_logic_interface(C); if (root->qualifiers & QUALcollectable) generate_gc_interface(C); if (root->qualifiers & QUALrelation) generate_inference_interface(C); } ////////////////////////////////////////////////////////////////////////////// // // Method to generate the interface of a base class // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::gen_class_interface( CodeGen& C) { // Generate tags for arg constructors if (arg_constructors > 1) { C.pr( "%-%^public:%+"); generate_constructor_tags( C, "Tag_", "tag_", arg_constructors, constructor_terms + unit_constructors); } // Generate a variant tag and a base class constructor for it // only if we have a variant_tag representation. if (has_variant_tag) { C.pr( "%-%^public:%+" "%^const Tag_%s tag__; // variant tag" "%-%^protected:%+" "%^inline %s(Tag_%s t__) : tag__(t__) {%&}", datatype_name, class_name, datatype_name, constructor_code ); } // Generate the untagging functions generate_untagging_member_functions(C); DatatypeClass::gen_class_interface(C); } ////////////////////////////////////////////////////////////////////////////// // // Method to generate untagging functions for a datatype class. // Three untagging functions are generated: // int untag() const --- returns the variant tag of the class // friend int untag(type * x) -- return a tag for the object x // so that each variant (boxed or unboxed) // gets a unique tag. // friend int boxed(type * x) -- returns true if object is boxed. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_untagging_member_functions( CodeGen& C) { /////////////////////////////////////////////////////////////////////////// // Generate untagger /////////////////////////////////////////////////////////////////////////// // if (has_variant_tag) // C.pr("%^inline int untag() const { return tag__; }"); } void DatatypeHierarchy::generate_untagging_functions( CodeGen& C) { if (arg_constructors == 0) return; /////////////////////////////////////////////////////////////////////////// // Generate boxed() predicate /////////////////////////////////////////////////////////////////////////// if (unit_constructors == 0) C.pr( "%^%Hinline int boxed(const %s%V *) { return 1; }", parameters, class_name, parameters); else if (unit_constructors == 1) C.pr( "%^%Hinline int boxed(const %s%V * x) { return x != 0; }", parameters, class_name, parameters); else C.pr( "%^%Hinline int boxed(const %s%V * x)" " { return (unsigned long)x >= %i; }", parameters, class_name, parameters, unit_constructors); /////////////////////////////////////////////////////////////////////////// // Generate function that untags the pointer if // the tags are embedded into a pointer. /////////////////////////////////////////////////////////////////////////// if (optimizations & OPTtaggedpointer) { C.pr( "%^%/" "%^//" "%^// Embbeded tag extraction functions" "%^//" "%^%/" "%^%Hinline int untagp(const %s%V * x)" "%^ { return (unsigned long)x & %i; }" "%^%Hinline %s%s%V * derefp(const %s%V * x)" "%^ { return (%s%s%V*)((unsigned long)x & ~%i); }", parameters, class_name, parameters, DatatypeCompiler::max_embedded_tags - 1, parameters,is_const,class_name, parameters, class_name, parameters, is_const, class_name, parameters, DatatypeCompiler::max_embedded_tags - 1 ); } /////////////////////////////////////////////////////////////////////////// // Generate a generic untag function that works on all boxed // and unboxed variants. /////////////////////////////////////////////////////////////////////////// if (unit_constructors == 0) { // No unboxed variants. if (optimizations & OPTtaggedpointer) C.pr( "%^%Hinline int untag(const %s%V * x) { return untagp(x); }", parameters, class_name, parameters); else if (arg_constructors == 1) C.pr( "%^%Hinline int untag(const %s%V *) { return 0; }", parameters, class_name, parameters); else C.pr( "%^%Hinline int untag(const %s%V * x) { return x->tag__; }", parameters, class_name, parameters); } else if (unit_constructors == 1) { // Only one unboxed variants. if (optimizations & OPTtaggedpointer) C.pr( "%^%Hinline int untag(const %s%V * x) " "{ return x ? untagp(x)+1 : 0; }", parameters, class_name, parameters); else if (arg_constructors == 1) C.pr( "%^%Hinline int untag(const %s%V * x) { return x ? 1 : 0; }", parameters, class_name, parameters); else C.pr( "%^%Hinline int untag(const %s%V * x)" " { return x ? (x->tag__+1) : 0; }", parameters, class_name, parameters); } else { // More than one unboxed variants. if (optimizations & OPTtaggedpointer) C.pr( "%^%Hinline int untag(const %s%V * x)" " { return boxed(x) ? untagp(x) + %i : (int)x; }", parameters, class_name, parameters, unit_constructors); else if (arg_constructors == 1) C.pr( "%^%Hinline int untag(const %s%V * x)" " { return boxed(x) ? %i : (int)x; }", parameters, class_name, parameters, 1 + unit_constructors); else C.pr( "%^%Hinline int untag(const %s%V * x)" " { return boxed(x) ? x->tag__ + %i : (int)x; }", parameters, class_name, parameters, unit_constructors); } } ////////////////////////////////////////////////////////////////////////////// // // Method to generate downcasting functions // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::generate_downcasting_functions( CodeGen& C) { C.pr( "%^%/" "%^//" "%^// Downcasting functions for %s%V" "%^//" "%^%/", datatype_name, parameters ); for (int i = 0; i < number_of_subclasses; i++) { DatatypeClass * D = subclasses[i]; C.pr( "%^%Hinline %s%V * _%S(const %s%V * _x_) { return (%s%V *)_x_; }", parameters, D->class_name, parameters, D->constructor_name, class_name, parameters, D->class_name, parameters); } } ////////////////////////////////////////////////////////////////////////////// // // Method to generate code right after the main class definition. // ////////////////////////////////////////////////////////////////////////////// void DatatypeClass::gen_class_postdefinition( CodeGen& C) { C.pr( "\n"); // Interfaces for extra features if (root->qualifiers & QUALprintable) generate_print_interface(C); } ////////////////////////////////////////////////////////////////////////////// // // Method to generate code right after the main class definition. // ////////////////////////////////////////////////////////////////////////////// void DatatypeHierarchy::gen_class_postdefinition( CodeGen& C) { generate_untagging_functions(C); DatatypeClass::gen_class_postdefinition(C); } #line 1208 "../../prop-src/datatype.pcc" /* ------------------------------- Statistics ------------------------------- Merge matching rules = yes Number of DFA nodes merged = 156 Number of ifs generated = 27 Number of switches generated = 14 Number of labels = 6 Number of gotos = 27 Adaptive matching = disabled Fast string matching = disabled Inline downcasts = disabled -------------------------------------------------------------------------- */
[ [ [ 1, 1528 ] ] ]
31fc5a3101b704a42f6bb7218d94a215a57fbfb7
de13bb58f0b0a0c5b7a533bb7a4ef8f255cbf35a
/Grapplon/BaseObject.h
4e4d95a6f54d149b5b49b8ecb0932303c6e8d0d3
[]
no_license
TimToxopeus/grapplon
96a34cc1fcefc2582c8702600727f5748ee894a9
f63c258357fe4b993e854089e7222c14a00ed731
refs/heads/master
2016-09-06T15:05:15.328601
2008-06-05T11:24:14
2008-06-05T11:24:14
41,954,511
0
0
null
null
null
null
UTF-8
C++
false
false
1,769
h
#pragma once #include "ActiveObject.h" #include <ode/ode.h> #include "Vector.h" #include "PhysicsData.h" class CAnimatedTexture; // Forward declaration class CBaseObject : public IActiveObject { protected: PhysicsData m_oPhysicsData; float m_fSecondaryScale; float m_fAngle; float m_fGravitationalConstant; Vector frontForce; CAnimatedTexture *m_pImage; float m_fInvincibleTime; int m_iHitpoints, m_iMaxHitpoints; public: CBaseObject(); virtual ~CBaseObject(); void Render(); void Update( float fTime ); virtual void SetPosition( float fX, float fY ); virtual void SetPosition( Vector pos ); Vector GetPosition(); float GetX(); float GetY(); void SetRotation( float fAngle ); float GetRotation(); dBodyID GetBody() { return m_oPhysicsData.body; }; PhysicsData *GetPhysicsData() { return &m_oPhysicsData; } void SetMass( float fMass, bool permanent = true ); void ResetMass(); float GetMass(); void SetGravitationalConstant( float fGravitationalConstant ) { m_oPhysicsData.m_fGravConst = fGravitationalConstant; } float GetGravitationalConstant() { return m_oPhysicsData.m_fGravConst; } void SetLinVelocity( Vector& v ); void SetAngVelocity( Vector& v ); void AddForce( Vector& f ); void SetForceFront( Vector& f ); void SetForce( Vector f ); virtual inline void ApplyForceFront(); Vector GetLinVelocity(); Vector GetForwardVector(); virtual void CollideWith( CBaseObject *pOther); virtual void OnDie( CBaseObject *m_pKiller ); virtual void IncreaseTemp( float timePassed ) {}; int GetHitpoints() { return m_iHitpoints; }; int GetMaxHitpoints() { return m_iMaxHitpoints; }; virtual void SetInvincibleTime( float fTime ) { m_fInvincibleTime = fTime; }; };
[ "Tim.Toxopeus@290fe64d-754b-0410-ab79-69b6bb713112", "rikjansen@290fe64d-754b-0410-ab79-69b6bb713112", "[email protected]" ]
[ [ [ 1, 3 ], [ 5, 16 ], [ 18, 19 ], [ 21, 23 ], [ 25, 28 ], [ 31, 39 ], [ 41, 45 ], [ 50, 50 ], [ 52, 52 ], [ 55, 56 ], [ 58, 58 ], [ 63, 63 ] ], [ [ 4, 4 ], [ 17, 17 ], [ 24, 24 ], [ 29, 30 ], [ 40, 40 ], [ 46, 49 ], [ 51, 51 ] ], [ [ 20, 20 ], [ 53, 54 ], [ 57, 57 ], [ 59, 62 ] ] ]
92b2229a9daca532e451f3c049a016570e12af7b
841e58a0ee1393ddd5053245793319c0069655ef
/Karma/Headers/PowerUp.h
f1a2fcfba542b59a76eb1e078d9c1b873db63bdb
[]
no_license
dremerbuik/projectkarma
425169d06dc00f867187839618c2d45865da8aaa
faf42e22b855fc76ed15347501dd817c57ec3630
refs/heads/master
2016-08-11T10:02:06.537467
2010-06-09T07:06:59
2010-06-09T07:06:59
35,989,873
0
0
null
null
null
null
UTF-8
C++
false
false
1,396
h
/*---------------------------------------------------------------------------------*/ /* File: PowerUp.h */ /* Author: Per Karlsson, [email protected] */ /* */ /* Description: PowerUp is a class that handles the PowerUps barrels that are */ /* located in the world. */ /*---------------------------------------------------------------------------------*/ #ifndef POWERUP_H #define POWERUP_H #include "Player.h" #include "GameCommon.h" class PowerUp: public NxOgre::Callback { public: /* A struct that binds a NxOgre volume to string, so Ogre knows what Entity to hide later. */ struct struct_PowerUp { NxOgre::Volume* volume; Ogre::String name; }; PowerUp(NxOgre::Scene*,Ogre::SceneManager*,NxOgre::RigidBody*, Player*); /* Adds a PowerUp barrel at position p and with material s. */ void addPowerUp(const Ogre::Vector3 &p,const Ogre::String& s); /* The event that triggers everytime the player runs into a PowerUp Barrel. */ void onVolumeEvent(NxOgre::Volume* volume, NxOgre::Shape* volumeShape, NxOgre::RigidBody* rigidBody, NxOgre::Shape* rigidBodyShape, unsigned int collisionEvent); private: std::vector<struct_PowerUp> mvPowerUps; NxOgre::Scene* mvpScene; Ogre::SceneManager* mvpSceneMgr; NxOgre::RigidBody* mvpCapsule; }; #endif
[ "perkarlsson89@0a7da93c-2c89-6d21-fed9-0a9a637d9411" ]
[ [ [ 1, 43 ] ] ]
c3a54c3d8055028a4ccc258d0ced2332975455a3
867f5533667cce30d0743d5bea6b0c083c073386
/jingxian-downloader/wxCURL/samples/curl_app/wxFTPMkdirDialog.cpp
cfa6fa0f522820ccf5f7139f37dc7645ac1edf78
[]
no_license
mei-rune/jingxian-project
32804e0fa82f3f9a38f79e9a99c4645b9256e889
47bc7a2cb51fa0d85279f46207f6d7bea57f9e19
refs/heads/master
2022-08-12T18:43:37.139637
2009-12-11T09:30:04
2009-12-11T09:30:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,787
cpp
/******************************************* * base.cpp * Created by Casey O'Donnell on Tue Jun 29 2004. * Copyright (c) 2004 Casey O'Donnell. All rights reserved. * Licence: wxWidgets Licence ******************************************/ #include "wxcurl/wxcurl_config.h" #include "wx/xrc/xmlres.h" // XRC XML resouces #include <wxcurl/ftp.h> #include "wxFTPMkdirDialog.h" ////////////////////////////////////////////////////////////////////// // Resources ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // Constants ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// // Event Tables and Other Macros for wxWindows ////////////////////////////////////////////////////////////////////// // the event tables connect the wxWindows events with the functions (event // handlers) which process them. It can be also done at run-time, but for the // simple menu events like this the static method is much simpler. IMPLEMENT_CLASS(wxFTPMkdirDialog, wxDialog); BEGIN_EVENT_TABLE(wxFTPMkdirDialog, wxDialog) EVT_BUTTON(XRCID("mkdir_button"), wxFTPMkdirDialog::OnMkdir) END_EVENT_TABLE() ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// wxFTPMkdirDialog::wxFTPMkdirDialog(wxWindow* pParent) { wxXmlResource::Get()->LoadDialog(this, pParent, "mkdir_ftp_dialog"); SetSize(400, -1); m_pMkdirCtrl = XRCCTRL(*this, "mkdir_text_ctrl", wxTextCtrl); m_pUserCtrl = XRCCTRL(*this, "user_text_ctrl", wxTextCtrl); m_pPassCtrl = XRCCTRL(*this, "pass_text_ctrl", wxTextCtrl); m_pResponseCtrl = XRCCTRL(*this, "response_text_ctrl", wxTextCtrl); if(m_pMkdirCtrl && m_pUserCtrl && m_pPassCtrl) { m_szDefaultMkdir = m_pMkdirCtrl->GetValue(); m_szDefaultUser = m_pUserCtrl->GetValue(); m_szDefaultPass = m_pPassCtrl->GetValue(); } } wxFTPMkdirDialog::~wxFTPMkdirDialog() { } ////////////////////////////////////////////////////////////////////// // Event Handlers ////////////////////////////////////////////////////////////////////// void wxFTPMkdirDialog::OnMkdir(wxCommandEvent& WXUNUSED(event)) { if(m_pMkdirCtrl && m_pUserCtrl && m_pPassCtrl) { wxString szMkdir = m_pMkdirCtrl->GetValue(); wxString szUser = m_pUserCtrl->GetValue(); wxString szPass = m_pPassCtrl->GetValue(); wxString szResponse; if((szMkdir == m_szDefaultMkdir)) { wxMessageBox("Please change the MKDIR location.", "Error...", wxICON_INFORMATION|wxOK, this); } else if((szUser == m_szDefaultUser) && (szPass == m_szDefaultPass)) { wxMessageBox("Please change the username or password.", "Error...", wxICON_INFORMATION|wxOK, this); } else { // Do it! wxCurlFTP ftp(szMkdir, szUser, szPass); if(ftp.MkDir()) { szResponse = "SUCCESS!\n\n"; szResponse += wxString::Format("\nResponse Code: %d\n\n", ftp.GetResponseCode()); szResponse += ftp.GetResponseHeader(); szResponse += "\n\n"; szResponse += ftp.GetResponseBody(); if(m_pResponseCtrl) m_pResponseCtrl->SetValue(szResponse); } else { szResponse = "FAILURE!\n\n"; szResponse += wxString::Format("\nResponse Code: %d\n\n", ftp.GetResponseCode()); szResponse += ftp.GetResponseHeader(); szResponse += "\n\n"; szResponse += ftp.GetResponseBody(); szResponse += "\n\n"; szResponse += ftp.GetErrorString(); if(m_pResponseCtrl) m_pResponseCtrl->SetValue(szResponse); } } } }
[ "runner.mei@0dd8077a-353d-11de-b438-597f59cd7555" ]
[ [ [ 1, 117 ] ] ]
71935e806fecd4d60839e02294c3e5ad69390a28
bda7b365b5952dc48827a8e8d33d11abd458c5eb
/Interface.cpp
aca2f7544294caedad248a5eb95975711229c1f8
[]
no_license
MrColdbird/gameservice
3bc4dc3906d16713050612c1890aa8820d90272e
009d28334bdd8f808914086e8367b1eb9497c56a
refs/heads/master
2021-01-25T09:59:24.143855
2011-01-31T07:12:24
2011-01-31T07:12:24
35,889,912
3
3
null
null
null
null
UTF-8
C++
false
false
24,748
cpp
// ====================================================================================== // File : Interface.cpp // Author : Li Chen // Last Change : 11/17/2010 | 11:46:27 AM | Wednesday,November // Description : // ====================================================================================== #include "stdafx.h" #include "Interface.h" #include "InterfaceMgr.h" #include "Master.h" #include "Task.h" #include "Session.h" #include "Stats.h" #include "Achievement.h" #include "SignIn.h" #include "SysMsgBox.h" // ======================================================== // GameService Interface for Game // ======================================================== #if defined(_XBOX) || defined(_XENON) || defined(_PS3) #include "InGameMarketplace.h" namespace GameService { GSCB_Func GS_CallBackFunc[EGSTaskType_MAX]; // Update function GS_VOID Initialize(GS_BOOL requireOnline, GS_INT achieveCount, GS_INT versionId, GS_BOOL bTrial, GS_INT bDumpLog #if defined(_PS3) , GS_INT iFreeSpaceAvail, GS_BOOL enableInGameMarketplace #endif ) { Master::G()->Initialize(requireOnline, 1, achieveCount, versionId, bTrial, bDumpLog #if defined(_PS3) , iFreeSpaceAvail, enableInGameMarketplace #endif ); } GS_VOID Update() { Master::G()->Update(); } GS_VOID Destroy() { Master::G()->Destroy(); } GS_BOOL IsUserOnline() { #if defined(_XBOX) || defined(_XENON) return SignIn::IsUserOnline(SignIn::GetActiveUserIndex()); #elif defined(_PS3) return SignIn::IsUserOnline(); #else return 1; #endif } // Profile check function GS_BOOL NotifyNoProfileSignedIn() { #if defined(_XBOX) || defined(_XENON) return SignIn::NotifyNoProfileSignedIn(); #endif return FALSE; } GS_INT GetSignedInUserCount() { #if defined(_XBOX) || defined(_XENON) return SignIn::GetSignedInUserCount(); #elif defined(_PS3) // no sub-signin now return 1; #endif return 0; } GS_VOID SetBeforePressStart(GS_BOOL before) { SignIn::SetBeforePressStart(before); } GS_BOOL GetBeforePressStart() { return SignIn::GetBeforePressStart(); } GS_VOID StartGame(GS_INT userIndex) { SignIn::StartGame(userIndex); } #if defined(_PS3) GS_INT GetUserAge() { return SignIn::GetUserAge(); } GS_INT GetUserLanguage() { switch(SignIn::GetLanguage().language1) { case SCE_NP_LANG_JAPANESE: return GS_ELang_Japanese; default: case SCE_NP_LANG_ENGLISH: return GS_ELang_English; case SCE_NP_LANG_FRENCH: return GS_ELang_French; case SCE_NP_LANG_SPANISH: return GS_ELang_Spanish; case SCE_NP_LANG_GERMAN: return GS_ELang_German; case SCE_NP_LANG_ITALIAN: return GS_ELang_Italian; case SCE_NP_LANG_DUTCH: return GS_ELang_Dutch; case SCE_NP_LANG_PORTUGUESE: return GS_ELang_Portugese; case SCE_NP_LANG_RUSSIAN: return GS_ELang_Russian; case SCE_NP_LANG_KOREAN: return GS_ELang_Korean; case SCE_NP_LANG_CHINESE_T: return GS_ELang_Chinese_t; case SCE_NP_LANG_CHINESE_S: return GS_ELang_Chinese_s; case SCE_NP_LANG_FINNISH: return GS_ELang_Finish; case SCE_NP_LANG_SWEDISH: return GS_ELang_Swedish; case SCE_NP_LANG_DANISH: return GS_ELang_Danish; case SCE_NP_LANG_NORWEGIAN: return GS_ELang_Norwegian; case SCE_NP_LANG_POLISH: return GS_ELang_Polish; } } #endif GS_INT GetSystemLanguage() { #if defined(_XBOX) || defined(_XENON) switch(XGetLanguage()) { default: case XC_LANGUAGE_ENGLISH: return GS_ELang_English; case XC_LANGUAGE_SCHINESE: return GS_ELang_Chinese_s; case XC_LANGUAGE_TCHINESE: return GS_ELang_Chinese_t; case XC_LANGUAGE_KOREAN: return GS_ELang_Korean; case XC_LANGUAGE_JAPANESE: return GS_ELang_Japanese; case XC_LANGUAGE_PORTUGUESE: return GS_ELang_Portugese; case XC_LANGUAGE_FRENCH: return GS_ELang_French; case XC_LANGUAGE_SPANISH: return GS_ELang_Spanish; case XC_LANGUAGE_ITALIAN: return GS_ELang_Italian; case XC_LANGUAGE_POLISH: return GS_ELang_Polish; case XC_LANGUAGE_RUSSIAN: return GS_ELang_Russian; case XC_LANGUAGE_GERMAN: return GS_ELang_German; // no nl lang for xbox // no no lang for xbox // no hu lang for xbox // no tr lang for xbox // no cs lang for xbox // no sl lang for xbox // no sv lang for xbox // no el lang for xbox } #elif defined(_PS3) GS_INT language; if( cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_LANG, &language) < 0 ) { return GS_ELang_English; } switch(language) { case CELL_SYSUTIL_LANG_JAPANESE: return GS_ELang_Japanese; default: case CELL_SYSUTIL_LANG_ENGLISH: return GS_ELang_English; case CELL_SYSUTIL_LANG_FRENCH: return GS_ELang_French; case CELL_SYSUTIL_LANG_SPANISH: return GS_ELang_Spanish; case CELL_SYSUTIL_LANG_GERMAN: return GS_ELang_German; case CELL_SYSUTIL_LANG_ITALIAN: return GS_ELang_Italian; case CELL_SYSUTIL_LANG_DUTCH: return GS_ELang_Dutch; case CELL_SYSUTIL_LANG_PORTUGUESE: return GS_ELang_Portugese; case CELL_SYSUTIL_LANG_RUSSIAN: return GS_ELang_Russian; case CELL_SYSUTIL_LANG_KOREAN: return GS_ELang_Korean; case CELL_SYSUTIL_LANG_CHINESE_T: return GS_ELang_Chinese_t; case CELL_SYSUTIL_LANG_CHINESE_S: return GS_ELang_Chinese_s; case CELL_SYSUTIL_LANG_FINNISH: return GS_ELang_Finish; case CELL_SYSUTIL_LANG_SWEDISH: return GS_ELang_Swedish; case CELL_SYSUTIL_LANG_DANISH: return GS_ELang_Danish; case CELL_SYSUTIL_LANG_NORWEGIAN: return GS_ELang_Norwegian; case CELL_SYSUTIL_LANG_POLISH: return GS_ELang_Polish; } #endif } GS_INT IsCableConnected() { #if defined(_XBOX) || defined(_XENON) return 1; #elif defined(_PS3) return SignIn::IsCableConnected(); #endif return 1; } GS_VOID RequestSignIn() { #if defined(_XBOX) || defined(_XENON) SignIn::ShowSignInUI(); #elif defined(_PS3) SignIn::SignInNP(); #endif } GS_DWORD GetActiveUserIndex() { return SignIn::GetActiveUserIndex(); } // Leaderboard function: GS_VOID RetrieveLocalStats(GS_INT immediately, GS_INT boardId, GS_INT columnNum, GS_INT* columnIds, GSCB_Func fun_cb) { if (!Master::G()->GetStatsSrv()) return; #if defined(_XBOX) || defined(_XENON) Master::G()->GetStatsSrv()->GetLBDef().Set(boardId,columnNum,columnIds); #elif defined(_PS3) Master::G()->GetStatsSrv()->GetLBDef().Set(boardId,0); #endif GS_CallBackFunc[EGSTaskType_StatsRetrieveLocal] = fun_cb; Master::G()->GetStatsSrv()->RetrieveLocalUserStats(immediately); } GS_INT ReadLeaderboardFinished() { if (!Master::G()->GetStatsSrv()) return 1; return !( Master::G()->GetStatsSrv()->IsReadingLeaderboard() ); } GS_INT GetLeaderboardCount() { if (!Master::G()->GetStatsSrv()) return 0; return Master::G()->GetStatsSrv()->GetRetrievedCount(); } GS_CHAR G_TempChar[8] = "none"; GS_CHAR* GetLeaderboardName(GS_INT index) { if (!Master::G()->GetStatsSrv()) return G_TempChar; return Master::G()->GetStatsSrv()->GetRetrievedName(index); } GS_INT GetLeaderboardRank(GS_INT index) { if (!Master::G()->GetStatsSrv()) return 0; return Master::G()->GetStatsSrv()->GetRetrievedRank(index); } GS_INT GetLeaderboardScore(GS_INT index) { if (!Master::G()->GetStatsSrv()) return 0; return (GS_INT)Master::G()->GetStatsSrv()->GetRetrievedScore(index); } GS_INT GetStatsErrorCode() { if (!Master::G()->GetStatsSrv()) return 0; return Master::G()->GetStatsSrv()->GetErrorCode(); } #if defined(_XBOX) || defined(_XENON) ULONGLONG GetKeyValueFromStats(GS_INT lbIndex) { if (!Master::G()->GetStatsSrv()) return 0; return Master::G()->GetStatsSrv()->GetLocalStats_Key(0,lbIndex); } GS_BOOL CanWriteStats() { if (!Master::G()->GetStatsSrv()) return FALSE; return Master::G()->GetStatsSrv()->CanWriteStats(); } GS_VOID WriteStats(GSCB_Func fun_cb, GS_INT lbNum, XSESSION_VIEW_PROPERTIES* views) { if (!Master::G()->GetStatsSrv()) return; Master::G()->GetStatsSrv()->PreWriteLeaderboard(lbNum, views); GS_CallBackFunc[EGSTaskType_StatsWrite] = fun_cb; Master::G()->GetStatsSrv()->WriteLeaderboard(SignIn::GetActiveUserIndex()); // always the first user } GS_VOID FlushStats(GSCB_Func fun_cb) { if (!Master::G()->GetStatsSrv()) return; GS_CallBackFunc[EGSTaskType_StatsFlush] = fun_cb; Master::G()->GetStatsSrv()->FlushLeaderboard(); } GS_BOOL ReadStats(GS_INT boardId, GS_INT columnNum, GS_INT* columnIds, GS_INT rankIdx, GS_INT userIndex, GS_INT maxRowNum, GS_INT myScoreOffset, GSCB_Func fun_cb) { if (!Master::G()->GetStatsSrv()) return FALSE; Master::G()->GetStatsSrv()->GetLBDef().Set(boardId,columnNum,columnIds); GS_CallBackFunc[EGSTaskType_StatsRead] = fun_cb; return Master::G()->GetStatsSrv()->ReadLeaderboard(rankIdx, userIndex, maxRowNum, myScoreOffset); } GS_BOOL ReadFriendsStats(GS_INT boardId, GS_INT columnNum, GS_INT* columnIds, GS_INT rankIdx, GS_INT userIndex, GS_INT maxRowNum, GSCB_Func fun_cb) { if (!Master::G()->GetStatsSrv()) return FALSE; Master::G()->GetStatsSrv()->GetLBDef().Set(boardId,columnNum,columnIds); GS_CallBackFunc[EGSTaskType_StatsReadFriend] = fun_cb; userIndex = SignIn::GetActiveUserIndex(); return Master::G()->GetStatsSrv()->ReadFriendsLeaderboard(rankIdx, userIndex, maxRowNum); } #elif defined(_PS3) GS_INT GetKeyValueFromStats(GS_INT lbIndex) { if (!Master::G()->GetStatsSrv()) return 0; return Master::G()->GetStatsSrv()->GetLocalStats_Key(0,lbIndex); } GS_VOID WriteStats(GSCB_Func fun_cb, GS_INT iLBId, GS_INT score) { if (!Master::G()->GetStatsSrv()) return; Master::G()->GetStatsSrv()->GetLBDef().Set(iLBId,score); GS_CallBackFunc[EGSTaskType_StatsWrite] = fun_cb; Master::G()->GetStatsSrv()->WriteLeaderboard(0); } GS_BOOL ReadStats(GS_INT boardId, GS_INT score, GS_INT rankIdx, GS_INT userIndex, GS_INT maxRowNum, GS_INT myScoreOffset, GSCB_Func fun_cb) { if (!Master::G()->GetStatsSrv()) return FALSE; Master::G()->GetStatsSrv()->GetLBDef().Set(boardId,score); GS_CallBackFunc[EGSTaskType_StatsRead] = fun_cb; return Master::G()->GetStatsSrv()->ReadLeaderboard(rankIdx, userIndex, maxRowNum, myScoreOffset); } GS_BOOL ReadFriendsStats(GS_INT boardId, GS_INT score, GS_INT rankIdx, GS_INT userIndex, GS_INT maxRowNum, GSCB_Func fun_cb) { if (!Master::G()->GetStatsSrv()) return FALSE; Master::G()->GetStatsSrv()->GetLBDef().Set(boardId,score); GS_CallBackFunc[EGSTaskType_StatsReadFriend] = fun_cb; return Master::G()->GetStatsSrv()->ReadFriendsLeaderboard(rankIdx, userIndex, maxRowNum); } #endif GS_VOID DebugOutputStats() { if (!Master::G()->GetStatsSrv()) return; Master::G()->GetStatsSrv()->DebugOutputLeaderboard(); } GS_VOID ShowGamerCard(GS_INT index) { if (!Master::G()->GetStatsSrv()) return; SignIn::ShowGamerCardUI(Master::G()->GetStatsSrv()->GetRetrievedIDByIndex(index)); } // Session Service GS_VOID CreateSession(GSCB_Func fun_cb) { if (!Master::G()->GetSessionSrv()) return; GS_CallBackFunc[EGSTaskType_SessionCreate] = fun_cb; Master::G()->GetSessionSrv()->BeginSession(); } GS_VOID JoinSession(GSCB_Func fun_cb) { if (!Master::G()->GetSessionSrv()) return; GS_CallBackFunc[EGSTaskType_SessionJoin] = fun_cb; Master::G()->GetSessionSrv()->JoinSession(); } GS_BOOL IsSessionCreated() { if (!Master::G()->GetSessionSrv()) return FALSE; return Master::G()->GetSessionSrv()->IsCreated(); } GS_VOID StartSession(GSCB_Func fun_cb) { if (!Master::G()->GetSessionSrv()) return; GS_CallBackFunc[EGSTaskType_SessionStart] = fun_cb; Master::G()->GetSessionSrv()->StartSession(); } GS_BOOL IsSessionStarted() { if (!Master::G()->GetSessionSrv()) return false; return Master::G()->GetSessionSrv()->IsStarted(); } GS_VOID EndSession(GSCB_Func fun_cb) { if (!Master::G()->GetSessionSrv()) return; GS_CallBackFunc[EGSTaskType_SessionEnd] = fun_cb; Master::G()->GetSessionSrv()->EndSession(); } GS_VOID LeaveSession(GSCB_Func fun_cb) { if (!Master::G()->GetSessionSrv()) return; GS_CallBackFunc[EGSTaskType_SessionLeave] = fun_cb; Master::G()->GetSessionSrv()->LeaveSession(); } GS_VOID DeleteSession(GSCB_Func fun_cb) { if (!Master::G()->GetSessionSrv()) return; GS_CallBackFunc[EGSTaskType_SessionDelete] = fun_cb; Master::G()->GetSessionSrv()->DeleteSession(); } // Achievement functions: GS_VOID WriteAchievement(GS_INT num, GS_INT* ids) { if (!Master::G()->GetAchievementSrv()) return; Master::G()->GetAchievementSrv()->Write(num,ids); } GS_VOID ShowAchievementUI() { #if defined(_XBOX) || defined(_XENON) if (!Master::G()->GetAchievementSrv()) return; Master::G()->GetAchievementSrv()->ShowSystemUI(SignIn::GetActiveUserIndex()); #endif } GS_VOID UnlockFullGame() { #if defined(_XBOX) || defined(_XENON) XShowMarketplaceUI(SignIn::GetActiveUserIndex(),XSHOWMARKETPLACEUI_ENTRYPOINT_CONTENTLIST,0,-1); //Master::G()->GetAchievementSrv()->ShowSystemUI(SignIn::GetActiveUserIndex()); #elif defined(_PS3) //#ifdef INGAMEBROWSING // Master::G()->GetInGameBrowsingSrv()->Start(); //#else // Master::G()->GetStoreBrowsingSrv()->Start(); //#endif #endif } GS_BOOL IsUserSignInLive() { #if defined(_XBOX) || defined(_XENON) return SignIn::IsUserSignedInOnline(SignIn::GetActiveUserIndex()); #endif return TRUE; } GS_BOOL IsAchievementEarned(GS_INT index) { if (!Master::G()->GetAchievementSrv()) return FALSE; return Master::G()->GetAchievementSrv()->IsEarned(index); } GS_BOOL HasAchievementRead() { if (!Master::G()->GetAchievementSrv()) return FALSE; return Master::G()->GetAchievementSrv()->HasRead(); } // tracking functions: GS_BOOL TrackingSendTag(char* tag, char* attributes) { return Master::G()->SendTrackingTag(tag, attributes); } GS_INT AreUsersSignedIn() { #if defined(_XBOX) || defined(_XENON) return SignIn::AreUsersSignedIn(); #endif return 0; } #if defined(_XBOX) || defined(_XENON) GS_VOID PressStartButton(GS_INT userIndex) { SignIn::SetActiveUserIndex(userIndex); SignIn::SetBeforePressStart(FALSE); SignIn::QuerySigninStatus(); //SignIn::StorageDeviceReset();//clear storage device id. } #endif GS_CHAR* GetUserName(GS_UINT iUser) { return SignIn::GetUserNameStr( iUser ); } #if defined(_XBOX) || defined(_XENON) GS_BOOL IsUserSignedIn( GS_DWORD dwController ) { return SignIn::IsUserSignedIn( dwController ); } #endif // ======================================================== // Get Language and Locale code // ======================================================== GS_VOID GetConsoleLangLocaleAbbr(char* output) { char* lang; char linker[] = "-"; #if defined(_XBOX) || defined(_XENON) char* locale; switch(XGetLanguage()) { default: case XC_LANGUAGE_ENGLISH: lang = "EN"; break; case XC_LANGUAGE_SCHINESE: case XC_LANGUAGE_TCHINESE: lang = "ZH"; break; case XC_LANGUAGE_KOREAN: lang = "KO"; break; case XC_LANGUAGE_JAPANESE: lang = "JA"; break; case XC_LANGUAGE_PORTUGUESE: lang = "PT"; break; case XC_LANGUAGE_FRENCH: lang = "FR"; break; case XC_LANGUAGE_SPANISH: lang = "ES"; break; case XC_LANGUAGE_ITALIAN: lang = "IT"; break; case XC_LANGUAGE_POLISH: lang = "PL"; break; case XC_LANGUAGE_RUSSIAN: lang = "RU"; break; case XC_LANGUAGE_GERMAN: lang = "DE"; break; // no nl lang for xbox // no no lang for xbox // no hu lang for xbox // no tr lang for xbox // no cs lang for xbox // no sl lang for xbox // no sv lang for xbox // no el lang for xbox } switch(XGetLocale()) { default: case XC_LOCALE_UNITED_STATES: locale = "US"; break; case XC_LOCALE_GREAT_BRITAIN: locale = "GB"; break; case XC_LOCALE_HONG_KONG: locale = "HK"; break; case XC_LOCALE_CANADA: locale = "CA"; break; case XC_LOCALE_AUSTRALIA: locale = "AU"; break; case XC_LOCALE_IRELAND: locale = "IE"; break; case XC_LOCALE_FINLAND: locale = "FI"; break; case XC_LOCALE_DENMARK: locale = "DK"; break; // no il locale for xbox case XC_LOCALE_SOUTH_AFRICA: locale = "ZA"; break; case XC_LOCALE_NORWAY: locale = "NO"; break; case XC_LOCALE_NEW_ZEALAND: locale = "NZ"; break; // no ph locale for xbox // no my locale for xbox case XC_LOCALE_INDIA: locale = "IN"; break; case XC_LOCALE_SINGAPORE: locale = "SG"; break; // no id locale for xbox // no th locale for xbox // no xa locale for xbox case XC_LOCALE_CHINA: locale = "CN"; break; case XC_LOCALE_TAIWAN: locale = "TW"; break; case XC_LOCALE_KOREA: locale = "KR"; break; case XC_LOCALE_JAPAN: locale = "JP"; break; case XC_LOCALE_PORTUGAL: locale = "PT"; break; case XC_LOCALE_BRAZIL: locale = "BR"; break; case XC_LOCALE_FRANCE: locale = "FR"; break; case XC_LOCALE_SWITZERLAND: locale = "CH"; break; case XC_LOCALE_BELGIUM: locale = "BE"; break; // no la locale for xbox case XC_LOCALE_SPAIN: locale = "SE"; break; // no ar locale for xbox case XC_LOCALE_MEXICO: locale = "MX"; break; case XC_LOCALE_COLOMBIA: locale = "CO"; break; // no pr locale for xbox case XC_LOCALE_GERMANY: locale = "DE"; break; case XC_LOCALE_AUSTRIA: locale = "AT"; break; // no ru locale for xbox...... case XC_LOCALE_ITALY: locale = "IT"; break; case XC_LOCALE_GREECE: locale = "GR"; break; case XC_LOCALE_HUNGARY: locale = "HU"; break; // no tr locale for xbox case XC_LOCALE_CZECH_REPUBLIC: locale = "CZ"; break; case XC_LOCALE_SLOVAK_REPUBLIC: locale = "SL"; break; case XC_LOCALE_POLAND: locale = "PL"; break; case XC_LOCALE_SWEDEN: locale = "SE"; break; case XC_LOCALE_CHILE: locale = "CL"; break; case XC_LOCALE_NETHERLANDS: locale = "NL"; break; } strcpy_s(output, 10, lang); strcat_s(output, 10, linker); strcat_s(output, 10, locale); #elif defined(_PS3) if (!SignIn::IsUserOnline()) return; GS_INT ps3_lang = -1; SceNpCountryCode ps3_country; if (sceNpManagerGetAccountRegion(&ps3_country, &ps3_lang) < 0) { strcpy(ps3_country.data, "fr"); } switch(GetSystemLanguage()) { default: case GS_ELang_English: lang = "EN"; break; case GS_ELang_Japanese: lang = "JA"; break; case GS_ELang_French: lang = "FR"; break; case GS_ELang_Spanish: lang = "ES"; break; case GS_ELang_German: lang = "DE"; break; case GS_ELang_Italian: lang = "IT"; break; case GS_ELang_Dutch: lang = "NL"; break; case GS_ELang_Portugese: lang = "PT"; break; case GS_ELang_Russian: lang = "RU"; break; case GS_ELang_Korean: lang = "KO"; break; case GS_ELang_Chinese_t: case GS_ELang_Chinese_s: lang = "ZH"; break; case GS_ELang_Finish: lang = "FI"; break; case GS_ELang_Swedish: lang = "SV"; break; case GS_ELang_Danish: lang = "DA"; break; case GS_ELang_Norwegian: lang = "NO"; break; case GS_ELang_Polish: lang = "PL"; break; } strcpy(output, lang); strcat(output, linker); strcat(output, ps3_country.data); #endif } // ======================================================== // SysMsgBox functions // ======================================================== GS_VOID ShowSysMsgBox_SaveDataNoFreeSpace( GSCB_Func fun_cb, GS_INT needExtraKB ) { if (Master::G()->GetSysMsgBoxManager()) { Master::G()->GetSysMsgBoxManager()->Display(EMODE_SaveDataNoSpace, &needExtraKB); } GS_CallBackFunc[EGSTaskType_SysMsgBox_SaveDataNoFreeSpace] = fun_cb; } GS_VOID ShowSysMsgBox_KeyFileCorrupted() { if (Master::G()->GetSysMsgBoxManager()) { Master::G()->GetSysMsgBoxManager()->Display(EMODE_KeyFileCorrupted); } } GS_VOID ShowSysMsgBox_TrophyNoFreeSpace() { if (Master::G()->GetSysMsgBoxManager()) Master::G()->GetSysMsgBoxManager()->Display(EMODE_TrophyNoSpace); } GS_VOID ShowSysMsgBox_PlayOtherUserSaveData() { if (Master::G()->GetSysMsgBoxManager()) Master::G()->GetSysMsgBoxManager()->Display(EMODE_PlayOtherUserSaveData); } GS_VOID ShowSysMsgBox_PlayerAgeForbidden() { if (Master::G()->GetSysMsgBoxManager()) Master::G()->GetSysMsgBoxManager()->Display(EMODE_PlayerAgeForbidden); } // ======================================================== // RichPresence // ======================================================== #if defined(_XBOX) || defined(_XENON) GS_VOID SetRichPresenceMode(GS_INT userIndex, GS_INT mode) { if (userIndex == -1) { userIndex = SignIn::GetActiveUserIndex(); } // Update the presence mode // TODO: // set Interval of invoking XUserSetContext XUserSetContext( userIndex , X_CONTEXT_PRESENCE, mode ); } GS_VOID UpdateDefaultPresenceInfo(GS_INT defaultInfo, GS_INT activeInfo) { for (GS_INT i=0;i<XUSER_MAX_COUNT;i++) { if (SignIn::IsUserOnline(i)) { if (SignIn::GetActiveUserIndex() == i) SetRichPresenceMode(i, activeInfo); else SetRichPresenceMode(i, defaultInfo); } } } #endif // ======================================================== // Log outside // ======================================================== GS_VOID Log(const GS_CHAR* strFormat, ...) { va_list pArgList; va_start( pArgList, strFormat ); GS_CHAR str[1024]; #if defined(_XBOX) || defined(_XENON) sprintf_s( str, 1024, strFormat, pArgList ); #elif defined(_PS3) sprintf( str, strFormat, pArgList ); #endif Master::G()->Log(str); va_end( pArgList ); } // ======================================================== // InterfaceMgr implementation // for Internal use only // ======================================================== InterfaceMgr::InterfaceMgr(MessageMgr* msgMgr) { if (msgMgr) { msgMgr->Register(EMessage_CallBackInterface,this); } } #define GS_CALLBACK(_index, _ret) { if (GS_CallBackFunc[_index]) {(*(GS_CallBackFunc[_index]))(_ret);} } GS_VOID InterfaceMgr::MessageResponse(Message* message) { GS_Assert(message->GetMessageID() == EMessage_CallBackInterface); GS_INT task_type = *(GS_INT*)message->ReadPayload(0); GS_INT result = *(GS_INT*)message->ReadPayload(1); GS_CALLBACK(task_type, result); } } // namespace GameService #endif // XBOX/XENON/PS3
[ "leavesmaple@383b229b-c81f-2bc2-fa3f-61d2d0c0fe69" ]
[ [ [ 1, 940 ] ] ]
7d523df1a49312dbd52820b52b62e8f12b74416a
91b964984762870246a2a71cb32187eb9e85d74e
/SRC/OFFI SRC!/boost_1_34_1/boost_1_34_1/libs/graph/test/graphviz_test.cpp
7d4472e747fbb51745bdd6b6f4f6f44cfbb6923c
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference", "Artistic-2.0", "LicenseRef-scancode-public-domain" ]
permissive
willrebuild/flyffsf
e5911fb412221e00a20a6867fd00c55afca593c7
d38cc11790480d617b38bb5fc50729d676aef80d
refs/heads/master
2021-01-19T20:27:35.200154
2011-02-10T12:34:43
2011-02-10T12:34:43
32,710,780
3
0
null
null
null
null
UTF-8
C++
false
false
7,087
cpp
// Copyright 2004-5 Trustees of Indiana University // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // graphviz_test.cpp - Test cases for the Boost.Spirit implementation of a // Graphviz DOT Language reader. // // Author: Ronald Garcia //#define BOOST_GRAPH_READ_GRAPHVIZ_ITERATORS #define BOOST_GRAPHVIZ_USE_ISTREAM #include <boost/graph/graphviz.hpp> #include <boost/assign/std/map.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/graph_traits.hpp> #include <boost/tuple/tuple.hpp> #include <boost/dynamic_property_map.hpp> #include <boost/test/test_tools.hpp> #include <boost/test/floating_point_comparison.hpp> #include <algorithm> #include <string> #include <iostream> #include <iterator> #include <map> #include <utility> using namespace std; using namespace boost; #ifndef BOOST_GRAPHVIZ_USE_ISTREAM using namespace boost::spirit; #endif using namespace boost::assign; typedef std::string node_t; typedef std::pair<node_t,node_t> edge_t; typedef std::map<node_t,float> mass_map_t; typedef std::map<edge_t,double> weight_map_t; template <typename Directedness, typename OutEdgeList> bool test_graph(std::istream& dotfile, mass_map_t const& masses, weight_map_t const& weights, std::string const& node_id = "node_id") { typedef adjacency_list < OutEdgeList, vecS, Directedness, property < vertex_name_t, std::string, property < vertex_color_t, float > >, property < edge_weight_t, double > > graph_t; typedef typename graph_traits < graph_t >::edge_descriptor edge_t; typedef typename graph_traits < graph_t >::vertex_descriptor vertex_t; // Construct a graph and set up the dynamic_property_maps. graph_t graph(0); dynamic_properties dp; typename property_map<graph_t, vertex_name_t>::type name = get(vertex_name, graph); dp.property(node_id,name); typename property_map<graph_t, vertex_color_t>::type mass = get(vertex_color, graph); dp.property("mass",mass); typename property_map<graph_t, edge_weight_t>::type weight = get(edge_weight, graph); dp.property("weight",weight); // Read in space characters too! dotfile >> noskipws; bool result = true; #ifdef BOOST_GRAPHVIZ_USE_ISTREAM if(read_graphviz(dotfile,graph,dp,node_id)) { #else std::string data; std::copy(std::istream_iterator<char>(dotfile), std::istream_iterator<char>(), std::back_inserter(data)); if(read_graphviz(data.begin(),data.end(),graph,dp,node_id)) { #endif // check masses if(!masses.empty()) { // assume that all the masses have been set // for each vertex: typename graph_traits<graph_t>::vertex_iterator i,j; for(boost::tie(i,j) = vertices(graph); i != j; ++i) { // - get its name std::string node_name = get(name,*i); // - get its mass float node_mass = get(mass,*i); float ref_mass = masses.find(node_name)->second; // - compare the mass to the result in the table BOOST_CHECK_CLOSE(node_mass, ref_mass, 0.01f); } } // check weights if(!weights.empty()) { // assume that all weights have been set /// for each edge: typename graph_traits<graph_t>::edge_iterator i,j; for(boost::tie(i,j) = edges(graph); i != j; ++i) { // - get its name std::pair<std::string,std::string> edge_name = make_pair(get(name, source(*i,graph)), get(name, target(*i,graph))); // - get its weight double edge_weight = get(weight,*i); double ref_weight = weights.find(edge_name)->second; // - compare the weight to teh result in the table BOOST_CHECK_CLOSE(edge_weight, ref_weight, 0.01); } } } else { std::cerr << "Parsing Failed!\n"; result = false; } return result; } int test_main(int, char*[]) { typedef istringstream gs_t; // Basic directed graph tests { mass_map_t masses; insert ( masses ) ("a",0.0f) ("c",7.7f) ("e", 6.66f); gs_t gs("digraph { a node [mass = 7.7] c e [mass = 6.66] }"); BOOST_CHECK((test_graph<directedS,vecS>(gs,masses,weight_map_t()))); } { weight_map_t weights; insert( weights )(make_pair("a","b"),0.0) (make_pair("c","d"),7.7)(make_pair("e","f"),6.66); gs_t gs("digraph { a -> b edge [weight = 7.7] " "c -> d e-> f [weight = 6.66] }"); BOOST_CHECK((test_graph<directedS,vecS>(gs,mass_map_t(),weights))); } // undirected graph with alternate node_id property name { mass_map_t masses; insert ( masses ) ("a",0.0f) ("c",7.7f) ("e", 6.66f); gs_t gs("graph { a node [mass = 7.7] c e [mass = 6.66] }"); BOOST_CHECK((test_graph<undirectedS,vecS>(gs,masses,weight_map_t(), "nodenames"))); } // Basic undirected graph tests { mass_map_t masses; insert ( masses ) ("a",0.0f) ("c",7.7f) ("e", 6.66f); gs_t gs("graph { a node [mass = 7.7] c e [mass = 6.66] }"); BOOST_CHECK((test_graph<undirectedS,vecS>(gs,masses,weight_map_t()))); } { weight_map_t weights; insert( weights )(make_pair("a","b"),0.0) (make_pair("c","d"),7.7)(make_pair("e","f"),6.66); gs_t gs("graph { a -- b eDge [weight = 7.7] " "c -- d e -- f [weight = 6.66] }"); BOOST_CHECK((test_graph<undirectedS,vecS>(gs,mass_map_t(),weights))); } // Mismatch directed graph test { mass_map_t masses; insert ( masses ) ("a",0.0f) ("c",7.7f) ("e", 6.66f); gs_t gs("graph { a nodE [mass = 7.7] c e [mass = 6.66] }"); try { test_graph<directedS,vecS>(gs,masses,weight_map_t()); } catch (boost::undirected_graph_error&) {} } // Mismatch undirected graph test { mass_map_t masses; insert ( masses ) ("a",0.0f) ("c",7.7f) ("e", 6.66f); gs_t gs("digraph { a node [mass = 7.7] c e [mass = 6.66] }"); try { test_graph<undirectedS,vecS>(gs,masses,weight_map_t()); BOOST_ERROR("Failed to throw boost::directed_graph_error."); } catch (boost::directed_graph_error&) {} } // Complain about parallel edges { weight_map_t weights; insert( weights )(make_pair("a","b"),7.7); gs_t gs("diGraph { a -> b [weight = 7.7] a -> b [weight = 7.7] }"); try { test_graph<directedS,setS>(gs,mass_map_t(),weights); BOOST_ERROR("Failed to throw boost::bad_parallel_edge."); } catch (boost::bad_parallel_edge&) {} } // Handle parallel edges gracefully { weight_map_t weights; insert( weights )(make_pair("a","b"),7.7); gs_t gs("digraph { a -> b [weight = 7.7] a -> b [weight = 7.7] }"); BOOST_CHECK((test_graph<directedS,vecS>(gs,mass_map_t(),weights))); } return 0; }
[ "[email protected]@e2c90bd7-ee55-cca0-76d2-bbf4e3699278" ]
[ [ [ 1, 214 ] ] ]
fc43b07283000ee01d4b1137a9ae8bf067ab3972
16d41562840d132a358388c2d02160f6bfd8c7d9
/tpd/source/4289 - Disgruntled Judge/judge.cpp
a9f718a7b2c669626752ad8d7121b81eea903652
[]
no_license
LMC00021002/pap2010-grupo14
a19547639506848f33a552dcb8d1bc293d3c528c
1ffebb02f9aa256e1c83ce1c941a2be6da50a218
refs/heads/master
2021-01-10T16:50:29.118977
2010-07-06T16:11:45
2010-07-06T16:11:45
48,855,309
0
0
null
null
null
null
UTF-8
C++
false
false
1,534
cpp
#include<iostream> using namespace std; #define forn(N,X) for(int X=0; X<(int)(N); ++X) #define forinvn(N,X) for(int X=(int)(N)-1; X>=0; --X) #define fromto(N,M,X) for (int X=N; X<M; X++) #define MAXN 10001 //bool ab[MAXN][MAXN]; int main(void) { int cases; cin >> cases; int input[100]; int input73[100]; int input137[100]; bool escandidato = false; int outputa; int outputb; int i73,i137,j73,j137; forn (cases,i) { cin >> input[i]; input73[i] = input[i] % 73; input137[i] = input[i] % 137; } i73 = i137 = -1; forn(MAXN,i) { //i73 = i % 73; i73++; if (i73 == 73) i73 = 0; //ii73 = i73*i73%73; i137++; if (i137 == 137) i137 = 0; //ii137 = i137*i137%137; j73 = j137 = -1; forn(MAXN,j) { j73++; if (j73 == 73) j73 = 0; //ij73 = j73 * i73 % 73; j137++; if (j137 == 137) j137 = 0; //ij137 = j137 * i137 % 137; forn(cases-1,t) { /* escandidato = (ii73 + input73[t] *i73 + ij73+ j73) % 73 == input73[t+1] && (ii137 + input137[t] * i137 + ij137 + j137) % 137 == input137[t+1];*/ escandidato = ((i73 * input73[t] + j73 )*i73+ j73) % 73 == input73[t+1] && ((i137 * input137[t] + j137 )*i137+ j137) % 137 == input137[t+1]; if (!escandidato)break; } if (escandidato) { outputa = i; outputb = j; break; } } if (escandidato)break; } forn (cases,t) cout << (outputa * input[t] + outputb) % MAXN << endl; return 0; }
[ "tutecosta@d1b1875b-4509-22a8-4f88-0435eeb08bb5" ]
[ [ [ 1, 78 ] ] ]
04fb9be11068d818161361adfc4d1a5145cc460c
c1c3866586c56ec921cd8c9a690e88ac471adfc8
/CEGUI/CEGUI-0.6.0/include/elements/CEGUITreeProperties.h
954a3a0b3500622aab6bf18789bf5c6ff9d237f6
[ "Zlib", "LicenseRef-scancode-pcre", "MIT" ]
permissive
rtmpnewbie/lai3d
0802dbb5ebe67be2b28d9e8a4d1cc83b4f36b14f
b44c9edfb81fde2b40e180a651793fec7d0e617d
refs/heads/master
2021-01-10T04:29:07.463289
2011-03-22T17:51:24
2011-03-22T17:51:24
36,842,700
1
0
null
null
null
null
UTF-8
C++
false
false
5,508
h
/*********************************************************************** filename: CEGUITreeProperties.h created: 5-13-07 author: Jonathan Welch (Based on Code by David Durant) *************************************************************************/ /*************************************************************************** * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************/ #ifndef _CEGUITreeProperties_h_ #define _CEGUITreeProperties_h_ #include "CEGUIProperty.h" // Start of CEGUI namespace section namespace CEGUI { // Start of TreeProperties namespace section /*! \brief Namespace containing all classes that make up the properties interface for the Listbox class */ namespace TreeProperties { /*! \brief Property to access the sort setting of the list box. \par Usage: - Name: Sort - Format: "[text]" \par Where [Text] is: - "True" to indicate the list items should be sorted. - "False" to indicate the list items should not be sorted. */ class Sort : public Property { public: Sort() : Property( "Sort", "Property to get/set the sort setting of the list box. Value is either \"True\" or \"False\".", "False") {} String get(const PropertyReceiver* receiver) const; void set(PropertyReceiver* receiver, const String& value); }; /*! \brief Property to access the multi-select setting of the list box. \par Usage: - Name: MultiSelect - Format: "[text]" \par Where [Text] is: - "True" to indicate that multiple items may be selected. - "False" to indicate that only a single item may be selected. */ class MultiSelect : public Property { public: MultiSelect() : Property( "MultiSelect", "Property to get/set the multi-select setting of the list box. Value is either \"True\" or \"False\".", "False") {} String get(const PropertyReceiver* receiver) const; void set(PropertyReceiver* receiver, const String& value); }; /*! \brief Property to access the 'always show' setting for the vertical scroll bar of the list box. \par Usage: - Name: ForceVertScrollbar - Format: "[text]" \par Where [Text] is: - "True" to indicate that the vertical scroll bar will always be shown. - "False" to indicate that the vertical scroll bar will only be shown when it is needed. */ class ForceVertScrollbar : public Property { public: ForceVertScrollbar() : Property( "ForceVertScrollbar", "Property to get/set the 'always show' setting for the vertical scroll bar of the list box. Value is either \"True\" or \"False\".", "False") {} String get(const PropertyReceiver* receiver) const; void set(PropertyReceiver* receiver, const String& value); }; /*! \brief Property to access the 'always show' setting for the horizontal scroll bar of the list box. \par Usage: - Name: ForceHorzScrollbar - Format: "[text]" \par Where [Text] is: - "True" to indicate that the horizontal scroll bar will always be shown. - "False" to indicate that the horizontal scroll bar will only be shown when it is needed. */ class ForceHorzScrollbar : public Property { public: ForceHorzScrollbar() : Property( "ForceHorzScrollbar", "Property to get/set the 'always show' setting for the horizontal scroll bar of the list box. Value is either \"True\" or \"False\".", "False") {} String get(const PropertyReceiver* receiver) const; void set(PropertyReceiver* receiver, const String& value); }; /*! \brief Property to access the show item tooltips setting of the list box. \par Usage: - Name: ItemTooltips - Format: "[text]" \par Where [Text] is: - "True" to indicate that the tooltip of the list box will be set by the item below the mouse pointer - "False" to indicate that the list box has a static tooltip. */ class ItemTooltips : public Property { public: ItemTooltips() : Property( "ItemTooltips", "Property to access the show item tooltips setting of the list box. Value is either \"True\" or \"False\".", "False") {} String get(const PropertyReceiver* receiver) const; void set(PropertyReceiver* receiver, const String& value); }; } // End of TreeProperties namespace section } // End of CEGUI namespace section #endif // end of guard _CEGUITreeProperties_h_
[ "laiyanlin@27d9c402-1b7e-11de-9433-ad2e3fad96c5" ]
[ [ [ 1, 177 ] ] ]
029ae88cb140f772fe1bc9f9d8967f09fc422dc4
2d2e8f07bf92bb395993bfcdf7917c17674ac8cd
/fub001/src/Plugins/calculation/ProjectionSurfaces/Warp.h
c0a98fc52ed73d87e62b0a25621406b066c563a4
[]
no_license
olekristensen/fuckyoubody
0a8a2b446c57f2e190eb61bee8ae56fcf5e10b7c
e6c656ff2cd02473d9252c036381c32a34b279f8
refs/heads/master
2020-03-31T00:16:08.127306
2010-02-20T21:15:59
2010-02-20T21:15:59
32,136,171
0
0
null
null
null
null
UTF-8
C++
false
false
785
h
#ifndef WARP_H #define WARP_H #include "ofxOpenCv.h" #include "ofGraphics.h" #include "ofxVectorMath.h" class Warp { public: Warp(); ~Warp(); void SetCorner(int i, float x, float y); void SetClosestCorner(float x, float y); int GetClosestCorner(float x, float y); void SetWindowSize(float _w, float _h); void DrawCorners(); float* MatrixCalculate(); void MatrixMultiply(); ofxPoint2f convertPoint(ofxPoint2f point); ofxPoint2f corners[4]; private: // CORNERS float w; float h; CvPoint2D32f cvsrc[4]; CvPoint2D32f cvdst[4]; // MATRIX STUFF GLfloat gl_matrix_4x4[16]; CvMat* cv_translate_3x3; CvMat* cv_srcmatrix_4x2; CvMat* cv_dstmatrix_4x2; }; #endif
[ "[email protected]@e8aa6d0e-c866-11de-ba9a-9db95b2bc6c5", "[email protected]@e8aa6d0e-c866-11de-ba9a-9db95b2bc6c5" ]
[ [ [ 1, 22 ], [ 25, 42 ] ], [ [ 23, 24 ] ] ]
398a6f06c111efa53b18e9b1771839b595b6fae2
1736474d707f5c6c3622f1cd370ce31ac8217c12
/Pseudo/TextWriter.hpp
6578785c053b44ecb870a0389f7c027cc80ffd8d
[]
no_license
arlm/pseudo
6d7450696672b167dd1aceec6446b8ce137591c0
27153e50003faff31a3212452b1aec88831d8103
refs/heads/master
2022-11-05T23:38:08.214807
2011-02-18T23:18:36
2011-02-18T23:18:36
275,132,368
0
0
null
null
null
null
UTF-8
C++
false
false
882
hpp
// Copyright (c) John Lyon-Smith. All rights reserved. #pragma once #ifndef __PSEUDO_TEXT_WRITER_HPP__ #define __PSEUDO_TEXT_WRITER_HPP__ #pragma warning(push) #include <Pseudo\ValueType.hpp> #include <Pseudo\String.hpp> namespace Pseudo { /// <summary> /// TextWriter for writing encoded text /// </summary> class TextWriter { private: public: TextWriter() { } public: virtual ~TextWriter() { } public: virtual void Write(Char c) = 0; public: virtual void Write(const String& s) = 0; public: virtual void Write(const Char* p, ...) = 0; public: virtual void WriteLine() = 0; public: virtual void WriteLine(Char c) = 0; public: virtual void WriteLine(const String& s) = 0; public: virtual void WriteLine(const Char* p, ...) = 0; }; } #pragma warning(pop) #endif // __PSEUDO_TEXT_WRITER_HPP__
[ [ [ 1, 42 ] ] ]
e4bed73a7993ed6dc7a2fc459c99b4b7b827fcb2
c5534a6df16a89e0ae8f53bcd49a6417e8d44409
/trunk/nGENE Toolset/frmMain.h
3bb7a0d0308052ee396de32da31b54ff38ec4763
[]
no_license
svn2github/ngene
b2cddacf7ec035aa681d5b8989feab3383dac012
61850134a354816161859fe86c2907c8e73dc113
refs/heads/master
2023-09-03T12:34:18.944872
2011-07-27T19:26:04
2011-07-27T19:26:04
78,163,390
2
0
null
null
null
null
UTF-8
C++
false
false
143,801
h
/* --------------------------------------------------------------------------- This source file is part of nGENE Tech. Copyright (c) 2006- Wojciech Toman This program is free software. File: frmMain.h Version: 0.08 --------------------------------------------------------------------------- */ #pragma once #ifndef __INC_FRMMAIN_H_ #define __INC_FRMMAIN_H_ #include "frmAbout.h" #include "frmErrorList.h" #include "frmHeightMapEditor.h" #include "frmMaterialEditor.h" #include "frmMaterialLib.h" #include "frmOutput.h" #include "frmPropertyManager.h" #include "frmRenderTarget.h" #include "frmSceneGraph.h" #include "frmScriptEditor.h" #include "ShaderEditor.h" #include "frmSolutionExplorer.h" #include "frmToolbox.h" #include "frmWebBrowser.h" #include "frmFXs.h" #include "MaterialWrapper.h" #include "CameraWrapper.h" #include "LightWrapper.h" #include "EngineWrapper.h" #include "FurWrapper.h" #include "LightningWrapper.h" #include "MeshWrapper.h" #include "PrefabBoxWrapper.h" #include "PrefabCapsuleWrapper.h" #include "PrefabCylinderWrapper.h" #include "PrefabPlaneWrapper.h" #include "PrefabPyramidWrapper.h" #include "PrefabSphereWrapper.h" #include "PrefabTeapotWrapper.h" #include "PrefabTorusWrapper.h" #include "RigidBodyWrapper.h" #include "SkyWrapper.h" #include "SoundWrapper.h" #include "CloudsWrapper.h" #include "TerrainWrapper.h" #include "WaterWrapper.h" #include "ParticleSystemWrapper.h" namespace nGENEToolset { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace WeifenLuo::WinFormsUI::Docking; using WeifenLuo::WinFormsUI::Docking::DockPanel; /** Application MDI main form. */ public ref class frmMain: public System::Windows::Forms::Form { private: nGENEToolset::frmRenderTarget^ target; ///< Form to which rendering is done. private: System::Windows::Forms::ToolStripButton^ tbsNewProject; private: System::Windows::Forms::ToolStripButton^ tsbOpen; private: System::Windows::Forms::ToolStripButton^ tsbSave; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator8; private: System::Windows::Forms::ToolStripButton^ toolStripButton4; private: System::Windows::Forms::ToolStripButton^ toolStripButton5; private: System::Windows::Forms::ToolStripButton^ toolStripButton6; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator9; private: System::Windows::Forms::ToolStripButton^ toolStripButton7; private: System::Windows::Forms::ToolStripButton^ toolStripButton8; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator10; private: System::Windows::Forms::ToolStripMenuItem^ mnuContentAuthoringShaderEditor; private: System::Windows::Forms::ToolStripMenuItem^ mnuMaterialEditor; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator11; private: System::Windows::Forms::ToolStripMenuItem^ animationEditorToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ textureEditorToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ texturedToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ exportSelectedToolStripMenuItem; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator12; private: System::Windows::Forms::ToolStripMenuItem^ mnuFileSave; private: System::Windows::Forms::ToolStripMenuItem^ saveAsToolStripMenuItem; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator13; private: System::Windows::Forms::ToolStripMenuItem^ simulationToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ pausedToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuLighting; private: System::Windows::Forms::ToolStripMenuItem^ modesToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ aIToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuSimulationModesPhysics; private: System::Windows::Forms::ToolStripMenuItem^ gameplayToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ materialLibraryToolStripMenuItem1; private: System::Windows::Forms::ToolStripMenuItem^ lightToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertLightDirectional; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertLightOmni; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertLightSpot; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertMesh; private: System::Windows::Forms::ToolStripMenuItem^ particleSystemToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ prefabToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPrefabBox; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPrefabSphere; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPrefabPlane; nGENEToolset::frmAbout^ frmAboutBox; ///< About box nGENEToolset::frmMaterialLib^ frmMatLib; ///< Material library window nGENEToolset::frmOutput^ frmOut; ///< Output window nGENEToolset::frmErrorList^ frmError; ///< Error list nGENEToolset::frmPropertyManager^ frmProperty; ///< Properties window nGENEToolset::frmMaterialEditor^ frmMatEdit; ///< Material editor window nGENEToolset::frmToolbox^ frmTools; ///< Toolbox nGENEToolset::frmFXs^ frmFX; ///< Special effects nGENEToolset::frmSceneGraph^ frmGraph; ///< Scene graph viewer nGENEToolset::frmSolutionExplorer^ frmExplorer; ///< Solution explorer nGENEToolset::frmHeightMapEditor^ frmHeight; ///< Height-map editor nGENEToolset::ShaderEditor^ frmShader; ///< Shader editor nGENEToolset::frmScriptEditor^ frmScript; ///< Script editor private: System::Windows::Forms::ToolStripMenuItem^ scenegraphEditorToolStripMenuItem; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator14; nGENEToolset::frmWebBrowser^ frmBrowser; ///< Built-in web browser private: System::Windows::Forms::ToolStripStatusLabel^ tssLabel; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator15; private: System::Windows::Forms::ToolStripMenuItem^ mnuScriptEditor; private: System::Windows::Forms::ToolStripMenuItem^ mnuNewProject; private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem1; private: System::Windows::Forms::ToolStripMenuItem^ projectToolStripMenuItem1; private: System::Windows::Forms::ToolStripMenuItem^ mnuFileOpenFile; private: System::Windows::Forms::ToolStripMenuItem^ saveAllToolStripMenuItem; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator16; private: System::Windows::Forms::ToolStripMenuItem^ closeToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ cameraToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertCameraFPP; nGENEToolset::LightWrapper^ light; ///< @todo Remove it nGENEToolset::TerrainWrapper^ terrain; ///< @todo Remove it nGENEToolset::SkyWrapper^ sky; ///< @todo Remove it nGENEToolset::SceneNode^ nodeObj; private: System::Windows::Forms::ToolStripMenuItem^ windowToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuWindowSaveLayout; private: System::Windows::Forms::ToolStripMenuItem^ outdoorToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertOutdoorSky; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertOutdoorTerrain; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertOutdoorClouds; private: System::Windows::Forms::ToolStripMenuItem^ mnuInstertOutdoorWater; private: System::Windows::Forms::ToolStripMenuItem^ mnuViewMaterialLibrary; private: System::Windows::Forms::ToolStripMenuItem^ mnuViewOutput; private: System::Windows::Forms::ToolStripMenuItem^ mnuViewSolutionExplorer; private: System::Windows::Forms::ToolStripMenuItem^ mnuViewToolbox; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPSParticleSystem; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPSParticleEmitter; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPSParticleColour; private: System::Windows::Forms::ToolStripMenuItem^ mnuViewModeHDR; private: System::Windows::Forms::ToolStripButton^ tbsRemoveNode; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator17; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator18; private: System::Windows::Forms::ToolStripMenuItem^ mnuViewModeShadows; private: System::Windows::Forms::ToolStripMenuItem^ mnuViewModeReflections; private: System::Windows::Forms::ToolStripMenuItem^ mnuHelpTutorials; private: System::Windows::Forms::ToolStripMenuItem^ mnuViewModeDebugInfo; private: System::Windows::Forms::ToolStripButton^ tsbLockX; private: System::Windows::Forms::ToolStripButton^ tsbLockY; private: System::Windows::Forms::ToolStripButton^ tsbLockZ; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator19; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator20; private: System::Windows::Forms::ToolStripMenuItem^ lockAxesToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ xAxisToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ yAxisToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ zAxisToolStripMenuItem; private: System::Windows::Forms::ToolStrip^ toolStrip2; private: System::Windows::Forms::ToolStripButton^ tbsLight; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator21; private: System::Windows::Forms::ToolStripButton^ tbsBox; private: System::Windows::Forms::ToolStripButton^ tbsSphere; private: System::Windows::Forms::ToolStripButton^ tbsPlane; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator22; private: System::Windows::Forms::ToolStripButton^ tbsCamera; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator23; private: System::Windows::Forms::ToolStripButton^ tbsTerrain; private: System::Windows::Forms::ToolStripButton^ tbsSky; private: System::Windows::Forms::ToolStripButton^ tbsClouds; private: System::Windows::Forms::ToolStripButton^ tbsWater; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator24; private: System::Windows::Forms::ToolStripButton^ tbsParticleSystem; private: System::Windows::Forms::ToolStripButton^ tbsParticleEmitter; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator25; private: System::Windows::Forms::ToolStripButton^ tbsMesh; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator26; private: System::Windows::Forms::ToolStripMenuItem^ otherToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertOtherFur; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator27; private: System::Windows::Forms::ToolStripMenuItem^ mnuHeightMapEditor; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPSParticleForce; private: System::Windows::Forms::ToolStripMenuItem^ mnuErrorList; private: System::Windows::Forms::ToolStripMenuItem^ physicsToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ rigidBodyToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ softBodyToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ clothToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ controllerToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPhysicsRigidActor; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator28; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPhysicsRigidBox; private: System::Windows::Forms::ToolStripMenuItem^ boxToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ capsuleToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ planeToolStripMenuItem1; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator29; private: System::Windows::Forms::ToolStripMenuItem^ meshToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ terrainToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuFXs; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertLightVolumetric; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertSound; private: System::Windows::Forms::ToolStripButton^ tbsSound; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator30; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertLightning; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPrefabCapsule; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPrefabTeapot; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPrefabTorus; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPrefabCylinder; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPrefabPyramid; private: System::Windows::Forms::ToolStripMenuItem^ mnuInsertPSParticleDeflector; private: System::Windows::Forms::ToolStripStatusLabel^ tssFPS; private: WeifenLuo::WinFormsUI::Docking::DockPanel^ dockManager; private: System::Windows::Forms::ToolStripMenuItem^ renderingToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuSimulationRenderingContinuous; private: System::Windows::Forms::ToolStripMenuItem^ mnuSimulationRenderingRequestRender; nGENEToolset::CameraWrapper^ camera; public: frmMain(void) { InitializeComponent(); } private: System::Windows::Forms::MenuStrip^ mnsMainMenu; System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ editToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ helpToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ mnuAbout; System::Windows::Forms::ToolStripMenuItem^ newToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ undoToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ redoToolStripMenuItem; System::Windows::Forms::ToolStripSeparator^ toolStripSeparator2; System::Windows::Forms::ToolStrip^ toolStrip1; private: System::Windows::Forms::StatusStrip^ stsStrip; System::Windows::Forms::ToolStripMenuItem^ insertToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ viewToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ searchToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ contentsToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ indexToolStripMenuItem; System::Windows::Forms::ToolStripSeparator^ toolStripSeparator3; private: System::Windows::Forms::ToolStripMenuItem^ mnuNGENEOnTheWeb; System::Windows::Forms::ToolStripMenuItem^ technicalSupportToolStripMenuItem; System::Windows::Forms::ToolStripSeparator^ toolStripSeparator4; System::Windows::Forms::ToolStripMenuItem^ toolsToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ openToolStripMenuItem; System::Windows::Forms::ToolStripSeparator^ toolStripSeparator5; System::Windows::Forms::ToolStripMenuItem^ exitToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ customizeToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuToolsOptions; System::Windows::Forms::ToolStripMenuItem^ cutToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ copyToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ pasteToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuEditDelete; System::Windows::Forms::ToolStripMenuItem^ materialLibraryToolStripMenuItem; System::Windows::Forms::ToolStripSeparator^ toolStripSeparator6; System::Windows::Forms::ToolStripMenuItem^ toolbarsToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ standardToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ fullToolStripMenuItem; System::Windows::Forms::ToolStripSeparator^ toolStripSeparator7; System::Windows::Forms::ToolStripMenuItem^ modeToolStripMenuItem; System::Windows::Forms::ToolStripMenuItem^ solidToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ mnuWireframe; WeifenLuo::WinFormsUI::Docking::DeserializeDockContent^ deserializeDockContent; private: System::Windows::Forms::ToolStripMenuItem^ mnuViewPropertyManager; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator1; System::Windows::Forms::ToolStripMenuItem^ propertiesToolStripMenuItem; protected: //FrameworkWin32* app; /// <summary> /// Clean up any resources being used. /// </summary> ~frmMain() { if(components) delete components; //if(app) // delete app; } private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(frmMain::typeid)); this->mnsMainMenu = (gcnew System::Windows::Forms::MenuStrip()); this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->newToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuNewProject = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->fileToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->openToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->projectToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuFileOpenFile = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator5 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->mnuFileSave = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->saveAsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->saveAllToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator16 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->closeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator13 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->exportSelectedToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator12 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->editToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->undoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->redoToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator2 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->cutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->copyToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->pasteToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator18 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->mnuEditDelete = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator20 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->lockAxesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->xAxisToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->yAxisToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->zAxisToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->insertToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->lightToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertLightDirectional = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertLightOmni = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertLightSpot = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertLightVolumetric = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertMesh = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->particleSystemToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPSParticleSystem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPSParticleEmitter = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPSParticleColour = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPSParticleForce = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPSParticleDeflector = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->prefabToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPrefabBox = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPrefabSphere = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPrefabCapsule = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPrefabCylinder = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPrefabPlane = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPrefabPyramid = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPrefabTeapot = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPrefabTorus = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->cameraToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertCameraFPP = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->outdoorToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertOutdoorSky = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertOutdoorTerrain = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertOutdoorClouds = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInstertOutdoorWater = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertLightning = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->otherToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertOtherFur = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->physicsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->rigidBodyToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertPhysicsRigidActor = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator28 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->mnuInsertPhysicsRigidBox = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->boxToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->capsuleToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->planeToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator29 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->meshToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->terrainToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->softBodyToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->clothToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->controllerToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuInsertSound = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->viewToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuViewMaterialLibrary = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuViewOutput = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuErrorList = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuViewPropertyManager = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuViewSolutionExplorer = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuViewToolbox = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuFXs = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->toolbarsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->standardToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->modeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->solidToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->texturedToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuWireframe = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuLighting = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuViewModeHDR = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuViewModeShadows = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuViewModeReflections = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuViewModeDebugInfo = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->fullToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator7 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->propertiesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->materialLibraryToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuContentAuthoringShaderEditor = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuMaterialEditor = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->materialLibraryToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator11 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->animationEditorToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->textureEditorToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator15 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->mnuScriptEditor = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator27 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->mnuHeightMapEditor = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator6 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->scenegraphEditorToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator14 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->customizeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuToolsOptions = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->simulationToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->pausedToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->modesToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->aIToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuSimulationModesPhysics = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->gameplayToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->windowToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuWindowSaveLayout = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->helpToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->searchToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->contentsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->indexToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator3 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->mnuNGENEOnTheWeb = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuHelpTutorials = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->technicalSupportToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStripSeparator4 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->mnuAbout = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->toolStrip1 = (gcnew System::Windows::Forms::ToolStrip()); this->tbsNewProject = (gcnew System::Windows::Forms::ToolStripButton()); this->tsbOpen = (gcnew System::Windows::Forms::ToolStripButton()); this->tsbSave = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator8 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->toolStripButton4 = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripButton5 = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripButton6 = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator9 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->tbsRemoveNode = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator17 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->toolStripButton7 = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripButton8 = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator10 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->tsbLockX = (gcnew System::Windows::Forms::ToolStripButton()); this->tsbLockY = (gcnew System::Windows::Forms::ToolStripButton()); this->tsbLockZ = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator19 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->stsStrip = (gcnew System::Windows::Forms::StatusStrip()); this->tssLabel = (gcnew System::Windows::Forms::ToolStripStatusLabel()); this->tssFPS = (gcnew System::Windows::Forms::ToolStripStatusLabel()); this->dockManager = (gcnew WeifenLuo::WinFormsUI::Docking::DockPanel()); this->toolStrip2 = (gcnew System::Windows::Forms::ToolStrip()); this->tbsLight = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator21 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->tbsBox = (gcnew System::Windows::Forms::ToolStripButton()); this->tbsSphere = (gcnew System::Windows::Forms::ToolStripButton()); this->tbsPlane = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator22 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->tbsCamera = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator23 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->tbsTerrain = (gcnew System::Windows::Forms::ToolStripButton()); this->tbsSky = (gcnew System::Windows::Forms::ToolStripButton()); this->tbsClouds = (gcnew System::Windows::Forms::ToolStripButton()); this->tbsWater = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator24 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->tbsParticleSystem = (gcnew System::Windows::Forms::ToolStripButton()); this->tbsParticleEmitter = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator25 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->tbsMesh = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator26 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->tbsSound = (gcnew System::Windows::Forms::ToolStripButton()); this->toolStripSeparator30 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->renderingToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuSimulationRenderingContinuous = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnuSimulationRenderingRequestRender = (gcnew System::Windows::Forms::ToolStripMenuItem()); this->mnsMainMenu->SuspendLayout(); this->toolStrip1->SuspendLayout(); this->stsStrip->SuspendLayout(); this->toolStrip2->SuspendLayout(); this->SuspendLayout(); // // mnsMainMenu // this->mnsMainMenu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(8) {this->fileToolStripMenuItem, this->editToolStripMenuItem, this->insertToolStripMenuItem, this->viewToolStripMenuItem, this->toolsToolStripMenuItem, this->simulationToolStripMenuItem, this->windowToolStripMenuItem, this->helpToolStripMenuItem}); this->mnsMainMenu->Location = System::Drawing::Point(0, 0); this->mnsMainMenu->Name = L"mnsMainMenu"; this->mnsMainMenu->Padding = System::Windows::Forms::Padding(4, 2, 0, 2); this->mnsMainMenu->RenderMode = System::Windows::Forms::ToolStripRenderMode::System; this->mnsMainMenu->Size = System::Drawing::Size(1158, 24); this->mnsMainMenu->TabIndex = 0; this->mnsMainMenu->Text = L"mnsMainMenu"; // // fileToolStripMenuItem // this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(12) {this->newToolStripMenuItem, this->openToolStripMenuItem, this->toolStripSeparator5, this->mnuFileSave, this->saveAsToolStripMenuItem, this->saveAllToolStripMenuItem, this->toolStripSeparator16, this->closeToolStripMenuItem, this->toolStripSeparator13, this->exportSelectedToolStripMenuItem, this->toolStripSeparator12, this->exitToolStripMenuItem}); this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem"; this->fileToolStripMenuItem->Size = System::Drawing::Size(37, 20); this->fileToolStripMenuItem->Text = L"File"; // // newToolStripMenuItem // this->newToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuNewProject, this->fileToolStripMenuItem1}); this->newToolStripMenuItem->Name = L"newToolStripMenuItem"; this->newToolStripMenuItem->Size = System::Drawing::Size(162, 22); this->newToolStripMenuItem->Text = L"New"; this->newToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::newToolStripMenuItem_Click); // // mnuNewProject // this->mnuNewProject->Name = L"mnuNewProject"; this->mnuNewProject->Size = System::Drawing::Size(120, 22); this->mnuNewProject->Text = L"Project..."; // // fileToolStripMenuItem1 // this->fileToolStripMenuItem1->Name = L"fileToolStripMenuItem1"; this->fileToolStripMenuItem1->Size = System::Drawing::Size(120, 22); this->fileToolStripMenuItem1->Text = L"File..."; // // openToolStripMenuItem // this->openToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->projectToolStripMenuItem1, this->mnuFileOpenFile}); this->openToolStripMenuItem->Name = L"openToolStripMenuItem"; this->openToolStripMenuItem->Size = System::Drawing::Size(162, 22); this->openToolStripMenuItem->Text = L"Open"; // // projectToolStripMenuItem1 // this->projectToolStripMenuItem1->Name = L"projectToolStripMenuItem1"; this->projectToolStripMenuItem1->Size = System::Drawing::Size(120, 22); this->projectToolStripMenuItem1->Text = L"Project..."; // // mnuFileOpenFile // this->mnuFileOpenFile->Name = L"mnuFileOpenFile"; this->mnuFileOpenFile->Size = System::Drawing::Size(120, 22); this->mnuFileOpenFile->Text = L"File..."; this->mnuFileOpenFile->Click += gcnew System::EventHandler(this, &frmMain::mnuFileOpenFile_Click); // // toolStripSeparator5 // this->toolStripSeparator5->Name = L"toolStripSeparator5"; this->toolStripSeparator5->Size = System::Drawing::Size(159, 6); // // mnuFileSave // this->mnuFileSave->Name = L"mnuFileSave"; this->mnuFileSave->Size = System::Drawing::Size(162, 22); this->mnuFileSave->Text = L"Save"; this->mnuFileSave->Click += gcnew System::EventHandler(this, &frmMain::mnuFileSave_Click); // // saveAsToolStripMenuItem // this->saveAsToolStripMenuItem->Name = L"saveAsToolStripMenuItem"; this->saveAsToolStripMenuItem->Size = System::Drawing::Size(162, 22); this->saveAsToolStripMenuItem->Text = L"Save as..."; // // saveAllToolStripMenuItem // this->saveAllToolStripMenuItem->Name = L"saveAllToolStripMenuItem"; this->saveAllToolStripMenuItem->Size = System::Drawing::Size(162, 22); this->saveAllToolStripMenuItem->Text = L"Save all"; // // toolStripSeparator16 // this->toolStripSeparator16->Name = L"toolStripSeparator16"; this->toolStripSeparator16->Size = System::Drawing::Size(159, 6); // // closeToolStripMenuItem // this->closeToolStripMenuItem->Name = L"closeToolStripMenuItem"; this->closeToolStripMenuItem->Size = System::Drawing::Size(162, 22); this->closeToolStripMenuItem->Text = L"Close"; // // toolStripSeparator13 // this->toolStripSeparator13->Name = L"toolStripSeparator13"; this->toolStripSeparator13->Size = System::Drawing::Size(159, 6); // // exportSelectedToolStripMenuItem // this->exportSelectedToolStripMenuItem->Name = L"exportSelectedToolStripMenuItem"; this->exportSelectedToolStripMenuItem->Size = System::Drawing::Size(162, 22); this->exportSelectedToolStripMenuItem->Text = L"Export selected..."; // // toolStripSeparator12 // this->toolStripSeparator12->Name = L"toolStripSeparator12"; this->toolStripSeparator12->Size = System::Drawing::Size(159, 6); // // exitToolStripMenuItem // this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem"; this->exitToolStripMenuItem->Size = System::Drawing::Size(162, 22); this->exitToolStripMenuItem->Text = L"Exit"; this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::exitToolStripMenuItem_Click); // // editToolStripMenuItem // this->editToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(10) {this->undoToolStripMenuItem, this->redoToolStripMenuItem, this->toolStripSeparator2, this->cutToolStripMenuItem, this->copyToolStripMenuItem, this->pasteToolStripMenuItem, this->toolStripSeparator18, this->mnuEditDelete, this->toolStripSeparator20, this->lockAxesToolStripMenuItem}); this->editToolStripMenuItem->Name = L"editToolStripMenuItem"; this->editToolStripMenuItem->Size = System::Drawing::Size(39, 20); this->editToolStripMenuItem->Text = L"Edit"; // // undoToolStripMenuItem // this->undoToolStripMenuItem->Name = L"undoToolStripMenuItem"; this->undoToolStripMenuItem->Size = System::Drawing::Size(124, 22); this->undoToolStripMenuItem->Text = L"Undo"; // // redoToolStripMenuItem // this->redoToolStripMenuItem->Name = L"redoToolStripMenuItem"; this->redoToolStripMenuItem->Size = System::Drawing::Size(124, 22); this->redoToolStripMenuItem->Text = L"Redo"; // // toolStripSeparator2 // this->toolStripSeparator2->Name = L"toolStripSeparator2"; this->toolStripSeparator2->Size = System::Drawing::Size(121, 6); // // cutToolStripMenuItem // this->cutToolStripMenuItem->Name = L"cutToolStripMenuItem"; this->cutToolStripMenuItem->Size = System::Drawing::Size(124, 22); this->cutToolStripMenuItem->Text = L"Cut"; // // copyToolStripMenuItem // this->copyToolStripMenuItem->Name = L"copyToolStripMenuItem"; this->copyToolStripMenuItem->Size = System::Drawing::Size(124, 22); this->copyToolStripMenuItem->Text = L"Copy"; // // pasteToolStripMenuItem // this->pasteToolStripMenuItem->Name = L"pasteToolStripMenuItem"; this->pasteToolStripMenuItem->Size = System::Drawing::Size(124, 22); this->pasteToolStripMenuItem->Text = L"Paste"; // // toolStripSeparator18 // this->toolStripSeparator18->Name = L"toolStripSeparator18"; this->toolStripSeparator18->Size = System::Drawing::Size(121, 6); // // mnuEditDelete // this->mnuEditDelete->Name = L"mnuEditDelete"; this->mnuEditDelete->Size = System::Drawing::Size(124, 22); this->mnuEditDelete->Text = L"Delete"; this->mnuEditDelete->Click += gcnew System::EventHandler(this, &frmMain::mnuEditDelete_Click); // // toolStripSeparator20 // this->toolStripSeparator20->Name = L"toolStripSeparator20"; this->toolStripSeparator20->Size = System::Drawing::Size(121, 6); // // lockAxesToolStripMenuItem // this->lockAxesToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->xAxisToolStripMenuItem, this->yAxisToolStripMenuItem, this->zAxisToolStripMenuItem}); this->lockAxesToolStripMenuItem->Name = L"lockAxesToolStripMenuItem"; this->lockAxesToolStripMenuItem->Size = System::Drawing::Size(124, 22); this->lockAxesToolStripMenuItem->Text = L"Lock axes"; // // xAxisToolStripMenuItem // this->xAxisToolStripMenuItem->Checked = true; this->xAxisToolStripMenuItem->CheckOnClick = true; this->xAxisToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked; this->xAxisToolStripMenuItem->Name = L"xAxisToolStripMenuItem"; this->xAxisToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>(((System::Windows::Forms::Keys::Alt | System::Windows::Forms::Keys::Shift) | System::Windows::Forms::Keys::X)); this->xAxisToolStripMenuItem->Size = System::Drawing::Size(172, 22); this->xAxisToolStripMenuItem->Text = L"X axis"; this->xAxisToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::xAxisToolStripMenuItem_Click); // // yAxisToolStripMenuItem // this->yAxisToolStripMenuItem->Checked = true; this->yAxisToolStripMenuItem->CheckOnClick = true; this->yAxisToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked; this->yAxisToolStripMenuItem->Name = L"yAxisToolStripMenuItem"; this->yAxisToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>(((System::Windows::Forms::Keys::Alt | System::Windows::Forms::Keys::Shift) | System::Windows::Forms::Keys::Y)); this->yAxisToolStripMenuItem->Size = System::Drawing::Size(172, 22); this->yAxisToolStripMenuItem->Text = L"Y axis"; this->yAxisToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::yAxisToolStripMenuItem_Click); // // zAxisToolStripMenuItem // this->zAxisToolStripMenuItem->Checked = true; this->zAxisToolStripMenuItem->CheckOnClick = true; this->zAxisToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked; this->zAxisToolStripMenuItem->Name = L"zAxisToolStripMenuItem"; this->zAxisToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>(((System::Windows::Forms::Keys::Alt | System::Windows::Forms::Keys::Shift) | System::Windows::Forms::Keys::Z)); this->zAxisToolStripMenuItem->Size = System::Drawing::Size(172, 22); this->zAxisToolStripMenuItem->Text = L"Z axis"; this->zAxisToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::zAxisToolStripMenuItem_Click); // // insertToolStripMenuItem // this->insertToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(9) {this->lightToolStripMenuItem, this->mnuInsertMesh, this->particleSystemToolStripMenuItem, this->prefabToolStripMenuItem, this->cameraToolStripMenuItem, this->outdoorToolStripMenuItem, this->otherToolStripMenuItem, this->physicsToolStripMenuItem, this->mnuInsertSound}); this->insertToolStripMenuItem->Name = L"insertToolStripMenuItem"; this->insertToolStripMenuItem->Size = System::Drawing::Size(48, 20); this->insertToolStripMenuItem->Text = L"Insert"; this->insertToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::insertToolStripMenuItem_Click); // // lightToolStripMenuItem // this->lightToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->mnuInsertLightDirectional, this->mnuInsertLightOmni, this->mnuInsertLightSpot, this->mnuInsertLightVolumetric}); this->lightToolStripMenuItem->Name = L"lightToolStripMenuItem"; this->lightToolStripMenuItem->Size = System::Drawing::Size(154, 22); this->lightToolStripMenuItem->Text = L"Light"; // // mnuInsertLightDirectional // this->mnuInsertLightDirectional->Name = L"mnuInsertLightDirectional"; this->mnuInsertLightDirectional->Size = System::Drawing::Size(132, 22); this->mnuInsertLightDirectional->Text = L"Directional"; this->mnuInsertLightDirectional->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertLightDirectional_Click); // // mnuInsertLightOmni // this->mnuInsertLightOmni->Name = L"mnuInsertLightOmni"; this->mnuInsertLightOmni->Size = System::Drawing::Size(132, 22); this->mnuInsertLightOmni->Text = L"Omni"; this->mnuInsertLightOmni->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertLightOmni_Click); // // mnuInsertLightSpot // this->mnuInsertLightSpot->Name = L"mnuInsertLightSpot"; this->mnuInsertLightSpot->Size = System::Drawing::Size(132, 22); this->mnuInsertLightSpot->Text = L"Spot"; this->mnuInsertLightSpot->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertLightSpot_Click); // // mnuInsertLightVolumetric // this->mnuInsertLightVolumetric->Name = L"mnuInsertLightVolumetric"; this->mnuInsertLightVolumetric->Size = System::Drawing::Size(132, 22); this->mnuInsertLightVolumetric->Text = L"Volumetric"; this->mnuInsertLightVolumetric->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertLightVolumetric_Click); // // mnuInsertMesh // this->mnuInsertMesh->Name = L"mnuInsertMesh"; this->mnuInsertMesh->Size = System::Drawing::Size(154, 22); this->mnuInsertMesh->Text = L"Mesh"; this->mnuInsertMesh->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertMesh_Click); // // particleSystemToolStripMenuItem // this->particleSystemToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(5) {this->mnuInsertPSParticleSystem, this->mnuInsertPSParticleEmitter, this->mnuInsertPSParticleColour, this->mnuInsertPSParticleForce, this->mnuInsertPSParticleDeflector}); this->particleSystemToolStripMenuItem->Name = L"particleSystemToolStripMenuItem"; this->particleSystemToolStripMenuItem->Size = System::Drawing::Size(154, 22); this->particleSystemToolStripMenuItem->Text = L"Particle System"; // // mnuInsertPSParticleSystem // this->mnuInsertPSParticleSystem->Name = L"mnuInsertPSParticleSystem"; this->mnuInsertPSParticleSystem->Size = System::Drawing::Size(163, 22); this->mnuInsertPSParticleSystem->Text = L"Particle system"; this->mnuInsertPSParticleSystem->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPSParticleSystem_Click); // // mnuInsertPSParticleEmitter // this->mnuInsertPSParticleEmitter->Name = L"mnuInsertPSParticleEmitter"; this->mnuInsertPSParticleEmitter->Size = System::Drawing::Size(163, 22); this->mnuInsertPSParticleEmitter->Text = L"Particle emitter"; this->mnuInsertPSParticleEmitter->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPSParticleEmitter_Click); // // mnuInsertPSParticleColour // this->mnuInsertPSParticleColour->Name = L"mnuInsertPSParticleColour"; this->mnuInsertPSParticleColour->Size = System::Drawing::Size(163, 22); this->mnuInsertPSParticleColour->Text = L"Particle colour"; this->mnuInsertPSParticleColour->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPSParticleColour_Click); // // mnuInsertPSParticleForce // this->mnuInsertPSParticleForce->Name = L"mnuInsertPSParticleForce"; this->mnuInsertPSParticleForce->Size = System::Drawing::Size(163, 22); this->mnuInsertPSParticleForce->Text = L"Particle force"; this->mnuInsertPSParticleForce->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPSParticleForce_Click); // // mnuInsertPSParticleDeflector // this->mnuInsertPSParticleDeflector->Name = L"mnuInsertPSParticleDeflector"; this->mnuInsertPSParticleDeflector->Size = System::Drawing::Size(163, 22); this->mnuInsertPSParticleDeflector->Text = L"Particle deflector"; this->mnuInsertPSParticleDeflector->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPSParticleDeflector_Click); // // prefabToolStripMenuItem // this->prefabToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(8) {this->mnuInsertPrefabBox, this->mnuInsertPrefabSphere, this->mnuInsertPrefabCapsule, this->mnuInsertPrefabCylinder, this->mnuInsertPrefabPlane, this->mnuInsertPrefabPyramid, this->mnuInsertPrefabTeapot, this->mnuInsertPrefabTorus}); this->prefabToolStripMenuItem->Name = L"prefabToolStripMenuItem"; this->prefabToolStripMenuItem->Size = System::Drawing::Size(154, 22); this->prefabToolStripMenuItem->Text = L"Prefab"; // // mnuInsertPrefabBox // this->mnuInsertPrefabBox->Name = L"mnuInsertPrefabBox"; this->mnuInsertPrefabBox->Size = System::Drawing::Size(118, 22); this->mnuInsertPrefabBox->Text = L"Box"; this->mnuInsertPrefabBox->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPrefabBox_Click); // // mnuInsertPrefabSphere // this->mnuInsertPrefabSphere->Name = L"mnuInsertPrefabSphere"; this->mnuInsertPrefabSphere->Size = System::Drawing::Size(118, 22); this->mnuInsertPrefabSphere->Text = L"Sphere"; this->mnuInsertPrefabSphere->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPrefabSphere_Click); // // mnuInsertPrefabCapsule // this->mnuInsertPrefabCapsule->Name = L"mnuInsertPrefabCapsule"; this->mnuInsertPrefabCapsule->Size = System::Drawing::Size(118, 22); this->mnuInsertPrefabCapsule->Text = L"Capsule"; this->mnuInsertPrefabCapsule->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPrefabCapsule_Click); // // mnuInsertPrefabCylinder // this->mnuInsertPrefabCylinder->Name = L"mnuInsertPrefabCylinder"; this->mnuInsertPrefabCylinder->Size = System::Drawing::Size(118, 22); this->mnuInsertPrefabCylinder->Text = L"Cylinder"; this->mnuInsertPrefabCylinder->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPrefabCylinder_Click); // // mnuInsertPrefabPlane // this->mnuInsertPrefabPlane->Name = L"mnuInsertPrefabPlane"; this->mnuInsertPrefabPlane->Size = System::Drawing::Size(118, 22); this->mnuInsertPrefabPlane->Text = L"Plane"; this->mnuInsertPrefabPlane->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPrefabPlane_Click); // // mnuInsertPrefabPyramid // this->mnuInsertPrefabPyramid->Name = L"mnuInsertPrefabPyramid"; this->mnuInsertPrefabPyramid->Size = System::Drawing::Size(118, 22); this->mnuInsertPrefabPyramid->Text = L"Pyramid"; this->mnuInsertPrefabPyramid->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPrefabPyramid_Click); // // mnuInsertPrefabTeapot // this->mnuInsertPrefabTeapot->Name = L"mnuInsertPrefabTeapot"; this->mnuInsertPrefabTeapot->Size = System::Drawing::Size(118, 22); this->mnuInsertPrefabTeapot->Text = L"Teapot"; this->mnuInsertPrefabTeapot->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPrefabTeapot_Click); // // mnuInsertPrefabTorus // this->mnuInsertPrefabTorus->Name = L"mnuInsertPrefabTorus"; this->mnuInsertPrefabTorus->Size = System::Drawing::Size(118, 22); this->mnuInsertPrefabTorus->Text = L"Torus"; this->mnuInsertPrefabTorus->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPrefabTorus_Click); // // cameraToolStripMenuItem // this->cameraToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->mnuInsertCameraFPP}); this->cameraToolStripMenuItem->Name = L"cameraToolStripMenuItem"; this->cameraToolStripMenuItem->Size = System::Drawing::Size(154, 22); this->cameraToolStripMenuItem->Text = L"Camera"; // // mnuInsertCameraFPP // this->mnuInsertCameraFPP->Name = L"mnuInsertCameraFPP"; this->mnuInsertCameraFPP->Size = System::Drawing::Size(137, 22); this->mnuInsertCameraFPP->Text = L"First-person"; this->mnuInsertCameraFPP->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertCameraFPP_Click); // // outdoorToolStripMenuItem // this->outdoorToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(5) {this->mnuInsertOutdoorSky, this->mnuInsertOutdoorTerrain, this->mnuInsertOutdoorClouds, this->mnuInstertOutdoorWater, this->mnuInsertLightning}); this->outdoorToolStripMenuItem->Name = L"outdoorToolStripMenuItem"; this->outdoorToolStripMenuItem->Size = System::Drawing::Size(154, 22); this->outdoorToolStripMenuItem->Text = L"Outdoor"; this->outdoorToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::outdoorToolStripMenuItem_Click); // // mnuInsertOutdoorSky // this->mnuInsertOutdoorSky->Name = L"mnuInsertOutdoorSky"; this->mnuInsertOutdoorSky->Size = System::Drawing::Size(125, 22); this->mnuInsertOutdoorSky->Text = L"Sky"; this->mnuInsertOutdoorSky->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertOutdoorSky_Click); // // mnuInsertOutdoorTerrain // this->mnuInsertOutdoorTerrain->Name = L"mnuInsertOutdoorTerrain"; this->mnuInsertOutdoorTerrain->Size = System::Drawing::Size(125, 22); this->mnuInsertOutdoorTerrain->Text = L"Terrain"; this->mnuInsertOutdoorTerrain->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertOutdoorTerrain_Click); // // mnuInsertOutdoorClouds // this->mnuInsertOutdoorClouds->Name = L"mnuInsertOutdoorClouds"; this->mnuInsertOutdoorClouds->Size = System::Drawing::Size(125, 22); this->mnuInsertOutdoorClouds->Text = L"Clouds"; this->mnuInsertOutdoorClouds->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertOutdoorClouds_Click); // // mnuInstertOutdoorWater // this->mnuInstertOutdoorWater->Name = L"mnuInstertOutdoorWater"; this->mnuInstertOutdoorWater->Size = System::Drawing::Size(125, 22); this->mnuInstertOutdoorWater->Text = L"Water"; this->mnuInstertOutdoorWater->Click += gcnew System::EventHandler(this, &frmMain::mnuInstertOutdoorWater_Click); // // mnuInsertLightning // this->mnuInsertLightning->Name = L"mnuInsertLightning"; this->mnuInsertLightning->Size = System::Drawing::Size(125, 22); this->mnuInsertLightning->Text = L"Lightning"; this->mnuInsertLightning->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertLightning_Click); // // otherToolStripMenuItem // this->otherToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->mnuInsertOtherFur}); this->otherToolStripMenuItem->Name = L"otherToolStripMenuItem"; this->otherToolStripMenuItem->Size = System::Drawing::Size(154, 22); this->otherToolStripMenuItem->Text = L"Other"; // // mnuInsertOtherFur // this->mnuInsertOtherFur->Name = L"mnuInsertOtherFur"; this->mnuInsertOtherFur->Size = System::Drawing::Size(91, 22); this->mnuInsertOtherFur->Text = L"Fur"; this->mnuInsertOtherFur->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertOtherFur_Click); // // physicsToolStripMenuItem // this->physicsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(4) {this->rigidBodyToolStripMenuItem, this->softBodyToolStripMenuItem, this->clothToolStripMenuItem, this->controllerToolStripMenuItem}); this->physicsToolStripMenuItem->Name = L"physicsToolStripMenuItem"; this->physicsToolStripMenuItem->Size = System::Drawing::Size(154, 22); this->physicsToolStripMenuItem->Text = L"Physics"; // // rigidBodyToolStripMenuItem // this->rigidBodyToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(9) {this->mnuInsertPhysicsRigidActor, this->toolStripSeparator28, this->mnuInsertPhysicsRigidBox, this->boxToolStripMenuItem, this->capsuleToolStripMenuItem, this->planeToolStripMenuItem1, this->toolStripSeparator29, this->meshToolStripMenuItem, this->terrainToolStripMenuItem}); this->rigidBodyToolStripMenuItem->Name = L"rigidBodyToolStripMenuItem"; this->rigidBodyToolStripMenuItem->Size = System::Drawing::Size(181, 22); this->rigidBodyToolStripMenuItem->Text = L"Rigid Body"; // // mnuInsertPhysicsRigidActor // this->mnuInsertPhysicsRigidActor->Name = L"mnuInsertPhysicsRigidActor"; this->mnuInsertPhysicsRigidActor->Size = System::Drawing::Size(116, 22); this->mnuInsertPhysicsRigidActor->Text = L"Actor"; // // toolStripSeparator28 // this->toolStripSeparator28->Name = L"toolStripSeparator28"; this->toolStripSeparator28->Size = System::Drawing::Size(113, 6); // // mnuInsertPhysicsRigidBox // this->mnuInsertPhysicsRigidBox->Name = L"mnuInsertPhysicsRigidBox"; this->mnuInsertPhysicsRigidBox->Size = System::Drawing::Size(116, 22); this->mnuInsertPhysicsRigidBox->Text = L"Box"; this->mnuInsertPhysicsRigidBox->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertPhysicsRigidBox_Click); // // boxToolStripMenuItem // this->boxToolStripMenuItem->Name = L"boxToolStripMenuItem"; this->boxToolStripMenuItem->Size = System::Drawing::Size(116, 22); this->boxToolStripMenuItem->Text = L"Sphere"; // // capsuleToolStripMenuItem // this->capsuleToolStripMenuItem->Name = L"capsuleToolStripMenuItem"; this->capsuleToolStripMenuItem->Size = System::Drawing::Size(116, 22); this->capsuleToolStripMenuItem->Text = L"Capsule"; // // planeToolStripMenuItem1 // this->planeToolStripMenuItem1->Name = L"planeToolStripMenuItem1"; this->planeToolStripMenuItem1->Size = System::Drawing::Size(116, 22); this->planeToolStripMenuItem1->Text = L"Plane"; this->planeToolStripMenuItem1->Click += gcnew System::EventHandler(this, &frmMain::planeToolStripMenuItem1_Click); // // toolStripSeparator29 // this->toolStripSeparator29->Name = L"toolStripSeparator29"; this->toolStripSeparator29->Size = System::Drawing::Size(113, 6); // // meshToolStripMenuItem // this->meshToolStripMenuItem->Name = L"meshToolStripMenuItem"; this->meshToolStripMenuItem->Size = System::Drawing::Size(116, 22); this->meshToolStripMenuItem->Text = L"Mesh"; // // terrainToolStripMenuItem // this->terrainToolStripMenuItem->Name = L"terrainToolStripMenuItem"; this->terrainToolStripMenuItem->Size = System::Drawing::Size(116, 22); this->terrainToolStripMenuItem->Text = L"Terrain"; // // softBodyToolStripMenuItem // this->softBodyToolStripMenuItem->Name = L"softBodyToolStripMenuItem"; this->softBodyToolStripMenuItem->Size = System::Drawing::Size(181, 22); this->softBodyToolStripMenuItem->Text = L"Soft Body"; // // clothToolStripMenuItem // this->clothToolStripMenuItem->Name = L"clothToolStripMenuItem"; this->clothToolStripMenuItem->Size = System::Drawing::Size(181, 22); this->clothToolStripMenuItem->Text = L"Cloth"; // // controllerToolStripMenuItem // this->controllerToolStripMenuItem->Name = L"controllerToolStripMenuItem"; this->controllerToolStripMenuItem->Size = System::Drawing::Size(181, 22); this->controllerToolStripMenuItem->Text = L"Character Controller"; // // mnuInsertSound // this->mnuInsertSound->Name = L"mnuInsertSound"; this->mnuInsertSound->Size = System::Drawing::Size(154, 22); this->mnuInsertSound->Text = L"Sound"; this->mnuInsertSound->Click += gcnew System::EventHandler(this, &frmMain::mnuInsertSound_Click); // // viewToolStripMenuItem // this->viewToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(13) {this->mnuViewMaterialLibrary, this->mnuViewOutput, this->mnuErrorList, this->mnuViewPropertyManager, this->mnuViewSolutionExplorer, this->mnuViewToolbox, this->mnuFXs, this->toolStripSeparator1, this->toolbarsToolStripMenuItem, this->modeToolStripMenuItem, this->fullToolStripMenuItem, this->toolStripSeparator7, this->propertiesToolStripMenuItem}); this->viewToolStripMenuItem->Name = L"viewToolStripMenuItem"; this->viewToolStripMenuItem->Size = System::Drawing::Size(44, 20); this->viewToolStripMenuItem->Text = L"View"; // // mnuViewMaterialLibrary // this->mnuViewMaterialLibrary->Name = L"mnuViewMaterialLibrary"; this->mnuViewMaterialLibrary->Size = System::Drawing::Size(168, 22); this->mnuViewMaterialLibrary->Text = L"Material Library"; this->mnuViewMaterialLibrary->Click += gcnew System::EventHandler(this, &frmMain::mnuViewMaterialLibrary_Click); // // mnuViewOutput // this->mnuViewOutput->Name = L"mnuViewOutput"; this->mnuViewOutput->Size = System::Drawing::Size(168, 22); this->mnuViewOutput->Text = L"Output"; this->mnuViewOutput->Click += gcnew System::EventHandler(this, &frmMain::mnuViewOutput_Click); // // mnuErrorList // this->mnuErrorList->Name = L"mnuErrorList"; this->mnuErrorList->Size = System::Drawing::Size(168, 22); this->mnuErrorList->Text = L"Error List"; this->mnuErrorList->Click += gcnew System::EventHandler(this, &frmMain::mnuErrorList_Click); // // mnuViewPropertyManager // this->mnuViewPropertyManager->Name = L"mnuViewPropertyManager"; this->mnuViewPropertyManager->Size = System::Drawing::Size(168, 22); this->mnuViewPropertyManager->Text = L"Properties"; this->mnuViewPropertyManager->Click += gcnew System::EventHandler(this, &frmMain::mnuPropertyManager_Click); // // mnuViewSolutionExplorer // this->mnuViewSolutionExplorer->Name = L"mnuViewSolutionExplorer"; this->mnuViewSolutionExplorer->Size = System::Drawing::Size(168, 22); this->mnuViewSolutionExplorer->Text = L"Solution Explorer"; this->mnuViewSolutionExplorer->Click += gcnew System::EventHandler(this, &frmMain::mnuViewSolutionExplorer_Click); // // mnuViewToolbox // this->mnuViewToolbox->Name = L"mnuViewToolbox"; this->mnuViewToolbox->Size = System::Drawing::Size(168, 22); this->mnuViewToolbox->Text = L"Toolbox"; this->mnuViewToolbox->Click += gcnew System::EventHandler(this, &frmMain::mnuViewToolbox_Click); // // mnuFXs // this->mnuFXs->Name = L"mnuFXs"; this->mnuFXs->Size = System::Drawing::Size(168, 22); this->mnuFXs->Text = L"Scene Effects"; this->mnuFXs->Click += gcnew System::EventHandler(this, &frmMain::mnuFXs_Click); // // toolStripSeparator1 // this->toolStripSeparator1->Name = L"toolStripSeparator1"; this->toolStripSeparator1->Size = System::Drawing::Size(165, 6); // // toolbarsToolStripMenuItem // this->toolbarsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->standardToolStripMenuItem}); this->toolbarsToolStripMenuItem->Name = L"toolbarsToolStripMenuItem"; this->toolbarsToolStripMenuItem->Size = System::Drawing::Size(168, 22); this->toolbarsToolStripMenuItem->Text = L"Toolbars"; // // standardToolStripMenuItem // this->standardToolStripMenuItem->Checked = true; this->standardToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked; this->standardToolStripMenuItem->Name = L"standardToolStripMenuItem"; this->standardToolStripMenuItem->Size = System::Drawing::Size(121, 22); this->standardToolStripMenuItem->Text = L"Standard"; // // modeToolStripMenuItem // this->modeToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(8) {this->solidToolStripMenuItem, this->texturedToolStripMenuItem, this->mnuWireframe, this->mnuLighting, this->mnuViewModeHDR, this->mnuViewModeShadows, this->mnuViewModeReflections, this->mnuViewModeDebugInfo}); this->modeToolStripMenuItem->Name = L"modeToolStripMenuItem"; this->modeToolStripMenuItem->Size = System::Drawing::Size(168, 22); this->modeToolStripMenuItem->Text = L"Mode"; // // solidToolStripMenuItem // this->solidToolStripMenuItem->Checked = true; this->solidToolStripMenuItem->CheckOnClick = true; this->solidToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked; this->solidToolStripMenuItem->Name = L"solidToolStripMenuItem"; this->solidToolStripMenuItem->Size = System::Drawing::Size(162, 22); this->solidToolStripMenuItem->Text = L"Solid"; // // texturedToolStripMenuItem // this->texturedToolStripMenuItem->Checked = true; this->texturedToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked; this->texturedToolStripMenuItem->Name = L"texturedToolStripMenuItem"; this->texturedToolStripMenuItem->Size = System::Drawing::Size(162, 22); this->texturedToolStripMenuItem->Text = L"Textured"; this->texturedToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::texturedToolStripMenuItem_Click); // // mnuWireframe // this->mnuWireframe->CheckOnClick = true; this->mnuWireframe->Name = L"mnuWireframe"; this->mnuWireframe->Size = System::Drawing::Size(162, 22); this->mnuWireframe->Text = L"Wire-frame"; this->mnuWireframe->Click += gcnew System::EventHandler(this, &frmMain::mnuWireframe_Click); // // mnuLighting // this->mnuLighting->Checked = true; this->mnuLighting->CheckOnClick = true; this->mnuLighting->CheckState = System::Windows::Forms::CheckState::Checked; this->mnuLighting->Name = L"mnuLighting"; this->mnuLighting->Size = System::Drawing::Size(162, 22); this->mnuLighting->Text = L"Lighting"; this->mnuLighting->Click += gcnew System::EventHandler(this, &frmMain::mnuLighting_Click); // // mnuViewModeHDR // this->mnuViewModeHDR->CheckOnClick = true; this->mnuViewModeHDR->Name = L"mnuViewModeHDR"; this->mnuViewModeHDR->Size = System::Drawing::Size(162, 22); this->mnuViewModeHDR->Text = L"HDR"; this->mnuViewModeHDR->Click += gcnew System::EventHandler(this, &frmMain::mnuViewModeHDR_Click); // // mnuViewModeShadows // this->mnuViewModeShadows->Checked = true; this->mnuViewModeShadows->CheckOnClick = true; this->mnuViewModeShadows->CheckState = System::Windows::Forms::CheckState::Checked; this->mnuViewModeShadows->Name = L"mnuViewModeShadows"; this->mnuViewModeShadows->Size = System::Drawing::Size(162, 22); this->mnuViewModeShadows->Text = L"Shadows"; this->mnuViewModeShadows->Click += gcnew System::EventHandler(this, &frmMain::mnuViewModeShadows_Click); // // mnuViewModeReflections // this->mnuViewModeReflections->Checked = true; this->mnuViewModeReflections->CheckOnClick = true; this->mnuViewModeReflections->CheckState = System::Windows::Forms::CheckState::Checked; this->mnuViewModeReflections->Name = L"mnuViewModeReflections"; this->mnuViewModeReflections->Size = System::Drawing::Size(162, 22); this->mnuViewModeReflections->Text = L"Reflections"; this->mnuViewModeReflections->Click += gcnew System::EventHandler(this, &frmMain::mnuViewModeReflections_Click); // // mnuViewModeDebugInfo // this->mnuViewModeDebugInfo->Checked = true; this->mnuViewModeDebugInfo->CheckOnClick = true; this->mnuViewModeDebugInfo->CheckState = System::Windows::Forms::CheckState::Checked; this->mnuViewModeDebugInfo->Name = L"mnuViewModeDebugInfo"; this->mnuViewModeDebugInfo->Size = System::Drawing::Size(162, 22); this->mnuViewModeDebugInfo->Text = L"Draw debug info"; this->mnuViewModeDebugInfo->Click += gcnew System::EventHandler(this, &frmMain::mnuViewModeDebugInfo_Click); // // fullToolStripMenuItem // this->fullToolStripMenuItem->CheckOnClick = true; this->fullToolStripMenuItem->Name = L"fullToolStripMenuItem"; this->fullToolStripMenuItem->ShortcutKeys = static_cast<System::Windows::Forms::Keys>((System::Windows::Forms::Keys::Alt | System::Windows::Forms::Keys::X)); this->fullToolStripMenuItem->Size = System::Drawing::Size(168, 22); this->fullToolStripMenuItem->Text = L"Full Screen"; this->fullToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::fullToolStripMenuItem_Click); // // toolStripSeparator7 // this->toolStripSeparator7->Name = L"toolStripSeparator7"; this->toolStripSeparator7->Size = System::Drawing::Size(165, 6); // // propertiesToolStripMenuItem // this->propertiesToolStripMenuItem->Name = L"propertiesToolStripMenuItem"; this->propertiesToolStripMenuItem->Size = System::Drawing::Size(168, 22); this->propertiesToolStripMenuItem->Text = L"Properties"; // // toolsToolStripMenuItem // this->toolsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(6) {this->materialLibraryToolStripMenuItem, this->toolStripSeparator6, this->scenegraphEditorToolStripMenuItem, this->toolStripSeparator14, this->customizeToolStripMenuItem, this->mnuToolsOptions}); this->toolsToolStripMenuItem->Name = L"toolsToolStripMenuItem"; this->toolsToolStripMenuItem->Size = System::Drawing::Size(48, 20); this->toolsToolStripMenuItem->Text = L"Tools"; // // materialLibraryToolStripMenuItem // this->materialLibraryToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(10) {this->mnuContentAuthoringShaderEditor, this->mnuMaterialEditor, this->materialLibraryToolStripMenuItem1, this->toolStripSeparator11, this->animationEditorToolStripMenuItem, this->textureEditorToolStripMenuItem, this->toolStripSeparator15, this->mnuScriptEditor, this->toolStripSeparator27, this->mnuHeightMapEditor}); this->materialLibraryToolStripMenuItem->Name = L"materialLibraryToolStripMenuItem"; this->materialLibraryToolStripMenuItem->Size = System::Drawing::Size(175, 22); this->materialLibraryToolStripMenuItem->Text = L"Content Authoring"; // // mnuContentAuthoringShaderEditor // this->mnuContentAuthoringShaderEditor->Name = L"mnuContentAuthoringShaderEditor"; this->mnuContentAuthoringShaderEditor->Size = System::Drawing::Size(173, 22); this->mnuContentAuthoringShaderEditor->Text = L"Shader Editor"; this->mnuContentAuthoringShaderEditor->Click += gcnew System::EventHandler(this, &frmMain::mnuContentAuthoringShaderEditor_Click); // // mnuMaterialEditor // this->mnuMaterialEditor->Name = L"mnuMaterialEditor"; this->mnuMaterialEditor->Size = System::Drawing::Size(173, 22); this->mnuMaterialEditor->Text = L"Material Editor"; this->mnuMaterialEditor->Click += gcnew System::EventHandler(this, &frmMain::mnuMaterialEditor_Click); // // materialLibraryToolStripMenuItem1 // this->materialLibraryToolStripMenuItem1->Name = L"materialLibraryToolStripMenuItem1"; this->materialLibraryToolStripMenuItem1->Size = System::Drawing::Size(173, 22); this->materialLibraryToolStripMenuItem1->Text = L"Material Library"; // // toolStripSeparator11 // this->toolStripSeparator11->Name = L"toolStripSeparator11"; this->toolStripSeparator11->Size = System::Drawing::Size(170, 6); // // animationEditorToolStripMenuItem // this->animationEditorToolStripMenuItem->Name = L"animationEditorToolStripMenuItem"; this->animationEditorToolStripMenuItem->Size = System::Drawing::Size(173, 22); this->animationEditorToolStripMenuItem->Text = L"Animation Editor"; // // textureEditorToolStripMenuItem // this->textureEditorToolStripMenuItem->Name = L"textureEditorToolStripMenuItem"; this->textureEditorToolStripMenuItem->Size = System::Drawing::Size(173, 22); this->textureEditorToolStripMenuItem->Text = L"Texture Editor"; // // toolStripSeparator15 // this->toolStripSeparator15->Name = L"toolStripSeparator15"; this->toolStripSeparator15->Size = System::Drawing::Size(170, 6); // // mnuScriptEditor // this->mnuScriptEditor->Name = L"mnuScriptEditor"; this->mnuScriptEditor->Size = System::Drawing::Size(173, 22); this->mnuScriptEditor->Text = L"Script Editor"; this->mnuScriptEditor->Click += gcnew System::EventHandler(this, &frmMain::mnuScriptEditor_Click); // // toolStripSeparator27 // this->toolStripSeparator27->Name = L"toolStripSeparator27"; this->toolStripSeparator27->Size = System::Drawing::Size(170, 6); // // mnuHeightMapEditor // this->mnuHeightMapEditor->Name = L"mnuHeightMapEditor"; this->mnuHeightMapEditor->Size = System::Drawing::Size(173, 22); this->mnuHeightMapEditor->Text = L"Height-map Editor"; this->mnuHeightMapEditor->Click += gcnew System::EventHandler(this, &frmMain::mnuHeightMapEditor_Click); // // toolStripSeparator6 // this->toolStripSeparator6->Name = L"toolStripSeparator6"; this->toolStripSeparator6->Size = System::Drawing::Size(172, 6); // // scenegraphEditorToolStripMenuItem // this->scenegraphEditorToolStripMenuItem->Name = L"scenegraphEditorToolStripMenuItem"; this->scenegraphEditorToolStripMenuItem->Size = System::Drawing::Size(175, 22); this->scenegraphEditorToolStripMenuItem->Text = L"Scene-graph Editor"; // // toolStripSeparator14 // this->toolStripSeparator14->Name = L"toolStripSeparator14"; this->toolStripSeparator14->Size = System::Drawing::Size(172, 6); // // customizeToolStripMenuItem // this->customizeToolStripMenuItem->Name = L"customizeToolStripMenuItem"; this->customizeToolStripMenuItem->Size = System::Drawing::Size(175, 22); this->customizeToolStripMenuItem->Text = L"Customize..."; // // mnuToolsOptions // this->mnuToolsOptions->Name = L"mnuToolsOptions"; this->mnuToolsOptions->Size = System::Drawing::Size(175, 22); this->mnuToolsOptions->Text = L"Options..."; this->mnuToolsOptions->Click += gcnew System::EventHandler(this, &frmMain::mnuToolsOptions_Click); // // simulationToolStripMenuItem // this->simulationToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->pausedToolStripMenuItem, this->modesToolStripMenuItem, this->renderingToolStripMenuItem}); this->simulationToolStripMenuItem->Name = L"simulationToolStripMenuItem"; this->simulationToolStripMenuItem->Size = System::Drawing::Size(76, 20); this->simulationToolStripMenuItem->Text = L"Simulation"; // // pausedToolStripMenuItem // this->pausedToolStripMenuItem->Checked = true; this->pausedToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked; this->pausedToolStripMenuItem->Name = L"pausedToolStripMenuItem"; this->pausedToolStripMenuItem->Size = System::Drawing::Size(152, 22); this->pausedToolStripMenuItem->Text = L"Paused"; // // modesToolStripMenuItem // this->modesToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(3) {this->aIToolStripMenuItem, this->mnuSimulationModesPhysics, this->gameplayToolStripMenuItem}); this->modesToolStripMenuItem->Name = L"modesToolStripMenuItem"; this->modesToolStripMenuItem->Size = System::Drawing::Size(152, 22); this->modesToolStripMenuItem->Text = L"Modes"; // // aIToolStripMenuItem // this->aIToolStripMenuItem->Checked = true; this->aIToolStripMenuItem->CheckOnClick = true; this->aIToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked; this->aIToolStripMenuItem->Name = L"aIToolStripMenuItem"; this->aIToolStripMenuItem->Size = System::Drawing::Size(152, 22); this->aIToolStripMenuItem->Text = L"AI"; // // mnuSimulationModesPhysics // this->mnuSimulationModesPhysics->Checked = true; this->mnuSimulationModesPhysics->CheckOnClick = true; this->mnuSimulationModesPhysics->CheckState = System::Windows::Forms::CheckState::Checked; this->mnuSimulationModesPhysics->Name = L"mnuSimulationModesPhysics"; this->mnuSimulationModesPhysics->Size = System::Drawing::Size(152, 22); this->mnuSimulationModesPhysics->Text = L"Physics"; this->mnuSimulationModesPhysics->Click += gcnew System::EventHandler(this, &frmMain::mnuSimulationModesPhysics_Click); // // gameplayToolStripMenuItem // this->gameplayToolStripMenuItem->Checked = true; this->gameplayToolStripMenuItem->CheckOnClick = true; this->gameplayToolStripMenuItem->CheckState = System::Windows::Forms::CheckState::Checked; this->gameplayToolStripMenuItem->Name = L"gameplayToolStripMenuItem"; this->gameplayToolStripMenuItem->Size = System::Drawing::Size(152, 22); this->gameplayToolStripMenuItem->Text = L"Gameplay"; // // windowToolStripMenuItem // this->windowToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(1) {this->mnuWindowSaveLayout}); this->windowToolStripMenuItem->Name = L"windowToolStripMenuItem"; this->windowToolStripMenuItem->Size = System::Drawing::Size(63, 20); this->windowToolStripMenuItem->Text = L"Window"; // // mnuWindowSaveLayout // this->mnuWindowSaveLayout->Name = L"mnuWindowSaveLayout"; this->mnuWindowSaveLayout->Size = System::Drawing::Size(134, 22); this->mnuWindowSaveLayout->Text = L"Save layout"; this->mnuWindowSaveLayout->Click += gcnew System::EventHandler(this, &frmMain::mnuWindowSaveLayout_Click); // // helpToolStripMenuItem // this->helpToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(9) {this->searchToolStripMenuItem, this->contentsToolStripMenuItem, this->indexToolStripMenuItem, this->toolStripSeparator3, this->mnuNGENEOnTheWeb, this->mnuHelpTutorials, this->technicalSupportToolStripMenuItem, this->toolStripSeparator4, this->mnuAbout}); this->helpToolStripMenuItem->Name = L"helpToolStripMenuItem"; this->helpToolStripMenuItem->Size = System::Drawing::Size(44, 20); this->helpToolStripMenuItem->Text = L"Help"; this->helpToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmMain::helpToolStripMenuItem_Click); // // searchToolStripMenuItem // this->searchToolStripMenuItem->Name = L"searchToolStripMenuItem"; this->searchToolStripMenuItem->Size = System::Drawing::Size(174, 22); this->searchToolStripMenuItem->Text = L"Search"; // // contentsToolStripMenuItem // this->contentsToolStripMenuItem->Name = L"contentsToolStripMenuItem"; this->contentsToolStripMenuItem->Size = System::Drawing::Size(174, 22); this->contentsToolStripMenuItem->Text = L"Contents"; // // indexToolStripMenuItem // this->indexToolStripMenuItem->Name = L"indexToolStripMenuItem"; this->indexToolStripMenuItem->Size = System::Drawing::Size(174, 22); this->indexToolStripMenuItem->Text = L"Index"; // // toolStripSeparator3 // this->toolStripSeparator3->Name = L"toolStripSeparator3"; this->toolStripSeparator3->Size = System::Drawing::Size(171, 6); // // mnuNGENEOnTheWeb // this->mnuNGENEOnTheWeb->Name = L"mnuNGENEOnTheWeb"; this->mnuNGENEOnTheWeb->Size = System::Drawing::Size(174, 22); this->mnuNGENEOnTheWeb->Text = L"nGENE on the Web"; this->mnuNGENEOnTheWeb->Click += gcnew System::EventHandler(this, &frmMain::mnuNGENEOnTheWeb_Click); // // mnuHelpTutorials // this->mnuHelpTutorials->Name = L"mnuHelpTutorials"; this->mnuHelpTutorials->Size = System::Drawing::Size(174, 22); this->mnuHelpTutorials->Text = L"Tutorials"; this->mnuHelpTutorials->Click += gcnew System::EventHandler(this, &frmMain::mnuHelpTutorials_Click); // // technicalSupportToolStripMenuItem // this->technicalSupportToolStripMenuItem->Name = L"technicalSupportToolStripMenuItem"; this->technicalSupportToolStripMenuItem->Size = System::Drawing::Size(174, 22); this->technicalSupportToolStripMenuItem->Text = L"Technical Support"; // // toolStripSeparator4 // this->toolStripSeparator4->Name = L"toolStripSeparator4"; this->toolStripSeparator4->Size = System::Drawing::Size(171, 6); // // mnuAbout // this->mnuAbout->Name = L"mnuAbout"; this->mnuAbout->Size = System::Drawing::Size(174, 22); this->mnuAbout->Text = L"About"; this->mnuAbout->Click += gcnew System::EventHandler(this, &frmMain::mnuAbout_Click); // // toolStrip1 // this->toolStrip1->AllowItemReorder = true; this->toolStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(17) {this->tbsNewProject, this->tsbOpen, this->tsbSave, this->toolStripSeparator8, this->toolStripButton4, this->toolStripButton5, this->toolStripButton6, this->toolStripSeparator9, this->tbsRemoveNode, this->toolStripSeparator17, this->toolStripButton7, this->toolStripButton8, this->toolStripSeparator10, this->tsbLockX, this->tsbLockY, this->tsbLockZ, this->toolStripSeparator19}); this->toolStrip1->LayoutStyle = System::Windows::Forms::ToolStripLayoutStyle::HorizontalStackWithOverflow; this->toolStrip1->Location = System::Drawing::Point(0, 24); this->toolStrip1->Name = L"toolStrip1"; this->toolStrip1->Size = System::Drawing::Size(1158, 25); this->toolStrip1->TabIndex = 1; this->toolStrip1->Text = L"toolStrip1"; this->toolStrip1->ItemClicked += gcnew System::Windows::Forms::ToolStripItemClickedEventHandler(this, &frmMain::toolStrip1_ItemClicked); // // tbsNewProject // this->tbsNewProject->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsNewProject->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsNewProject.Image"))); this->tbsNewProject->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsNewProject->Name = L"tbsNewProject"; this->tbsNewProject->Size = System::Drawing::Size(23, 22); this->tbsNewProject->Text = L"Create new world"; this->tbsNewProject->Click += gcnew System::EventHandler(this, &frmMain::tbsNewProject_Click); // // tsbOpen // this->tsbOpen->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tsbOpen->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tsbOpen.Image"))); this->tsbOpen->ImageTransparentColor = System::Drawing::Color::Magenta; this->tsbOpen->Name = L"tsbOpen"; this->tsbOpen->Size = System::Drawing::Size(23, 22); this->tsbOpen->Text = L"toolStripButton2"; this->tsbOpen->ToolTipText = L"Open existing map file"; this->tsbOpen->Click += gcnew System::EventHandler(this, &frmMain::tsbOpen_Click); // // tsbSave // this->tsbSave->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tsbSave->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tsbSave.Image"))); this->tsbSave->ImageTransparentColor = System::Drawing::Color::Magenta; this->tsbSave->Name = L"tsbSave"; this->tsbSave->Size = System::Drawing::Size(23, 22); this->tsbSave->Text = L"toolStripButton3"; this->tsbSave->ToolTipText = L"Save world"; this->tsbSave->Click += gcnew System::EventHandler(this, &frmMain::tsbSave_Click); // // toolStripSeparator8 // this->toolStripSeparator8->Name = L"toolStripSeparator8"; this->toolStripSeparator8->Size = System::Drawing::Size(6, 25); // // toolStripButton4 // this->toolStripButton4->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->toolStripButton4->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton4.Image"))); this->toolStripButton4->ImageTransparentColor = System::Drawing::Color::Magenta; this->toolStripButton4->Name = L"toolStripButton4"; this->toolStripButton4->Size = System::Drawing::Size(23, 22); this->toolStripButton4->Text = L"toolStripButton4"; // // toolStripButton5 // this->toolStripButton5->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->toolStripButton5->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton5.Image"))); this->toolStripButton5->ImageTransparentColor = System::Drawing::Color::Magenta; this->toolStripButton5->Name = L"toolStripButton5"; this->toolStripButton5->Size = System::Drawing::Size(23, 22); this->toolStripButton5->Text = L"toolStripButton5"; // // toolStripButton6 // this->toolStripButton6->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->toolStripButton6->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton6.Image"))); this->toolStripButton6->ImageTransparentColor = System::Drawing::Color::Magenta; this->toolStripButton6->Name = L"toolStripButton6"; this->toolStripButton6->Size = System::Drawing::Size(23, 22); this->toolStripButton6->Text = L"toolStripButton6"; // // toolStripSeparator9 // this->toolStripSeparator9->Name = L"toolStripSeparator9"; this->toolStripSeparator9->Size = System::Drawing::Size(6, 25); // // tbsRemoveNode // this->tbsRemoveNode->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsRemoveNode->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsRemoveNode.Image"))); this->tbsRemoveNode->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsRemoveNode->Name = L"tbsRemoveNode"; this->tbsRemoveNode->Size = System::Drawing::Size(23, 22); this->tbsRemoveNode->Text = L"toolStripButton9"; this->tbsRemoveNode->ToolTipText = L"Delete selected node"; this->tbsRemoveNode->Click += gcnew System::EventHandler(this, &frmMain::tbsRemoveNode_Click); // // toolStripSeparator17 // this->toolStripSeparator17->Name = L"toolStripSeparator17"; this->toolStripSeparator17->Size = System::Drawing::Size(6, 25); // // toolStripButton7 // this->toolStripButton7->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->toolStripButton7->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton7.Image"))); this->toolStripButton7->ImageTransparentColor = System::Drawing::Color::Magenta; this->toolStripButton7->Name = L"toolStripButton7"; this->toolStripButton7->Size = System::Drawing::Size(23, 22); this->toolStripButton7->Text = L"toolStripButton7"; // // toolStripButton8 // this->toolStripButton8->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->toolStripButton8->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"toolStripButton8.Image"))); this->toolStripButton8->ImageTransparentColor = System::Drawing::Color::Magenta; this->toolStripButton8->Name = L"toolStripButton8"; this->toolStripButton8->Size = System::Drawing::Size(23, 22); this->toolStripButton8->Text = L"toolStripButton8"; // // toolStripSeparator10 // this->toolStripSeparator10->Name = L"toolStripSeparator10"; this->toolStripSeparator10->Size = System::Drawing::Size(6, 25); // // tsbLockX // this->tsbLockX->Checked = true; this->tsbLockX->CheckOnClick = true; this->tsbLockX->CheckState = System::Windows::Forms::CheckState::Checked; this->tsbLockX->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text; this->tsbLockX->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tsbLockX.Image"))); this->tsbLockX->ImageTransparentColor = System::Drawing::Color::Magenta; this->tsbLockX->Name = L"tsbLockX"; this->tsbLockX->Size = System::Drawing::Size(23, 22); this->tsbLockX->Text = L"X"; this->tsbLockX->ToolTipText = L"Lock x axis"; this->tsbLockX->Click += gcnew System::EventHandler(this, &frmMain::tsbLockX_Click); // // tsbLockY // this->tsbLockY->Checked = true; this->tsbLockY->CheckOnClick = true; this->tsbLockY->CheckState = System::Windows::Forms::CheckState::Checked; this->tsbLockY->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text; this->tsbLockY->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tsbLockY.Image"))); this->tsbLockY->ImageTransparentColor = System::Drawing::Color::Magenta; this->tsbLockY->Name = L"tsbLockY"; this->tsbLockY->Size = System::Drawing::Size(23, 22); this->tsbLockY->Text = L"Y"; this->tsbLockY->ToolTipText = L"Lock y axis"; this->tsbLockY->Click += gcnew System::EventHandler(this, &frmMain::tsbLockY_Click); // // tsbLockZ // this->tsbLockZ->Checked = true; this->tsbLockZ->CheckOnClick = true; this->tsbLockZ->CheckState = System::Windows::Forms::CheckState::Checked; this->tsbLockZ->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Text; this->tsbLockZ->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tsbLockZ.Image"))); this->tsbLockZ->ImageTransparentColor = System::Drawing::Color::Magenta; this->tsbLockZ->Name = L"tsbLockZ"; this->tsbLockZ->Size = System::Drawing::Size(23, 22); this->tsbLockZ->Text = L"Z"; this->tsbLockZ->ToolTipText = L"Lock z axis"; this->tsbLockZ->Click += gcnew System::EventHandler(this, &frmMain::tsbLockZ_Click); // // toolStripSeparator19 // this->toolStripSeparator19->Name = L"toolStripSeparator19"; this->toolStripSeparator19->Size = System::Drawing::Size(6, 25); // // stsStrip // this->stsStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->tssLabel, this->tssFPS}); this->stsStrip->Location = System::Drawing::Point(0, 530); this->stsStrip->Name = L"stsStrip"; this->stsStrip->Padding = System::Windows::Forms::Padding(1, 0, 10, 0); this->stsStrip->Size = System::Drawing::Size(1158, 22); this->stsStrip->TabIndex = 2; this->stsStrip->Text = L"statusStrip1"; // // tssLabel // this->tssLabel->Name = L"tssLabel"; this->tssLabel->Size = System::Drawing::Size(39, 17); this->tssLabel->Text = L"Ready"; // // tssFPS // this->tssFPS->Name = L"tssFPS"; this->tssFPS->Size = System::Drawing::Size(38, 17); this->tssFPS->Text = L"FPS: 0"; // // toolStrip2 // this->toolStrip2->AllowItemReorder = true; this->toolStrip2->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(20) {this->tbsLight, this->toolStripSeparator21, this->tbsBox, this->tbsSphere, this->tbsPlane, this->toolStripSeparator22, this->tbsCamera, this->toolStripSeparator23, this->tbsTerrain, this->tbsSky, this->tbsClouds, this->tbsWater, this->toolStripSeparator24, this->tbsParticleSystem, this->tbsParticleEmitter, this->toolStripSeparator25, this->tbsMesh, this->toolStripSeparator26, this->tbsSound, this->toolStripSeparator30}); this->toolStrip2->LayoutStyle = System::Windows::Forms::ToolStripLayoutStyle::HorizontalStackWithOverflow; this->toolStrip2->Location = System::Drawing::Point(0, 49); this->toolStrip2->Name = L"toolStrip2"; this->toolStrip2->Size = System::Drawing::Size(1158, 25); this->toolStrip2->TabIndex = 2; this->toolStrip2->Text = L"toolStrip2"; // // tbsLight // this->tbsLight->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsLight->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsLight.Image"))); this->tbsLight->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsLight->Name = L"tbsLight"; this->tbsLight->Size = System::Drawing::Size(23, 22); this->tbsLight->Text = L"toolStripButton1"; this->tbsLight->ToolTipText = L"Add new light object"; this->tbsLight->Click += gcnew System::EventHandler(this, &frmMain::tbsLight_Click); // // toolStripSeparator21 // this->toolStripSeparator21->Name = L"toolStripSeparator21"; this->toolStripSeparator21->Size = System::Drawing::Size(6, 25); // // tbsBox // this->tbsBox->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsBox->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsBox.Image"))); this->tbsBox->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsBox->Name = L"tbsBox"; this->tbsBox->Size = System::Drawing::Size(23, 22); this->tbsBox->Text = L"toolStripButton1"; this->tbsBox->ToolTipText = L"Add new box object"; this->tbsBox->Click += gcnew System::EventHandler(this, &frmMain::tbsBox_Click); // // tbsSphere // this->tbsSphere->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsSphere->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsSphere.Image"))); this->tbsSphere->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsSphere->Name = L"tbsSphere"; this->tbsSphere->Size = System::Drawing::Size(23, 22); this->tbsSphere->Text = L"toolStripButton1"; this->tbsSphere->ToolTipText = L"Add new sphere object"; this->tbsSphere->Click += gcnew System::EventHandler(this, &frmMain::tbsSphere_Click); // // tbsPlane // this->tbsPlane->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsPlane->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsPlane.Image"))); this->tbsPlane->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsPlane->Name = L"tbsPlane"; this->tbsPlane->Size = System::Drawing::Size(23, 22); this->tbsPlane->Text = L"toolStripButton1"; this->tbsPlane->ToolTipText = L"Add new plane object"; this->tbsPlane->Click += gcnew System::EventHandler(this, &frmMain::tbsPlane_Click); // // toolStripSeparator22 // this->toolStripSeparator22->Name = L"toolStripSeparator22"; this->toolStripSeparator22->Size = System::Drawing::Size(6, 25); // // tbsCamera // this->tbsCamera->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsCamera->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsCamera.Image"))); this->tbsCamera->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsCamera->Name = L"tbsCamera"; this->tbsCamera->Size = System::Drawing::Size(23, 22); this->tbsCamera->Text = L"toolStripButton1"; this->tbsCamera->ToolTipText = L"Add new camera object"; this->tbsCamera->Click += gcnew System::EventHandler(this, &frmMain::tbsCamera_Click); // // toolStripSeparator23 // this->toolStripSeparator23->Name = L"toolStripSeparator23"; this->toolStripSeparator23->Size = System::Drawing::Size(6, 25); // // tbsTerrain // this->tbsTerrain->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsTerrain->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsTerrain.Image"))); this->tbsTerrain->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsTerrain->Name = L"tbsTerrain"; this->tbsTerrain->Size = System::Drawing::Size(23, 22); this->tbsTerrain->Text = L"toolStripButton1"; this->tbsTerrain->ToolTipText = L"Add new terrain object"; this->tbsTerrain->Click += gcnew System::EventHandler(this, &frmMain::tbsTerrain_Click); // // tbsSky // this->tbsSky->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsSky->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsSky.Image"))); this->tbsSky->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsSky->Name = L"tbsSky"; this->tbsSky->Size = System::Drawing::Size(23, 22); this->tbsSky->Text = L"toolStripButton1"; this->tbsSky->ToolTipText = L"Add new sky object"; this->tbsSky->Click += gcnew System::EventHandler(this, &frmMain::tbsSky_Click); // // tbsClouds // this->tbsClouds->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsClouds->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsClouds.Image"))); this->tbsClouds->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsClouds->Name = L"tbsClouds"; this->tbsClouds->Size = System::Drawing::Size(23, 22); this->tbsClouds->Text = L"toolStripButton2"; this->tbsClouds->ToolTipText = L"Add new clouds object"; this->tbsClouds->Click += gcnew System::EventHandler(this, &frmMain::tbsClouds_Click); // // tbsWater // this->tbsWater->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsWater->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsWater.Image"))); this->tbsWater->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsWater->Name = L"tbsWater"; this->tbsWater->Size = System::Drawing::Size(23, 22); this->tbsWater->Text = L"toolStripButton1"; this->tbsWater->ToolTipText = L"Add new water object"; this->tbsWater->Click += gcnew System::EventHandler(this, &frmMain::tbsWater_Click); // // toolStripSeparator24 // this->toolStripSeparator24->Name = L"toolStripSeparator24"; this->toolStripSeparator24->Size = System::Drawing::Size(6, 25); // // tbsParticleSystem // this->tbsParticleSystem->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsParticleSystem->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsParticleSystem.Image"))); this->tbsParticleSystem->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsParticleSystem->Name = L"tbsParticleSystem"; this->tbsParticleSystem->Size = System::Drawing::Size(23, 22); this->tbsParticleSystem->Text = L"toolStripButton1"; this->tbsParticleSystem->ToolTipText = L"Add new particle system"; this->tbsParticleSystem->Click += gcnew System::EventHandler(this, &frmMain::tbsParticleSystem_Click); // // tbsParticleEmitter // this->tbsParticleEmitter->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsParticleEmitter->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsParticleEmitter.Image"))); this->tbsParticleEmitter->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsParticleEmitter->Name = L"tbsParticleEmitter"; this->tbsParticleEmitter->Size = System::Drawing::Size(23, 22); this->tbsParticleEmitter->Text = L"toolStripButton2"; this->tbsParticleEmitter->ToolTipText = L"Add new particle emitter object"; this->tbsParticleEmitter->Click += gcnew System::EventHandler(this, &frmMain::tbsParticleEmitter_Click); // // toolStripSeparator25 // this->toolStripSeparator25->Name = L"toolStripSeparator25"; this->toolStripSeparator25->Size = System::Drawing::Size(6, 25); // // tbsMesh // this->tbsMesh->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsMesh->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsMesh.Image"))); this->tbsMesh->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsMesh->Name = L"tbsMesh"; this->tbsMesh->Size = System::Drawing::Size(23, 22); this->tbsMesh->Text = L"toolStripButton1"; this->tbsMesh->ToolTipText = L"Add new mesh object"; this->tbsMesh->Click += gcnew System::EventHandler(this, &frmMain::tbsMesh_Click); // // toolStripSeparator26 // this->toolStripSeparator26->Name = L"toolStripSeparator26"; this->toolStripSeparator26->Size = System::Drawing::Size(6, 25); // // tbsSound // this->tbsSound->DisplayStyle = System::Windows::Forms::ToolStripItemDisplayStyle::Image; this->tbsSound->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tbsSound.Image"))); this->tbsSound->ImageTransparentColor = System::Drawing::Color::Magenta; this->tbsSound->Name = L"tbsSound"; this->tbsSound->Size = System::Drawing::Size(23, 22); this->tbsSound->Text = L"Add new sound object"; this->tbsSound->Click += gcnew System::EventHandler(this, &frmMain::tbsSound_Click); // // toolStripSeparator30 // this->toolStripSeparator30->Name = L"toolStripSeparator30"; this->toolStripSeparator30->Size = System::Drawing::Size(6, 25); // // dockManager // this->dockManager->ActiveAutoHideContent = nullptr; this->dockManager->AllowEndUserDocking = true; this->dockManager->Dock = System::Windows::Forms::DockStyle::Fill; this->dockManager->Location = System::Drawing::Point(0, 74); this->dockManager->Margin = System::Windows::Forms::Padding(2); this->dockManager->Name = L"dockManager"; this->dockManager->Size = System::Drawing::Size(1158, 456); this->dockManager->TabIndex = 9; // // renderingToolStripMenuItem // this->renderingToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(2) {this->mnuSimulationRenderingContinuous, this->mnuSimulationRenderingRequestRender}); this->renderingToolStripMenuItem->Name = L"renderingToolStripMenuItem"; this->renderingToolStripMenuItem->Size = System::Drawing::Size(152, 22); this->renderingToolStripMenuItem->Text = L"Rendering"; // // mnuSimulationRenderingContinuous // this->mnuSimulationRenderingContinuous->Checked = true; this->mnuSimulationRenderingContinuous->CheckOnClick = true; this->mnuSimulationRenderingContinuous->CheckState = System::Windows::Forms::CheckState::Checked; this->mnuSimulationRenderingContinuous->Name = L"mnuSimulationRenderingContinuous"; this->mnuSimulationRenderingContinuous->Size = System::Drawing::Size(153, 22); this->mnuSimulationRenderingContinuous->Text = L"Continuous"; this->mnuSimulationRenderingContinuous->Click += gcnew System::EventHandler(this, &frmMain::mnuSimulationRenderingContinuous_Click); // // mnuSimulationRenderingRequestRender // this->mnuSimulationRenderingRequestRender->Enabled = false; this->mnuSimulationRenderingRequestRender->Name = L"mnuSimulationRenderingRequestRender"; this->mnuSimulationRenderingRequestRender->Size = System::Drawing::Size(153, 22); this->mnuSimulationRenderingRequestRender->Text = L"Request render"; this->mnuSimulationRenderingRequestRender->Click += gcnew System::EventHandler(this, &frmMain::mnuSimulationRenderingRequestRender_Click); // // frmMain // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(1158, 552); this->Controls->Add(this->dockManager); this->Controls->Add(this->toolStrip2); this->Controls->Add(this->stsStrip); this->Controls->Add(this->toolStrip1); this->Controls->Add(this->mnsMainMenu); this->IsMdiContainer = true; this->KeyPreview = true; this->Location = System::Drawing::Point(0, 28); this->MainMenuStrip = this->mnsMainMenu; this->Margin = System::Windows::Forms::Padding(2); this->Name = L"frmMain"; this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen; this->Text = L"nGENE Tech Toolset"; this->WindowState = System::Windows::Forms::FormWindowState::Maximized; this->Load += gcnew System::EventHandler(this, &frmMain::frmMain_Load); this->mnsMainMenu->ResumeLayout(false); this->mnsMainMenu->PerformLayout(); this->toolStrip1->ResumeLayout(false); this->toolStrip1->PerformLayout(); this->stsStrip->ResumeLayout(false); this->stsStrip->PerformLayout(); this->toolStrip2->ResumeLayout(false); this->toolStrip2->PerformLayout(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: WeifenLuo::WinFormsUI::Docking::IDockContent^ GetContentFromPersistString(System::String^ persistString) { if (persistString == frmRenderTarget::typeid->ToString()) return target; else if (persistString == frmPropertyManager::typeid->ToString()) return frmProperty; else if (persistString == frmToolbox::typeid->ToString()) return frmTools; else if (persistString == frmFXs::typeid->ToString()) return frmFX; else if (persistString == frmSolutionExplorer::typeid->ToString()) return frmExplorer; else if (persistString == frmMaterialLib::typeid->ToString()) return frmMatLib; else if (persistString == frmSceneGraph::typeid->ToString()) return frmGraph; else if (persistString == frmOutput::typeid->ToString()) return frmOut; else if (persistString == frmErrorList::typeid->ToString()) return frmError; else return nullptr; } private: System::Void frmMain_Load(System::Object^ sender, System::EventArgs^ e) { // Create windows frmAboutBox = gcnew frmAbout(); frmTools = gcnew frmToolbox(); frmOut = gcnew frmOutput(); target = gcnew frmRenderTarget(tssFPS); frmProperty = gcnew frmPropertyManager(); frmFX = gcnew frmFXs(); frmBrowser = gcnew frmWebBrowser(); frmExplorer = gcnew frmSolutionExplorer(); frmMatLib = gcnew frmMaterialLib(frmProperty, frmFX); frmGraph = gcnew frmSceneGraph(frmProperty); frmError = gcnew frmErrorList(); frmHeight = gcnew frmHeightMapEditor(tssLabel); frmShader = gcnew ShaderEditor(); frmScript = gcnew frmScriptEditor(); // Load layout from file deserializeDockContent = gcnew DeserializeDockContent(this, &frmMain::GetContentFromPersistString); if(System::IO::File::Exists("layout.xml")) dockManager->LoadFromXml("layout.xml", deserializeDockContent); frmProperty->Show(dockManager); frmTools->Show(dockManager); frmExplorer->Show(dockManager); frmMatLib->Show(dockManager); frmFX->Show(dockManager); frmGraph->Show(dockManager); frmError->Show(dockManager); frmOut->Show(dockManager); //frmBrowser->Show(dockManager, DockState::Document); target->Show(dockManager, DockState::Document); this->Invalidate(); this->Update(); target->init(); frmMatLib->addLibrary(L"default"); frmProperty->SelectedObject = frmRenderTarget::engine; // Get scene manager SceneManager* sm = Engine::getSingleton().getSceneManager(0); NodeWrapper^ root = gcnew NodeWrapper(sm->getRootNode(), "Scene Root", 0); camera = gcnew CameraWrapper(); camera->Aspect = (float)target->Width / (float)target->Height; // Create partitioner QUAD_TREE_DESC quad_tree; quad_tree.bounds.left = -5000.0f; quad_tree.bounds.right= 5000.0f; quad_tree.bounds.top = -5000.0f; quad_tree.bounds.bottom = 5000.0f; quad_tree.minimumNodeSize = 50.0f; Assert(quad_tree.isValid(), "Invalid quad tree description!"); ScenePartitioner* m_pPartitioner = new ScenePartitionerQuadTree(quad_tree); sm->setScenePartitioner(m_pPartitioner); Log::log(LET_EVENT, L"Editor", __WFILE__, __WFUNCTION__, __LINE__, L"-----------------------------------------------------------------------------------------"); Log::log(LET_EVENT, L"Editor", __WFILE__, __WFUNCTION__, __LINE__, L"nGENE Tech Editor loaded"); } System::Void helpToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { } System::Void insertToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { } System::Void newToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void mnuPropertyManager_Click(System::Object^ sender, System::EventArgs^ e) { if(frmProperty->Visible) frmProperty->Hide(); else frmProperty->Show(dockManager); } private: System::Void texturedToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void fullToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void mnuMaterialEditor_Click(System::Object^ sender, System::EventArgs^ e) { if(frmMatEdit != nullptr) { delete frmMatEdit; } frmMatEdit = gcnew frmMaterialEditor(); frmMatEdit->Show(dockManager); } private: System::Void mnuNGENEOnTheWeb_Click(System::Object^ sender, System::EventArgs^ e) { if(frmBrowser->Visible) frmBrowser->Hide(); else { frmBrowser->setURL("http://ngene.wikidot.com"); frmBrowser->Show(dockManager, DockState::Document); } } private: System::Void mnuWireframe_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->Wireframe = mnuWireframe->Checked; } } private: System::Void mnuLighting_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->Lighting = mnuLighting->Checked; } } private: System::Void mnuInsertLightOmni_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); light = gcnew LightWrapper(); light->Type = LightType::Point; frmProperty->SelectedObject = light; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertLightDirectional_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); light = gcnew LightWrapper(); light->Type = LightType::Directional; frmProperty->SelectedObject = light; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuSimulationModesPhysics_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->PhysicsEnabled = mnuSimulationModesPhysics->Checked; } } private: System::Void mnuInsertCameraFPP_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); camera = gcnew CameraWrapper(); camera->Aspect = (float)target->Width / (float)target->Height; frmProperty->SelectedObject = camera; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertPrefabBox_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PrefabBoxWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertLightSpot_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); light = gcnew LightWrapper(); light->Type = LightType::Spot; frmProperty->SelectedObject = light; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertTerrain_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); OpenFileDialog^ dlgOpenFile = gcnew OpenFileDialog(); dlgOpenFile->Title = "Choose height map file"; dlgOpenFile->Filter = ".bmp files|*.bmp|.jpg files|*.jpg|.gif files|*.gif|.png files|*.png|All files (*.*)|*.*"; dlgOpenFile->FilterIndex = 1; if(dlgOpenFile->ShowDialog() == System::Windows::Forms::DialogResult::OK) { pin_ptr <const wchar_t> str1 = PtrToStringChars(dlgOpenFile->FileName); wstring fileName(str1); ITexture* pTexture = TextureManager::getSingleton().createTextureFromFile(L"Terrain", fileName, TT_2D, TU_NORMAL, TF_A8R8G8B8); terrain = gcnew TerrainWrapper(pTexture); frmProperty->SelectedObject = terrain; TextureManager::getSingleton().removeTexture(L"Terrain"); } } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void loadLayoutToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void outdoorToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void mnuInsertOutdoorTerrain_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); OpenFileDialog^ dlgOpenFile = gcnew OpenFileDialog(); dlgOpenFile->Title = "Choose height map file"; dlgOpenFile->Filter = ".bmp files|*.bmp|.jpg files|*.jpg|.gif files|*.gif|.png files|*.png|All files (*.*)|*.*"; dlgOpenFile->FilterIndex = 1; if(dlgOpenFile->ShowDialog() == System::Windows::Forms::DialogResult::OK) { pin_ptr <const wchar_t> str1 = PtrToStringChars(dlgOpenFile->FileName); wstring fileName(str1); ITexture* pTexture = TextureManager::getSingleton().createTextureFromFile(L"Terrain", fileName, TT_2D, TU_NORMAL, TF_A8R8G8B8); terrain = gcnew TerrainWrapper(pTexture); frmProperty->SelectedObject = terrain; TextureManager::getSingleton().removeTexture(L"Terrain"); } } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertOutdoorSky_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew SkyWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertOutdoorClouds_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew CloudsWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInstertOutdoorWater_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew WaterWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuWindowSaveLayout_Click(System::Object^ sender, System::EventArgs^ e) { FileManager::getSingleton().changeDir("../release"); dockManager->SaveAsXml("layout.xml"); FileManager::getSingleton().changeDir("../media"); } private: System::Void mnuAbout_Click(System::Object^ sender, System::EventArgs^ e) { frmAboutBox->Show(nullptr); } private: System::Void mnuViewMaterialLibrary_Click(System::Object^ sender, System::EventArgs^ e) { if(frmMatLib->Visible) frmMatLib->Hide(); else frmMatLib->Show(dockManager); } private: System::Void mnuViewOutput_Click(System::Object^ sender, System::EventArgs^ e) { if(frmOut->Visible) frmOut->Hide(); else frmOut->Show(dockManager); } private: System::Void mnuViewSolutionExplorer_Click(System::Object^ sender, System::EventArgs^ e) { if(frmExplorer->Visible) frmExplorer->Hide(); else frmExplorer->Show(dockManager); } private: System::Void mnuViewToolbox_Click(System::Object^ sender, System::EventArgs^ e) { if(frmTools->Visible) frmTools->Hide(); else frmTools->Show(dockManager); } private: System::Void mnuInsertPSParticleSystem_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew ParticleSystemWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertPSParticleEmitter_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { ParticleSystemWrapper^ ps = safe_cast<ParticleSystemWrapper^>(frmGraph->graph->getActive()); nodeObj = gcnew ParticleEmitterWrapper(); ps->addEmitter(safe_cast<ParticleEmitterWrapper^>(nodeObj)); } catch(InvalidCastException^) { MessageBox::Show("Please select node of particle system type"); } } } private: System::Void mnuInsertPSParticleColour_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { ParticleEmitterWrapper^ emitter = safe_cast<ParticleEmitterWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew ParticleColourWrapper(); emitter->addColour(safe_cast<ParticleColourWrapper^>(nodeObj)); } catch(InvalidCastException^) { MessageBox::Show("Please select node of particle emitter type"); } } } private: System::Void mnuViewModeHDR_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->HDR = mnuViewModeHDR->Checked; } } private: System::Void exitToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void mnuFileSave_Click(System::Object^ sender, System::EventArgs^ e) { saveWorld(); } private: System::Void mnuInsertMesh_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); OpenFileDialog^ dlgOpenFile = gcnew OpenFileDialog(); dlgOpenFile->Filter = ".x files|*.x|.3ds files|*.3ds|Collada files|*.xml|All files (*.*)|*.*"; dlgOpenFile->FilterIndex = 1; if(dlgOpenFile->ShowDialog() == System::Windows::Forms::DialogResult::OK) { String^ ext = IO::Path::GetExtension(dlgOpenFile->FileName); if(ext->ToLower() == ".x") nodeObj = gcnew MeshWrapperXFile(dlgOpenFile->FileName); else if(ext->ToLower() == ".3ds") nodeObj = gcnew MeshWrapper3dsFile(dlgOpenFile->FileName); else if(ext->ToLower() == ".xml") nodeObj = gcnew MeshWrapperColladaFile(dlgOpenFile->FileName); else { MessageBox::Show("File format is not supported", "Invalid format", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Error); Log::log(LET_ERROR, L"Editor", __WFILE__, __WFUNCTION__, __LINE__, L"Mesh couldn't be loaded. Unsupported file format"); return; } frmProperty->SelectedObject = nodeObj; } } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void tsbSave_Click(System::Object^ sender, System::EventArgs^ e) { saveWorld(); } private: System::Void saveWorld() { tssLabel->Text = "Saving map..."; if(target != nullptr) { frmRenderTarget::engine->save(); } Log::log(LET_EVENT, L"Editor", __WFILE__, __WFUNCTION__, __LINE__, L"Map saved successfully."); tssLabel->Text = "Ready"; } private: System::Void mnuFileOpenFile_Click(System::Object^ sender, System::EventArgs^ e) { loadWorld(); } private: System::Void tsbOpen_Click(System::Object^ sender, System::EventArgs^ e) { loadWorld(); } private: System::Void loadWorld() { tssLabel->Text = "Loading map..."; if(target != nullptr) { bool result = frmRenderTarget::engine->load(); if(result) { // Remove all post processing materials if(frmFX != nullptr) frmFX->cleanup(); } Log::log(LET_EVENT, L"Editor", __WFILE__, __WFUNCTION__, __LINE__, L"Map loaded successfully."); } tssLabel->Text = "Ready"; } private: System::Void mnuInsertPrefabSphere_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PrefabSphereWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertPrefabPlane_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PrefabPlaneWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuViewModeShadows_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->Shadows = mnuViewModeShadows->Checked; } } private: System::Void mnuViewModeReflections_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->Reflections = mnuViewModeReflections->Checked; } } private: System::Void mnuHelpTutorials_Click(System::Object^ sender, System::EventArgs^ e) { if(frmBrowser->Visible) frmBrowser->Hide(); else { frmBrowser->setURL("http://ngene.wikidot.com/tutorials"); frmBrowser->Show(dockManager, DockState::Document); } } private: System::Void mnuViewModeDebugInfo_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->DebugAABB = mnuViewModeDebugInfo->Checked; } } private: System::Void toolStrip1_ItemClicked(System::Object^ sender, System::Windows::Forms::ToolStripItemClickedEventArgs^ e) { } private: System::Void tsbLockX_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->LockX = tsbLockX->Checked; } } private: System::Void tsbLockY_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->LockY = tsbLockY->Checked; } } private: System::Void tsbLockZ_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmRenderTarget::engine->LockZ = tsbLockZ->Checked; } } private: System::Void xAxisToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { tsbLockX->Checked = xAxisToolStripMenuItem->Checked; if(target != nullptr) { frmRenderTarget::engine->LockX = tsbLockX->Checked; } } private: System::Void yAxisToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { tsbLockY->Checked = yAxisToolStripMenuItem->Checked; if(target != nullptr) { frmRenderTarget::engine->LockY = tsbLockY->Checked; } } private: System::Void zAxisToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) { tsbLockZ->Checked = zAxisToolStripMenuItem->Checked; if(target != nullptr) { frmRenderTarget::engine->LockZ = tsbLockZ->Checked; } } private: System::Void tbsNewProject_Click(System::Object^ sender, System::EventArgs^ e) { createNewProject(); } private: System::Void createNewProject() { System::Windows::Forms::DialogResult result; result = MessageBox::Show("Creating new project. All unsaved data will be lost. Continue?", "Creating new project", System::Windows::Forms::MessageBoxButtons::OKCancel, System::Windows::Forms::MessageBoxIcon::Question); if(result == System::Windows::Forms::DialogResult::OK) { frmRenderTarget::engine->reset(target->Width, target->Height); if(frmFX != nullptr) { frmFX->cleanup(); } } } private: System::Void tbsRemoveNode_Click(System::Object^ sender, System::EventArgs^ e) { System::Windows::Forms::DialogResult result; result = MessageBox::Show("Are you sure you want to delete this node? All child nodes will be removed as well.", "Deleting node", System::Windows::Forms::MessageBoxButtons::YesNo, System::Windows::Forms::MessageBoxIcon::Question); if(result == System::Windows::Forms::DialogResult::Yes) { if(target != nullptr) { frmRenderTarget::engine->removeSelected(); } } } private: System::Void tbsLight_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertLightOmni_Click(sender, e); } private: System::Void tbsBox_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertPrefabBox_Click(sender, e); } private: System::Void tbsSphere_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertPrefabSphere_Click(sender, e); } private: System::Void tbsPlane_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertPrefabPlane_Click(sender, e); } private: System::Void tbsCamera_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertCameraFPP_Click(sender, e); } private: System::Void tbsTerrain_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertTerrain_Click(sender, e); } private: System::Void tbsSky_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertOutdoorSky_Click(sender, e); } private: System::Void tbsClouds_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertOutdoorClouds_Click(sender, e); } private: System::Void tbsWater_Click(System::Object^ sender, System::EventArgs^ e) { mnuInstertOutdoorWater_Click(sender, e); } private: System::Void tbsParticleSystem_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertPSParticleSystem_Click(sender, e); } private: System::Void tbsParticleEmitter_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertPSParticleEmitter_Click(sender, e); } private: System::Void tbsMesh_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertMesh_Click(sender, e); } private: System::Void mnuEditDelete_Click(System::Object^ sender, System::EventArgs^ e) { tbsRemoveNode_Click(sender, e); } private: System::Void mnuInsertOtherFur_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { SurfaceWrapper^ surf = safe_cast<SurfaceWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew FurWrapper(surf); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select surface to use as fur base", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuToolsOptions_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { frmProperty->SelectedObject = frmRenderTarget::engine; } } private: System::Void mnuHeightMapEditor_Click(System::Object^ sender, System::EventArgs^ e) { if(frmHeight->Visible) frmHeight->Hide(); else frmHeight->Show(dockManager); } private: System::Void mnuContentAuthoringShaderEditor_Click(System::Object^ sender, System::EventArgs^ e) { if(frmShader->Visible) frmShader->Hide(); else frmShader->Show(dockManager); } private: System::Void mnuInsertPSParticleForce_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { ParticleEmitterWrapper^ emitter = safe_cast<ParticleEmitterWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew ParticleForceWrapper(); emitter->addForce(safe_cast<ParticleForceWrapper^>(nodeObj)); } catch(InvalidCastException^) { MessageBox::Show("Please select node of particle emitter type", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuErrorList_Click(System::Object^ sender, System::EventArgs^ e) { if(frmError->Visible) frmError->Hide(); else frmError->Show(dockManager); } private: System::Void mnuInsertPhysicsRigidBox_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PhysicsActorWrapper(node->getnGENENode(), L"Box", true); } catch(InvalidCastException^) { MessageBox::Show("Please select scene node of node type", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void planeToolStripMenuItem1_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PhysicsActorWrapper(node->getnGENENode(), L"Plane", false); } catch(InvalidCastException^) { MessageBox::Show("Please select scene node of node type", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuScriptEditor_Click(System::Object^ sender, System::EventArgs^ e) { if(frmScript->Visible) frmScript->Hide(); else frmScript->Show(dockManager); } private: System::Void mnuFXs_Click(System::Object^ sender, System::EventArgs^ e) { if(frmFX->Visible) frmFX->Hide(); else frmFX->Show(dockManager); } private: System::Void mnuInsertLightVolumetric_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { LightWrapper^ lw = safe_cast<LightWrapper^>(frmGraph->graph->getActive()); nodeObj = gcnew VolumetricLightWrapper(lw->getLight()); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select light node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertSound_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); OpenFileDialog^ dlgOpenFile = gcnew OpenFileDialog(); dlgOpenFile->Filter = ".wav files|*.wav|.ogg files|*.ogg|*.mp3 files|*.mp3|All files (*.*)|*.*"; dlgOpenFile->FilterIndex = 1; if(dlgOpenFile->ShowDialog() == System::Windows::Forms::DialogResult::OK) { nodeObj = gcnew SoundWrapper(dlgOpenFile->FileName); frmProperty->SelectedObject = nodeObj; } } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void tbsSound_Click(System::Object^ sender, System::EventArgs^ e) { mnuInsertSound_Click(sender, e); } private: System::Void mnuInsertLightning_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew LightningWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertPrefabCapsule_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PrefabCapsuleWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertPrefabTeapot_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PrefabTeapotWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertPrefabTorus_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PrefabTorusWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertPrefabCylinder_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PrefabCylinderWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertPrefabPyramid_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { NodeWrapper^ node = safe_cast<NodeWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew PrefabPyramidWrapper(); frmProperty->SelectedObject = nodeObj; } catch(InvalidCastException^) { MessageBox::Show("Please select scene node", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuInsertPSParticleDeflector_Click(System::Object^ sender, System::EventArgs^ e) { if(target != nullptr) { try { ParticleEmitterWrapper^ emitter = safe_cast<ParticleEmitterWrapper^>(frmGraph->graph->getActiveSceneNode()); nodeObj = gcnew ParticleDeflectorWrapper(); emitter->addDeflector(safe_cast<ParticleDeflectorWrapper^>(nodeObj)); } catch(InvalidCastException^) { MessageBox::Show("Please select node of particle emitter type", "Select different node", System::Windows::Forms::MessageBoxButtons::OK, System::Windows::Forms::MessageBoxIcon::Exclamation); } } } private: System::Void mnuSimulationRenderingContinuous_Click(System::Object^ sender, System::EventArgs^ e) { bool bRender = mnuSimulationRenderingContinuous->Checked; mnuSimulationRenderingRequestRender->Enabled = !bRender; target->setContinuousRendering(bRender); } private: System::Void mnuSimulationRenderingRequestRender_Click(System::Object^ sender, System::EventArgs^ e) { target->requestRender(); } }; } #endif
[ "Riddlemaster@fdc6060e-f348-4335-9a41-9933a8eecd57" ]
[ [ [ 1, 3052 ] ] ]
2c696cb3fc819bd92f946ef4a3940571d17a876c
59166d9d1eea9b034ac331d9c5590362ab942a8f
/XMLTree2Geom/xml/xmlRoot/xmlLeaf/xmlLeafSave.h
0319d7af9bf90bb3430a4e1c79e7fccdc47b59c9
[]
no_license
seafengl/osgtraining
5915f7b3a3c78334b9029ee58e6c1cb54de5c220
fbfb29e5ae8cab6fa13900e417b6cba3a8c559df
refs/heads/master
2020-04-09T07:32:31.981473
2010-09-03T15:10:30
2010-09-03T15:10:30
40,032,354
0
3
null
null
null
null
WINDOWS-1251
C++
false
false
370
h
#ifndef _XML_LEAF_SAVE_H_ #define _XML_LEAF_SAVE_H_ #include "binLeaf.h" #include "ticpp.h" class xmlLeafSave { public: xmlLeafSave(); ~xmlLeafSave(); //получить xml тег с сформированными данными ticpp::Node* GetXmlData( const binLeaf &_data ); private: const binLeaf *m_pData; }; #endif //_XML_LEAF_SAVE_H_
[ "asmzx79@3290fc28-3049-11de-8daa-cfecb5f7ff5b" ]
[ [ [ 1, 20 ] ] ]
5f9ae307af3cd339a906c3bbc0d6c0a5101275e0
1e4daaa1f0846720f608094479aadb58759e1021
/graphgenerator/network_files/LTSNetwork.cpp
313f18d22a410ce4aafd8fd5cddc052054557822
[]
no_license
DDionne/SpiderWeb
d7d69091a08aaf6b2ae7f50ad7a8bd40406cc693
0d3e78a0a053e4c0e826cf9b9eae332930929fc0
refs/heads/master
2021-01-16T19:56:44.257854
2011-06-07T19:33:40
2011-06-07T19:33:40
1,860,449
0
0
null
null
null
null
UTF-8
C++
false
false
6,512
cpp
/******************************************************************* * * DESCRIPTION: Atomic Model : Network (LTS system) * * AUTHOR: Alan * * * DATE: November 2010 * *******************************************************************/ /** include files **/ #include <math.h> // fabs( ... ) #include <stdlib.h> #include "randlib.h" // Random numbers library #include "LTSNetwork.h" // base header #include "message.h" // InternalMessage .... //#include "..\..\lib\graph-c++.h" // class graph //#include "NetGraph.h" // basic undirected graph with integers #include "mainsimu.h" // class MainSimulator #include "strutil.h" // str2float( ... ) /******************************************************************* * Function Name: LTSNetwork * Description: constructor ********************************************************************/ LTSNetwork::LTSNetwork( const string &name ) : Atomic( name ) , peer_online( addInputPort( "peer_online" ) ) , peer_offline( addInputPort( "peer_offline" ) ) , peer_connect( addInputPort( "peer_connect" ) ) , peer_disconnect( addInputPort( "peer_disconnect" ) ) , inroute( addInputPort( "inroute" ) ) , route_out( addOutputPort( "route_out" ) ) , out_connect( addOutputPort( "out_connect" ) ) , out_disconnect( addOutputPort( "out_disconnect" ) ) { //create a new Graph. Nothing else... ? thegraph= new GraphInt(); } /******************************************************************* * Function Name: externalFunction * Description: the Network gets input from outside ********************************************************************/ Model &LTSNetwork::externalFunction( const ExternalMessage &msg ){ if (msg.port() == peer_online) { thegraph->online(msg.value()); //adds a node to the graph with the given value if(VERBOSE) cout<<"node "<<msg.value()<<" inserted\n"; //holdIn( active, Time(0.00f)); } else if (msg.port() == peer_offline){ int inpeer = msg.value(); //get all the connected nodes a disconnect them, plus let them know they've been disconnected set<int> connected = thegraph->getConnectedNodes(inpeer); set<int>::iterator sit; for ( sit=connected.begin() ; sit != connected.end(); sit++ ){ thegraph->disconnect(inpeer, *sit); //disconnect them DisconnectionQueue.push(buildMessage(*sit, inpeer)); //enqueue a message saying peer "inpeer" disconnects from "*sit" } thegraph->offline(inpeer); if(VERBOSE) cout<<"node "<<msg.value()<<" removed\n"; //holdIn( active, Time(0.00f)); } else if (msg.port() == peer_connect){ int twonumbers, from, to; twonumbers = msg.value(); from = getPeerId(twonumbers); //first and second field encoding of the peers to = getMessageId(twonumbers); if(VERBOSE) cout<<"connecting "<<from<<" to "<< to<<"\n"; if(thegraph->connect(from,to)) ConnectionQueue.push(buildMessage(to, from, 1)); // enqueue a connection message : adding the TTL makes it different from a disconnect message, further down the road //holdIn( active, Time(0.00f)); } else if (msg.port() == peer_disconnect){ int twonumbers, from, to; twonumbers = msg.value(); from = getPeerId(twonumbers); //first and second field encoding of the peers to = getMessageId(twonumbers); if(VERBOSE) cout<<"disconnecting "<<from<<" and "<< to<<"\n"; if(thegraph->disconnect(from, to)) DisconnectionQueue.push(twonumbers); // enqueue the original message to be re-output as confirmation that connection took place //holdIn( active, Time(0.00f)); } else if (msg.port() == inroute){ //routing=true; int inpeer, TTL, messageId; inpeer = getPeerId(msg.value()); TTL= getTTL(msg.value()); messageId = getMessageId(msg.value()); if(VERBOSE) cout<<"about to route a message from"<<inpeer<<"\n"; //get all the connected nodes and enqueue the "arrival of the message" event for all these new nodes //find the nodes connected to this one set<int> connected = thegraph->getConnectedNodes(inpeer); //if(VERBOSE) cout<<"loop for enqueuing nodes :"<<connected.size()<<" nodes to enqueue"; set<int>::iterator sit; //if(VERBOSE) cout << "connected nodes contains:"; for ( sit=connected.begin() ; sit != connected.end(); sit++ ){ // if(VERBOSE) cout<<"bang! "<<*sit<<"\n"; EvQ.push(makeNetworkEvent(messageId, *sit, TTL, 0.0f)); //enqueue a network event with the "*sit" peer (the other parts are not used for now) //holdIn( active, Time(0.01f)); } } // TEST : no external transition unless we're passive if (this->state()==passive){ holdIn( active, Time(0,0,0,120)); //wait 120ms before doing something } return *this ; } /******************************************************************* * Function Name: internalFunction ********************************************************************/ Model &LTSNetwork::internalFunction( const InternalMessage & ){ if (!EvQ.empty() || !DisconnectionQueue.empty() || !ConnectionQueue.empty()) { // if any of the queues are not empty holdIn( active, Time(0,0,0,10)); // we wait 10ms to dequeue // that is, we only have a useless fixed timing between two messages getting through the network } else { passivate(); // we just passivate immediately } return *this; } /******************************************************************* * Function Name: outputFunction ********************************************************************/ Model &LTSNetwork::outputFunction( const InternalMessage &msg ) { if(VERBOSE) cout<<"LTS: output coming...\n"; if ( !EvQ.empty() ) // if we have messages to dequeue { long message = buildMessage(EvQ.front().id, EvQ.front().peerid, EvQ.front().TTL); sendOutput( msg.time(), route_out, message); EvQ.pop(); //remove val from queue } if ( !ConnectionQueue.empty() ) // if we have connect messages to dequeue { sendOutput( msg.time(), out_connect, ConnectionQueue.front()); ConnectionQueue.pop(); //remove val from queue } if ( !DisconnectionQueue.empty() ) // if we have disconnect messages to dequeue { sendOutput( msg.time(), out_disconnect, DisconnectionQueue.front()); DisconnectionQueue.pop(); //remove val from queue } return *this; } LTSNetwork::~LTSNetwork() { delete thegraph; }
[ [ [ 1, 182 ] ] ]
42ba11b4611dbc8fd290b95a9c7a099c276a283f
940a846f0685e4ca0202897a60c58c4f77dd94a8
/demo/FireFox/plugin/test/nprt3/nprt/ScriptablePluginObject.h
c6827688fb19f885fa35a607cd7296010227f1ce
[]
no_license
grharon/tpmbrowserplugin
be33fbe89e460c9b145e86d7f03be9c4e3b73c14
53a04637606f543012c0d6d18fa54215123767f3
refs/heads/master
2016-09-05T15:46:55.064258
2010-09-04T12:05:31
2010-09-04T12:05:31
35,827,176
0
0
null
null
null
null
UTF-8
C++
false
false
1,494
h
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ #include "ScriptablePluginObjectBase.h" #ifndef SCRIPTABLEPLUGINOBJECT_H #define SCRIPTABLEPLUGINOBJECT_H #include "fix.h" class ScriptablePluginObject : public ScriptablePluginObjectBase { public: ScriptablePluginObject(NPP npp) : ScriptablePluginObjectBase(npp) { // sample of initialized value : keyword keyword = m_strdup("HELLO WORLD"); // sample of uninitailized value : code code = NULL; } virtual ~ScriptablePluginObject() { // dealloc memory if (keyword) NPN_MemFree(keyword); if (code) NPN_MemFree(code); } virtual bool HasMethod(NPIdentifier name); virtual bool HasProperty(NPIdentifier name); virtual bool GetProperty(NPIdentifier name, NPVariant *result); virtual bool Invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result); virtual bool InvokeDefault(const NPVariant *args, uint32_t argCount, NPVariant *result); virtual bool SetProperty(NPIdentifier name, const NPVariant *value); private: // define ScriptablePluginObject vars here char* keyword; char* code; }; static NPObject * AllocateScriptablePluginObject(NPP npp, NPClass *aClass) { return new ScriptablePluginObject(npp); } DECLARE_NPOBJECT_CLASS_WITH_BASE(ScriptablePluginObject, AllocateScriptablePluginObject); #endif
[ "stlt1sean@aa5d9edc-7c6f-d5c9-3e23-ee20326b5c4f" ]
[ [ [ 1, 50 ] ] ]
7176c899662b6d335bd0e18e1871f0398ce7ef71
353bd39ba7ae46ed521936753176ed17ea8546b5
/src/layer0_base/math/src/axmt_float.cpp
766a5057b9dc5e548ef723a5a733fccbc16798d4
[]
no_license
d0n3val/axe-engine
1a13e8eee0da667ac40ac4d92b6a084ab8a910e8
320b08df3a1a5254b776c81775b28fa7004861dc
refs/heads/master
2021-01-01T19:46:39.641648
2007-12-10T18:26:22
2007-12-10T18:26:22
32,251,179
1
0
null
null
null
null
UTF-8
C++
false
false
2,612
cpp
/** * @file * axe_float struct */ #include "axmt_stdafx.h" // ----------------------------------------------------------------- // Creators -------------------------------------------------------- axe_float::axe_float( const float& f ) { this->f = f; } // ----------------------------------------------------------------- // Cast operators -------------------------------------------------- axe_float::operator int() const { return( (int) f ); } axe_float::operator float() const { return( f ); } // ----------------------------------------------------------------- // Math operators -------------------------------------------------- bool axe_float::operator==( const axe_float& v ) const { return( abs(f - v.f) < EPSILON ); } bool axe_float::operator!=( const axe_float& v ) const { return( abs(f - v.f) > EPSILON ); } bool axe_float::operator>=( const axe_float& v ) const { return( f > v.f || abs(f - v.f) < EPSILON ); } bool axe_float::operator<=( const axe_float& v ) const { return( f < v.f || abs(f - v.f) < EPSILON ); } // ----------------------------------------------------------------- // Other methods --------------------------------------------------- axe_float axe_float::set_infinity() { f = INFINITY; return( *this ); } axe_float axe_float::inverse() const { return( axe_float(1.0f / f) ); } axe_float axe_float::sin() const { const float B = 4.0f / PI; const float C = -4.0f / QUAD_PI; float y = B * f + C * f * abs( f ); #ifdef AXMT_EXTRA_PRECISION const float P = 0.225f; y = P * ( y * abs(y) - y ) + y; #endif return( y ); } axe_float axe_float::cos() const { // cos(x) = sin(x + pi/2) axe_float s = f + HALF_PI; return( s.sin() ); } axe_float axe_float::tan() const { return( tanf(f) ); } axe_float axe_float::asin() const { return( asinf(f) ); } axe_float axe_float::acos() const { return( acosf(f) ); } axe_float axe_float::atan() const { return( atanf(f) ); } axe_float axe_float::floor() const { return( floorf(f) ); } axe_float axe_float::set_max( axe_float& v ) { if( f > v.f ) { f = v.f; } return( *this ); } axe_float axe_float::set_min( axe_float& v ) { if( f < v.f ) { f = v.f; } return( *this ); } axe_float axe_float::cap( axe_float& min, axe_float& max ) { if( f < min.f ) { f = min.f; } else if( f > max.f ) { f = max.f; } return( *this ); } /* $Id: axmt_angle.cpp,v 1.2 2004/08/31 07:45:20 doneval Exp $ */
[ "d0n3val@2cff7946-3f3c-0410-b79f-f9b517ddbf54" ]
[ [ [ 1, 141 ] ] ]
c89bfd09a5af619be78a99ca42867b60dbcc1727
975d45994f670a7f284b0dc88d3a0ebe44458a82
/cliente/Source/Shader/CToonShader.cpp
b533158759a4022ac5e25b2be82e91e3f620971c
[]
no_license
phabh/warbugs
2b616be17a54fbf46c78b576f17e702f6ddda1e6
bf1def2f8b7d4267fb7af42df104e9cdbe0378f8
refs/heads/master
2020-12-25T08:51:02.308060
2010-11-15T00:37:38
2010-11-15T00:37:38
60,636,297
0
0
null
null
null
null
UTF-8
C++
false
false
2,319
cpp
#include "CToonShader.h" //----------------------------------------------------------------------------------------- CToonShader::CToonShader( IrrlichtDevice *device, ILightSceneNode *light ) { _dispositivo = device; _gerVideo = _dispositivo->getVideoDriver(); _gerCena = _dispositivo->getSceneManager(); _luz = light; //_lightPosition = light->getAbsolutePosition(); _camera = _gerCena->getActiveCamera(); } //----------------------------------------------------------------------------------------- CToonShader::~CToonShader() { } //----------------------------------------------------------------------------------------- void CToonShader::apply(ISceneNode/*IAnimatedMeshSceneNode*/ *modelo, c8 *textura) { modelo->setMaterialFlag( EMF_NORMALIZE_NORMALS, true ); modelo->getMaterial(0).setTexture(0, _gerVideo->getTexture(textura)); modelo->getMaterial(0).setTexture(1, _gerVideo->getTexture("recursos/texturas/layercell.png")); modelo->getMaterial(0).TextureLayer[1].BilinearFilter = false; IGPUProgrammingServices* gpu = _gerVideo->getGPUProgrammingServices(); s32 toonMaterial = gpu->addHighLevelShaderMaterialFromFiles( "recursos/shaders/cellshader.fx", "vertexMain", EVST_VS_2_0, "recursos/shaders/cellshader.fx", "pixelMain", EPST_PS_2_0, this); modelo->getMaterial(0).MaterialType = (E_MATERIAL_TYPE)toonMaterial; } //----------------------------------------------------------------------------------------- void CToonShader::OnSetConstants(IMaterialRendererServices* servicos, s32 dados) { matrix4 world = _gerVideo->getTransform(ETS_WORLD); matrix4 invWorld; world.getInverse(invWorld); vector3df lightPosOS; invWorld.transformVect(lightPosOS, _luz->getAbsolutePosition()/*_lightPosition*/); servicos->setVertexShaderConstant("mLightPos", &lightPosOS.X, 3); vector3df camPosOS; invWorld.transformVect(camPosOS, _camera->getAbsolutePosition()); servicos->setVertexShaderConstant("mCamPos", &camPosOS.X, 3); matrix4 wvp = _gerVideo->getTransform(ETS_PROJECTION); wvp *= _gerVideo->getTransform(ETS_VIEW); wvp *= world; servicos->setVertexShaderConstant("mWorldViewProj", wvp.pointer(), 16); } //-----------------------------------------------------------------------------------------
[ [ [ 1, 69 ] ] ]
f0115d832bb2021d193191675df444792352a823
b38ab5dcfb913569fc1e41e8deedc2487b2db491
/libraries/SoftFX/module/Image.cpp
e3d1aafd90d8db6236c8c33bdd095ce7f42e1eda
[]
no_license
santosh90n/Fury2
dacec86ab3972952e4cf6442b38e66b7a67edade
740a095c2daa32d33fdc24cc47145a1c13431889
refs/heads/master
2020-03-21T00:44:27.908074
2008-10-16T07:09:17
2008-10-16T07:09:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
26,892
cpp
/* SoftFX (Software graphics manipulation library) Copyright (C) 2003 Kevin Gadd This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../header/SoftFX Main.hpp" #include "../header/Clip.hpp" #include "../header/Blitters.hpp" #include "../header/Filters.hpp" #include "../header/Resample.hpp" #include "../header/Blend.hpp" LockingModes lockingMode = UserLocking; void ResampleImage_Linear(Image* Source, Image* Target) { if (Override::EnumOverrides(Override::ResampleImage_Linear, 2, Source, Target)) return; ImageLockManager ilDest(lockingMode, Target); ImageLockManager ilSource(lockingMode, Source); if (!ilDest.performUnlock()) { return; } if (!ilSource.performUnlock()) { return; } float x_multiplier = ((float)Source->Width / (float)Target->Width); float y_multiplier = ((float)Source->Height / (float)Target->Height); int *x_table = AllocateArray(int, Target->Width); int *y_table = AllocateArray(int, Target->Height); for (int y = 0; y < Target->Height; y++) { y_table[y] = y * y_multiplier; } for (int x = 0; x < Target->Width; x++) { x_table[x] = x * x_multiplier; } Pixel *target = Target->pointer(0, 0); for (int y = 0; y < Target->Height; y++) { for (int x = 0; x < Target->Width; x++) { *target = Source->getPixel(x_table[x], y_table[y]); target++; } } DeleteArray(x_table); DeleteArray(y_table); return; } void ResampleImage_Bilinear(Image* Source, Image* Target) { if (Override::EnumOverrides(Override::ResampleImage_BiLinear, 2, Source, Target)) return; ImageLockManager ilDest(lockingMode, Target); ImageLockManager ilSource(lockingMode, Source); if (!ilDest.performUnlock()) { return; } if (!ilSource.performUnlock()) { return; } float x_multiplier = ((float)Source->Width / (float)Target->Width); float y_multiplier = ((float)Source->Height / (float)Target->Height); float *x_table = AllocateArray(float, Target->Width); float *y_table = AllocateArray(float, Target->Height); for (int y = 0; y < Target->Height; y++) { y_table[y] = y * y_multiplier; } for (int x = 0; x < Target->Width; x++) { x_table[x] = x * x_multiplier; } Pixel *target = Target->pointer(0, 0); for (int y = 0; y < Target->Height; y++) { for (int x = 0; x < Target->Width; x++) { *target = Source->getPixelAA(x_table[x], y_table[y]); target++; } } DeleteArray(x_table); DeleteArray(y_table); return; } void ResampleImage_Half(Image* Source, Image* Target) { if (((Source->Width % 2) != 0) || ((Source->Height % 2) != 0)) { ResampleImage_Bilinear(Source, Target); return; } if (Override::EnumOverrides(Override::ResampleImage_Half, 2, Source, Target)) return; ImageLockManager ilDest(lockingMode, Target); ImageLockManager ilSource(lockingMode, Source); if (!ilDest.performUnlock()) { return; } if (!ilSource.performUnlock()) { return; } Pixel *target = Target->pointer(0, 0); Pixel *source[2] = {Source->pointer(0, 0), Source->pointer(0, 1)}; int r, g, b, a; for (int y = 0; y < Target->Height; y++) { for (int x = 0; x < Target->Width; x++) { r = g = b = a = 0; b += (*source[0])[::Blue]; g += (*source[0])[::Green]; r += (*source[0])[::Red]; a += (*source[0])[::Alpha]; source[0]++; b += (*source[1])[::Blue]; g += (*source[1])[::Green]; r += (*source[1])[::Red]; a += (*source[1])[::Alpha]; source[1]++; b += (*source[0])[::Blue]; g += (*source[0])[::Green]; r += (*source[0])[::Red]; a += (*source[0])[::Alpha]; source[0]++; b += (*source[1])[::Blue]; g += (*source[1])[::Green]; r += (*source[1])[::Red]; a += (*source[1])[::Alpha]; source[1]++; (*target)[::Blue] = (b / 4); (*target)[::Green] = (g / 4); (*target)[::Red] = (r / 4); (*target)[::Alpha] = (a / 4); target++; } source[0] += Source->Width; source[1] += Source->Width; } return; } void ResampleImage_Double(Image* Source, Image* Target) { if (Override::EnumOverrides(Override::ResampleImage_Double, 2, Source, Target)) return; ImageLockManager ilDest(lockingMode, Target); ImageLockManager ilSource(lockingMode, Source); if (!ilDest.performUnlock()) { return; } if (!ilSource.performUnlock()) { return; } Pixel *target[2] = {Target->pointer(0, 0), Target->pointer(0, 1)}; Pixel source[4]; for (int y = 0; y < Target->Height; y+=2) { for (int x = 0; x < Target->Width; x+=2) { Source->getPixels(x / 2, y / 2, 2, 2, source); *target[0] = source[0]; target[0]++; (*target[0])[::Blue] = (source[0][::Blue] + source[1][::Blue]) / 2; (*target[0])[::Green] = (source[0][::Green] + source[1][::Green]) / 2; (*target[0])[::Red] = (source[0][::Red] + source[1][::Red]) / 2; (*target[0])[::Alpha] = (source[0][::Alpha] + source[1][::Alpha]) / 2; target[0]++; (*target[1])[::Blue] = (source[0][::Blue] + source[2][::Blue]) / 2; (*target[1])[::Green] = (source[0][::Green] + source[2][::Green]) / 2; (*target[1])[::Red] = (source[0][::Red] + source[2][::Red]) / 2; (*target[1])[::Alpha] = (source[0][::Alpha] + source[2][::Alpha]) / 2; target[1]++; (*target[1])[::Blue] = (source[0][::Blue] + source[1][::Blue] + source[2][::Blue] + source[3][::Blue]) / 4; (*target[1])[::Green] = (source[0][::Green] + source[1][::Green] + source[2][::Green] + source[3][::Green]) / 4; (*target[1])[::Red] = (source[0][::Red] + source[1][::Red] + source[2][::Red] + source[3][::Red]) / 4; (*target[1])[::Alpha] = (source[0][::Alpha] + source[1][::Alpha] + source[2][::Alpha] + source[3][::Alpha]) / 4; target[1]++; } target[0] += Target->Width; target[1] += Target->Width; } return; } void Image::resample(Image* Target, int Width, int Height, ResampleModes ResampleMode) { if (!Target) return; if ((this->Width < 1) || (this->Height < 1)) return; if ((Width < 1) || (Height < 1)) return; if (Override::EnumOverrides(Override::Resample, 5, this, Target, Width, Height, ResampleMode)) return; Target->resize(Width, Height); switch(ResampleMode) { case -1: case 0: break; case ResampleMode_Linear: case ResampleMode_Linear_Wrap: case ResampleMode_Linear_Clamp: ::ResampleImage_Linear(this, Target); break; case ResampleMode_Bilinear: case ResampleMode_Bilinear_Wrap: case ResampleMode_Bilinear_Clamp: case ResampleMode_Bilinear_High_Quality: if ((Width == (this->Width / 2)) && (Height == (this->Height / 2))) { ::ResampleImage_Half(this, Target); } else if ((Width == (this->Width * 2)) && (Height == (this->Height * 2))) { ::ResampleImage_Double(this, Target); } else { ::ResampleImage_Bilinear(this, Target); } break; } return; } void Image::allocate(Size Width, Size Height) { this->deallocate(); this->dirty(); this->Pitch = 0; if (Override::EnumOverrides(Override::Allocate, 3, this, Width, Height)) { this->setClipRectangle(this->getRectangle()); this->clear(); } else { if ((Width > 0) && (Height > 0)) { this->Data = (Pixel*)vm_alloc(Width * Height * sizeof(Pixel)); this->DataSize = Width * Height * sizeof(Pixel); } if (this->Data) { this->Width = Width; this->Height = Height; } this->unlock(); this->setClipRectangle(this->getRectangle()); this->clear(); } return; } void Image::getPixels(int X, int Y, int W, int H, Pixel* Target) { int sy = 0, xr = 0; Pixel* source; if (Override::EnumOverrides(Override::GetPixels, 6, this, X, Y, W, H, Target)) return; IfLocked(return); for (int cy = 0; cy < H; cy++) { sy = ClipValue(Y + cy, Height - 1); source = this->fast_pointer(X, sy); xr = this->Width - X - 1; for (int cx = 0; cx < W; cx++) { *Target = *source; if (xr) { xr--; source++; } Target++; } } return; } void Image::getPixelsClip(int X, int Y, int W, int H, Pixel* Target) { return; } void Image::allocateDIB(Size Width, Size Height, int DC) { win32::BITMAPINFO bmi; this->deallocate(); _Fill<Byte>(&(bmi), 0, sizeof(win32::BITMAPINFO)); this->DIBDC = DC; bmi.bmiHeader.biSize = sizeof(win32::BITMAPINFOHEADER); bmi.bmiHeader.biWidth = Width; bmi.bmiHeader.biHeight = -Height; bmi.bmiHeader.biBitCount = 32; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biCompression = 0; if ((Width > 0) && (Height > 0)) { this->DIBSection = zeroinit<int>(reinterpret_cast<int>(win32::CreateDIBSection(reinterpret_cast<win32::HDC>(DC), &bmi, 0, reinterpret_cast<void**>(&(this->Data)), Null, 0))); } if (this->Data) { this->Width = Width; this->Height = Height; } this->dirty(); this->Pitch = 0; this->setClipRectangle(this->getRectangle()); this->unlock(); this->clear(); return; } void Image::allocateShared(Size Width, Size Height, unsigned char *ID) { bool isNew = true; this->deallocate(); this->dirty(); this->Pitch = 0; int padding = 12; if ((Width > 0) && (Height > 0)) { this->DataSize = Width * Height * sizeof(Pixel); this->SharedMapping = win32::CreateFileMappingA(((win32::HANDLE)(win32::LONG_PTR)-1), Null, PAGE_READWRITE, 0, this->DataSize + padding, (win32::LPCSTR)ID); if (win32::GetLastError() == ERROR_ALREADY_EXISTS) { isNew = false; } if (this->SharedMapping) { DoubleWord *ptr = reinterpret_cast<DoubleWord*>(win32::MapViewOfFile(this->SharedMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0)); if (ptr) { if (isNew) { *ptr = this->DataSize; ptr++; *ptr = Width; ptr++; *ptr = Height; ptr++; this->Tags = ptr; for (int i = 0; i < Image::TagCount; i++) { *ptr = 0; ptr++; } this->Data = reinterpret_cast<Pixel*>(ptr); } else { DoubleWord sz = *ptr; ptr++; DoubleWord w = *ptr; ptr++; DoubleWord h = *ptr; ptr++; this->Tags = ptr; ptr+=Image::TagCount; if ((sz == this->DataSize) && (w == Width) && (h == Height)) { // valid this->Data = reinterpret_cast<Pixel*>(ptr); } } } } } if (this->Data) { this->Width = Width; this->Height = Height; } else { this->DataSize = 0; this->Tags = this->StaticTags; } this->unlock(); this->setClipRectangle(this->getRectangle()); if (isNew) this->clear(); return; } void Image::optimize() { bool transparentOnly = true, opaqueOnly = true, maskOnly = true, noMask = true, sameAlpha = true, grayscaleOnly = true, solidColor = true; DoubleWord fa = 0; DoubleWord fv = 0; if (!this) return; IfLocked(return); int i = 0, iMax = (this->Width * this->Height); Byte a; Pixel *pCurrent = this->pointer(0,0); if (!pCurrent) return; fa = (*pCurrent)[::Alpha]; fv = pCurrent->V; this->dirty(); // default for (i = 0; i < iMax; i++) { a = ((*pCurrent)[::Alpha]); if ((a == 255) || (a == 0)) { if (a == 0) { opaqueOnly = false; } else { transparentOnly = false; } } else { opaqueOnly = false; maskOnly = false; transparentOnly = false; } if (pCurrent->V == this->MatteColor.V) { noMask = false; } if (fa != a) { sameAlpha = false; } if (fv != pCurrent->V) { solidColor = false; } if (grayscaleOnly) { if (((*pCurrent)[::Red] == (*pCurrent)[::Green]) && ((*pCurrent)[::Green] == (*pCurrent)[::Blue])) { } else { grayscaleOnly = false; } } pCurrent++; } this->OptimizeData.transparentOnly = transparentOnly; this->OptimizeData.opaqueOnly = opaqueOnly; this->OptimizeData.maskOnly = maskOnly; this->OptimizeData.grayscaleOnly = grayscaleOnly; this->OptimizeData.sameAlpha = sameAlpha; this->OptimizeData.noMask = noMask; this->OptimizeData.solidColor = solidColor; } void Image::resize(Size Width, Size Height) { if (this->Unlocked) { Image* OldImage = new Image(); OldImage->steal(this); if ((Width > 0) && (Height > 0)) { this->reallocate(Width, Height); } this->dirty(); this->Pitch = 0; this->setClipRectangle(this->getRectangle()); if (OldImage) { this->clear(); Rectangle oldRect = OldImage->getRectangle(); BlitSimple_Normal(this, OldImage, &oldRect, 0, 0); delete OldImage; } return; } else { // can't preserve hardware images if ((Width > 0) && (Height > 0)) { this->reallocate(Width, Height); } this->dirty(); this->Pitch = 0; this->setClipRectangle(this->getRectangle()); return; } } void Image::slide(Coordinate X, Coordinate Y) { Image* OldImage = new Image(); IfLocked(return); OldImage->steal(this); if ((OldImage->Width > 0) && (OldImage->Height > 0)) { this->reallocate(OldImage->Width, OldImage->Height); } this->dirty(); this->Pitch = 0; this->setClipRectangle(this->getRectangle()); this->clear(); Rectangle oldRect = OldImage->getRectangle(); oldRect.translate(X, Y); BlitSimple_Normal(this, OldImage, &oldRect, 0, 0); delete OldImage; return; } void Image::reallocate(Size Width, Size Height) { this->deallocate(); if (this->DIBSection) { this->allocateDIB(Width, Height, DIBDC); } else { this->allocate(Width, Height); } } void Image::deallocate() { if (this->Unlocked) { this->lock(); } if (Override::EnumOverrides(Override::Deallocate, 1, this)) return; if (this->Data == Null) return; if(this->CoronaImage != 0) { delete this->CoronaImage; this->CoronaImage = Null; this->Data = Null; this->DataSize = 0; this->DIBSection = 0; this->SharedMapping = 0; } else if ((this->DIBSection != 0) && (this->Data != 0)) { win32::DeleteObject(reinterpret_cast<win32::HGDIOBJ>((int)this->DIBSection)); this->Data = Null; this->DataSize = 0; this->DIBSection = 0; this->SharedMapping = 0; this->CoronaImage = Null; } else if ((this->SharedMapping != 0) && (this->Data != 0)) { this->Data -= 3; win32::UnmapViewOfFile(this->Data); this->Data = Null; win32::CloseHandle(this->SharedMapping); this->SharedMapping = 0; this->DataSize = 0; this->DIBSection = 0; this->CoronaImage = Null; } else if ((this->DataSize > 0) && (this->Data != 0)) { vm_dealloc(this->Data); this->CoronaImage = Null; this->DIBSection = 0; this->Data = Null; this->DataSize = 0; this->SharedMapping = 0; } this->Data = Null; this->DataSize = 0; this->dirty(); this->Width = this->Height = 0; this->Pitch = 0; this->ClipRectangle = Rectangle(0,0,0,0); this->Unlocked = false; return; } void Image::setClipRectangle(Rectangle *NewRectangle) { Rectangle rClip; rClip = *NewRectangle; if (ClipRectangle_Image(&rClip, this)) { this->ClipRectangle = rClip; } else { this->ClipRectangle = this->getRectangle(); } return; } void Image::setClipRectangle(Rectangle NewRectangle) { if (ClipRectangle_Image(&NewRectangle, this)) { this->ClipRectangle = NewRectangle; } else { this->ClipRectangle = this->getRectangle(); } return; } void Image::clear() { if (Override::EnumOverrides(Override::Clear, 1, this)) return; IfLocked(return); _Fill<Pixel>(this->Data, Pixel(0), this->Width * this->Height); this->dirty(); return; } void Image::fill(Pixel Value) { if (Override::EnumOverrides(Override::Fill, 2, this, Value)) return; IfLocked(return); _Fill<Pixel>(this->Data, Value, this->Width * this->Height); this->dirty(); return; } void Image::fill(Pixel Value, Rectangle *Rectangle) { FilterSimple_Fill(this, Rectangle, Value); return; } int Image::clipRectangle(Rectangle *Rectangle) { if (Rectangle) return ClipRectangle_ImageClipRect(Rectangle, this); return false; } int Image::clipRectangle(Rectangle *Rectangle, int *CropOffsets) { if (Rectangle) return ClipRectangle_ImageClipRect(Rectangle, this, CropOffsets); return false; } Rectangle Image::getRectangle() { Rectangle r; r.Left = r.Top = 0; r.Width = this->Width; r.Height = this->Height; return r; } void Image::copy(Image *Source) { if (Source) { if (Override::EnumOverrides(Override::Copy, 2, this, Source)) return; ImageLockManager ilSource(lockingMode, Source); if (!ilSource.performUnlock()) return; if ((this->Width != Source->Width) || (this->Height != Source->Height)) { this->reallocate(Source->Width, Source->Height); } IfLocked(return); for (int i = 0; i < this->Height; i++) { _Copy<Byte>(this->fast_pointer(0, i), Source->pointer(0, i), this->Width * 4); } this->optimize(); } } void Image::copy(Image* Source, int X, int Y, int W, int H) { if (Source) { if (Override::EnumOverrides(Override::CopyEx, 6, this, Source, X, Y, W, H)) return; ImageLockManager ilSource = ImageLockManager(lockingMode, Source); if (!ilSource.performUnlock()) return; if ((this->Width != W) || (this->Height != H)) { this->reallocate(W, H); } IfLocked(return); if (X < 0) X = 0; if (Y < 0) Y = 0; if ((W + X) >= (Source->Width)) { W -= (W + X) - Source->Width; } if ((H + Y) >= (Source->Height)) { H -= (H + Y) - Source->Height; } for (int i = 0; i < this->Height; i++) { _Copy<Byte>(this->fast_pointer(0, i), Source->pointer(X, Y + i), W * 4); } this->optimize(); } } void Image::rotate(float Angle) { this->rotate(Angle, SampleRow_Bilinear_Rolloff); return; } // ruthlessly stolen from Sphere #define RotateX(x, y, cr, sr) ((x * cr) - (y * sr)) #define RotateY(x, y, cr, sr) ((x * sr) + (y * cr)) void Image::rotate(float Angle, ScalerFunction *Scaler) { if (Override::EnumOverrides(Override::Rotate, 3, this, Angle, Scaler)) return; IfLocked(return); float ix[2], iy[2]; float tx[2], ty; float xd, yd; int width, height; float xOff, yOff; double aCos, aSin, radians; radians = -Angle * ((22.0 / 7.0) / 180.0); aCos = cos(radians); aSin = sin(radians); { width = this->Width; height = this->Height; float x[4], y[4]; float xNOff, yNOff; xOff = xNOff = 0; yOff = yNOff = 0; x[0] = RotateX(0, 0, aCos, aSin); y[0] = RotateY(0, 0, aCos, aSin); x[1] = RotateX(width, height, aCos, aSin); y[1] = RotateY(width, height, aCos, aSin); x[2] = RotateX(width, 0, aCos, aSin); y[2] = RotateY(width, 0, aCos, aSin); x[3] = RotateX(0, height, aCos, aSin); y[3] = RotateY(0, height, aCos, aSin); xOff = std::max(xOff, x[0]); xNOff = std::min(xNOff, x[0]); xOff = std::max(xOff, x[1]); xNOff = std::min(xNOff, x[1]); xOff = std::max(xOff, x[2]); xNOff = std::min(xNOff, x[2]); xOff = std::max(xOff, x[3]); xNOff = std::min(xNOff, x[3]); yOff = std::max(yOff, y[0]); yNOff = std::min(yNOff, y[0]); yOff = std::max(yOff, y[1]); yNOff = std::min(yNOff, y[1]); yOff = std::max(yOff, y[2]); yNOff = std::min(yNOff, y[2]); yOff = std::max(yOff, y[3]); yNOff = std::min(yNOff, y[3]); xOff = (xOff - xNOff) - (width); yOff = (yOff - yNOff) - (height); width = width + (int)xOff; height = height + (int)yOff; xOff /= 2; yOff /= 2; } if (Angle >= 90) xOff -= 1; if (Angle >= 180) { yOff -= 1; } if (Angle >= 270) { } if ((width <= 0) || (height <= 0)) return; Image* OldImage = new Image(); OldImage->steal(this); if ((OldImage->Width > 0) && (OldImage->Height > 0)) { this->resize(width, height); } else { delete OldImage; return; } for (int y=0; y<height; y++) { // realigns the rotating axis to 0,0 (of a graphical point of view) tx[0] = ((0) - (OldImage->Width/2) - xOff); tx[1] = ((width-1) - (OldImage->Width/2) - xOff); ty = (y - (OldImage->Height/2) - yOff); ix[0] = RotateX(tx[0], ty, aCos, aSin); ix[1] = RotateX(tx[1], ty, aCos, aSin); iy[0] = RotateY(tx[0], ty, aCos, aSin); iy[1] = RotateY(tx[1], ty, aCos, aSin); ix[0] += (OldImage->Width/2); ix[1] += (OldImage->Width/2); iy[0] += (OldImage->Height/2); iy[1] += (OldImage->Height/2); xd = (ix[1] - ix[0]) / width; yd = (iy[1] - iy[0]) / width; Scaler(OldImage, ix[0], iy[0], (int)(ix[0] * 65536.0) % 65536, (int)(iy[0] * 65536.0) % 65536, xd, yd, (int)(xd * 65536.0) % 65536, (int)(yd * 65536.0) % 65536, width, this->pointer(0, y)); } delete OldImage; return; } bool Image::setPixelAA(int xi, int yi, Byte xw, Byte yw, Pixel Color) { if (xi < -1) return false; if (yi < -1) return false; if (xi >= Width) return false; if (yi >= Height) return false; if (Override::EnumOverrides(Override::SetPixelAA, 6, this, xi, yi, (int)xw, (int)yw, Color.V)) return true; IfLocked(return false) Byte w[4]; { w[1] = AlphaLookup(AlphaLookup(xw, yw ^ 0xFF), Color[::Alpha]); w[2] = AlphaLookup(AlphaLookup(xw ^ 0xFF, yw), Color[::Alpha]); w[3] = AlphaLookup(AlphaLookup(xw, yw), Color[::Alpha]); w[0] = Color[::Alpha] - (w[1] + w[2] + w[3]); } Pixel *pColor = &Color; Pixel *p[4]; { p[0] = this->pointer_clip(xi,yi); p[1] = this->pointer_clip(xi+1,yi); p[2] = this->pointer_clip(xi,yi+1); p[3] = this->pointer_clip(xi+1,yi+1); } AlphaLevel *LevelDest, *LevelSource; if ((p[0]) && (w[0])) { LevelDest = AlphaLevelLookup(w[0] ^ 0xFF); LevelSource = AlphaLevelLookup(w[0]); BLENDPIXEL_ALPHA_OPACITY(p[0], p[0], pColor, LevelDest, LevelSource); } if ((p[1]) && (w[1])) { LevelDest = AlphaLevelLookup(w[1] ^ 0xFF); LevelSource = AlphaLevelLookup(w[1]); BLENDPIXEL_ALPHA_OPACITY(p[1], p[1], pColor, LevelDest, LevelSource); } if ((p[2]) && (w[2])) { LevelDest = AlphaLevelLookup(w[2] ^ 0xFF); LevelSource = AlphaLevelLookup(w[2]); BLENDPIXEL_ALPHA_OPACITY(p[2], p[2], pColor, LevelDest, LevelSource); } if ((p[3]) && (w[3])) { LevelDest = AlphaLevelLookup(w[3] ^ 0xFF); LevelSource = AlphaLevelLookup(w[3]); BLENDPIXEL_ALPHA_OPACITY(p[3], p[3], pColor, LevelDest, LevelSource); } return false; } void Image::setBrushPattern(Image *Pattern) { if (!Pattern) return; this->BrushPattern = Pattern; } Image* Image::getBrushPattern() { return this->BrushPattern; } bool Image::lock() { if (Override::EnumOverrides(Override::Lock, 1, this)) return (this->Unlocked == false); this->Unlocked = false; return true; } bool Image::unlock() { if (Override::EnumOverrides(Override::Unlock, 1, this)) return (this->Unlocked == true); if (this->Data != Null) { this->Unlocked = true; return true; } else { this->Unlocked = false; return false; } } ImageLockManager::~ImageLockManager() { if (lockOnDestroy) { if (image) { image->lock(); } } } bool ImageLockManager::performUnlock() { if (this->image) { switch(this->mode) { case AutoUnlock: if (image->Unlocked) { return true; } else { image->unlock(); return image->Unlocked; } break; case AutoUnlockLockWhenDone: if (image->Unlocked) { return true; } else { image->unlock(); this->lockOnDestroy = true; return image->Unlocked; } break; default: return image->Unlocked; break; } } else { return false; } }
[ "kevin@1af785eb-1c5d-444a-bf89-8f912f329d98", "janus@1af785eb-1c5d-444a-bf89-8f912f329d98" ]
[ [ [ 1, 213 ], [ 216, 218 ], [ 222, 241 ], [ 244, 256 ], [ 260, 293 ], [ 295, 297 ], [ 299, 301 ], [ 308, 309 ], [ 311, 328 ], [ 393, 445 ], [ 449, 449 ], [ 453, 453 ], [ 456, 456 ], [ 458, 458 ], [ 480, 522 ], [ 525, 529 ], [ 531, 531 ], [ 533, 535 ], [ 537, 537 ], [ 553, 560 ], [ 562, 603 ], [ 605, 614 ], [ 616, 654 ], [ 656, 659 ], [ 661, 817 ], [ 822, 911 ] ], [ [ 214, 215 ], [ 219, 221 ], [ 242, 243 ], [ 257, 259 ], [ 294, 294 ], [ 298, 298 ], [ 302, 307 ], [ 310, 310 ], [ 329, 392 ], [ 446, 448 ], [ 450, 452 ], [ 454, 455 ], [ 457, 457 ], [ 459, 479 ], [ 523, 524 ], [ 530, 530 ], [ 532, 532 ], [ 536, 536 ], [ 538, 552 ], [ 561, 561 ], [ 604, 604 ], [ 615, 615 ], [ 655, 655 ], [ 660, 660 ], [ 818, 821 ] ] ]
9451c25bbb3ad3260b2139aa906df4cfd48d5786
6bdb3508ed5a220c0d11193df174d8c215eb1fce
/Codes/Halak/IReloadable.h
0bb4b4e4e383bfe6e5f44e0738583825dce8e718
[]
no_license
halak/halak-plusplus
d09ba78640c36c42c30343fb10572c37197cfa46
fea02a5ae52c09ff9da1a491059082a34191cd64
refs/heads/master
2020-07-14T09:57:49.519431
2011-07-09T14:48:07
2011-07-09T14:48:07
66,716,624
0
0
null
null
null
null
UTF-8
C++
false
false
414
h
#pragma once #ifndef __HALAK_RELOADABLE_INTERFACE__ #define __HALAK_RELOADABLE_INTERFACE__ # include <Halak/FWD.h> # include <Halak/URI.h> namespace Halak { class IReloadable { public: virtual ~IReloadable() { } virtual void Reload() = 0; virtual const URI& GetURI() const = 0; }; } #endif
[ [ [ 1, 21 ] ] ]
5edc33332d00b86883829ebdaf1491b1c870eb64
478570cde911b8e8e39046de62d3b5966b850384
/apicompatanamdw/bcdrivers/mw/classicui/uifw/apps/S60_SDK3.0/bctestmisccontrol/inc/bctesteikcontrolgroupcase.h
5a6670417bb8320abf3f54829ded5ee23a019712
[]
no_license
SymbianSource/oss.FCL.sftools.ana.compatanamdw
a6a8abf9ef7ad71021d43b7f2b2076b504d4445e
1169475bbf82ebb763de36686d144336fcf9d93b
refs/heads/master
2020-12-24T12:29:44.646072
2010-11-11T14:03:20
2010-11-11T14:03:20
72,994,432
0
0
null
null
null
null
UTF-8
C++
false
false
2,229
h
/* * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: Declares test bc for eik control group testcase. * */ #ifndef C_CBCTESTEIKCONTROLGROUPCASE_H #define C_CBCTESTEIKCONTROLGROUPCASE_H #include "bctestcase.h" class CBCTestMiscControlContainer; class CCoeControl; /** * test case for various misc control classes */ class CBCTestEikControlGroupCase: public CBCTestCase { public: // constructor and destructor /** * Symbian 2nd static constructor */ static CBCTestEikControlGroupCase* NewL( CBCTestMiscControlContainer* aContainer ); /** * Destructor */ virtual ~CBCTestEikControlGroupCase(); // from CBCTestCase /** * Execute corresponding test functions for UI command * @param aCmd, UI command */ void RunL( TInt aCmd ); protected: // new functions /** * Build autotest script */ void BuildScriptL(); /** * TestFunctionsForEikControlGroupL function */ void TestFunctionsForEikControlGroupL(); /** * TestFunctionsForEikKeyWindowL function */ void TestFunctionsForEikKeyWindowL(); /** * TestFunctionsForEikMoverL function */ void TestFunctionsForEikMoverL(); /** * TestFunctionsForEikToolBarL function */ void TestFunctionsForEikToolBarL(); private: // constructor /** * C++ default constructor */ CBCTestEikControlGroupCase( CBCTestMiscControlContainer* aContainer ); /** * Symbian 2nd constructor */ void ConstructL(); private: // data /** * Pointer to container. * not own */ CBCTestMiscControlContainer* iContainer; }; #endif // C_CBCTESTEIKCONTROLGROUPCASE_H
[ "none@none" ]
[ [ [ 1, 104 ] ] ]
4cf2b5a567e97e753eddff0c0bc0679faf249863
7b4c786d4258ce4421b1e7bcca9011d4eeb50083
/C++Primer中文版(第4版)/第一次-代码集合-20090414/第十五章 面向对象编程/20090308_TextQuery.hpp
a1e22642f1bd4b2d6a0ecda206ad49f4d901ecef
[]
no_license
lzq123218/guoyishi-works
dbfa42a3e2d3bd4a984a5681e4335814657551ef
4e78c8f2e902589c3f06387374024225f52e5a92
refs/heads/master
2021-12-04T11:11:32.639076
2011-05-30T14:12:43
2011-05-30T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
703
hpp
#ifndef TEXTQUERY_H #define TEXTQUERY_H #include <string> #include <vector> #include <set> #include <map> #include <cctype> #include <iostream> #include <fstream> #include <cstring> using namespace std; class TextQuery { public: typedef string::size_type str_size; typedef vector<string>::size_type line_no; void read_file(ifstream &is) { store_file(is); build_map(); } set<line_no> run_query(const string&) const; string text_line(line_no) const; line_no size() const; private: void store_file(ifstream&); void build_map(); vector<string> lines_of_text; map< string, set<line_no> > word_map; static string cleanup_str(const string&); }; #endif
[ "baicaibang@70501136-4834-11de-8855-c187e5f49513" ]
[ [ [ 1, 37 ] ] ]
b2e58e93ab4a24ba9e04c7d1ceac5f0bcb2a154f
d37848c528fe70a9ed6ede4737b93196c855d04e
/ParallelMergeSort/Timers.cpp
10302b578acdc708e74e1f9374eadb01b4cf8e0a
[]
no_license
chuanran/parallel-merge-sort
74991cae0ad398f7d7d021a4bd62b5c16b2bb52e
9c88ef5507aa800fc31d52b1bcd09058f742488c
refs/heads/master
2021-01-10T13:38:33.531256
2011-03-21T13:57:03
2011-03-21T13:57:03
48,393,723
0
0
null
null
null
null
UTF-8
C++
false
false
5,546
cpp
#include "Timers.h" #include "Common.h" #include <cuda_runtime.h> #include "float.h" #include <iostream> #include <fstream> using std::cout; using std::endl; using std::ofstream; Timers* Timers::Allocate(bool isOnHost, int NumberOfBlocks, int Depth) { if (isOnHost) { Timers* timers = new Timers(); timers->CopyToSharedMemory = new float[NumberOfBlocks]; timers->CopyFromSharedMemory = new float[NumberOfBlocks]; timers->MergeOperation = new float[NumberOfBlocks * Depth]; timers->CopyLayer = new float[NumberOfBlocks * Depth]; return timers; } else { Timers* timers = new Timers(); cudaError_t errorCode; errorCode = cudaMalloc<float>(&timers->CopyToSharedMemory, sizeof(float) * NumberOfBlocks); ASSERT(errorCode); errorCode = cudaMalloc<float>(&timers->CopyFromSharedMemory, sizeof(float) * NumberOfBlocks); ASSERT(errorCode); errorCode = cudaMalloc<float>(&timers->MergeOperation, sizeof(float) * NumberOfBlocks * Depth); ASSERT(errorCode); errorCode = cudaMalloc<float>(&timers->CopyLayer, sizeof(float) * NumberOfBlocks * Depth); ASSERT(errorCode); return timers; } } void Timers::Destroy(Timers* timers, bool OnHost) { if (OnHost) { delete[] timers->CopyFromSharedMemory; delete[] timers->CopyToSharedMemory; delete[] timers->MergeOperation; delete[] timers->CopyLayer; delete timers; } else { cudaFree(timers->CopyFromSharedMemory); cudaFree(timers->CopyToSharedMemory); cudaFree(timers->MergeOperation); cudaFree(timers->CopyLayer); delete timers; } } Timers* Timers::CopyToHost(Timers* deviceTimers, int numberOfBlocks, int depth) { Timers* hostTimers = Timers::Allocate(true, numberOfBlocks, depth); cudaError_t errorCode; errorCode = cudaMemcpy(hostTimers->CopyFromSharedMemory, deviceTimers->CopyFromSharedMemory, sizeof(float) * numberOfBlocks, cudaMemcpyDeviceToHost); ASSERT(errorCode); errorCode = cudaMemcpy(hostTimers->CopyToSharedMemory, deviceTimers->CopyFromSharedMemory, sizeof(float) * numberOfBlocks, cudaMemcpyDeviceToHost); ASSERT(errorCode); errorCode = cudaMemcpy(hostTimers->CopyLayer, deviceTimers->CopyLayer, sizeof(float) * numberOfBlocks * depth, cudaMemcpyDeviceToHost); ASSERT(errorCode); errorCode = cudaMemcpy(hostTimers->MergeOperation, deviceTimers->MergeOperation, sizeof(float) * numberOfBlocks * depth, cudaMemcpyDeviceToHost); ASSERT(errorCode); return hostTimers; } float Timers::Average(float d[], int N) { float t = 0; for (int i = 0; i < N; i++) { t *= i; t += d[i]; t /= (i+1); } return t; } float Timers::Max(float d[], int N) { float m = -FLT_MAX; for (int i = 0; i < N; i++) { m = (d[i] > m) ? d[i] : m; } return m; } float Timers::Min(float d[], int N) { float m = FLT_MAX; for (int i = 0; i < N; i++) { m = (d[i] < m) ? d[i] : m; } return m; } void Timers::PrintSummary(Timers* timers, int numberOfBlocks, int depth) { ofstream copyTo("D:\\CopyTo.txt", std::ios::app); ofstream copyFrom("D:\\CopyFrom.txt", std::ios::app); ofstream layerMerge("D:\\LayerMerge.txt", std::ios::app); ofstream layerCopy("D:\\LayerCopy.txt", std::ios::app); float copyFromSharedAverage = Timers::Average(timers->CopyFromSharedMemory, numberOfBlocks); float copyFromSharedMin = Timers::Min(timers->CopyFromSharedMemory, numberOfBlocks); float copyFromSharedMax = Timers::Max(timers->CopyFromSharedMemory, numberOfBlocks); float copyToSharedAverage = Timers::Average(timers->CopyToSharedMemory, numberOfBlocks); float copyToSharedMin = Timers::Min(timers->CopyToSharedMemory, numberOfBlocks); float copyToSharedMax = Timers::Max(timers->CopyToSharedMemory, numberOfBlocks); //cout << "Copy to Shared Memory: [" << copyToSharedMin << ", " << copyToSharedMax << "]. Avg: " << copyToSharedAverage << endl; //cout << "Copy from Shared Memory: [" << copyFromSharedMin << ", " << copyFromSharedMax << "]. Avg: " << copyFromSharedAverage << endl; copyTo << "CopyToSharedMemory" << '\t' << copyToSharedMin << '\t' << copyToSharedMax << '\t' << copyToSharedAverage << endl; copyFrom << "CopyFromSharedMemory" << '\t' << copyFromSharedMin << '\t' << copyFromSharedMax << '\t' << copyFromSharedAverage << endl; for (int i = 0; i < depth; i++) { float* mergePtr = timers->MergeOperation + numberOfBlocks * i; float mergeAverage = Timers::Average(mergePtr, numberOfBlocks); float mergeMin = Timers::Min(mergePtr, numberOfBlocks); float mergeMax = Timers::Max(mergePtr, numberOfBlocks); //cout << "Layer " << i << " Merge: [" << mergeMin << ", " << mergeMax << "]. Avg: " << mergeAverage << endl; layerMerge << "LayerMerge" << '\t' << i << '\t' << mergeMin << '\t' << mergeMax << '\t' << mergeAverage << endl; } for (int i = 0; i < depth; i++) { float* copyPtr = timers->CopyLayer + numberOfBlocks * i; float copyAverage = Timers::Average(copyPtr, numberOfBlocks); float copyMin = Timers::Min(copyPtr, numberOfBlocks); float copyMax = Timers::Max(copyPtr, numberOfBlocks); //cout << "Layer " << i << " Copy: [" << copyMin << ", " << copyMax << "]. Avg: " << copyAverage << endl; layerCopy << "LayerCopy" << '\t' << i << '\t' << copyMin << '\t' << copyMax << '\t' << copyAverage << endl; } copyTo.close(); copyFrom.close(); layerMerge.close(); layerCopy.close(); }
[ "shay.markanty@018be4eb-6b87-c2f0-6375-72b8ba19d606" ]
[ [ [ 1, 171 ] ] ]
ef8aad76dc28c25e6ff283c70ae1b505463ec656
0f973718202109e95fc25240d1cec2d952225732
/Source/Util/BuildOrder.cpp
faa1e3c5d6cff30a708e982addbb9525552f9a36
[]
no_license
RadicalZephyr/fast-ai
eeb9a7bb2357680f63f06c5d49361e274772b456
4f8b9847f6d59f0ec0fcbbdaef8b2c7291be338f
refs/heads/master
2021-01-01T19:47:08.047409
2011-09-28T01:14:48
2011-09-28T01:14:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,011
cpp
#include "BuildOrder.h" void BuildOrderElementOnStartVoid(BuildOrderElement* orderElement, BWAPI::Unit* builderProbe) { return; } void BuildOrderElementOnDoneVoid(BWAPI::Unit* finishedBuilding) { return; } void BuildOrderProbeDefaultProbeIdle(BWAPI::Unit* probe, BWAPI::TilePosition nextSpot) { if(probe->isAttacking() || probe->getOrderTarget()) probe->stop(); else if(!probe->isMoving()) probe->move(BWAPI::Position(nextSpot), true); } void BuildOrder::addOrderElement(BuildOrderElement const & newOrder) { m_buildQueue.push(newOrder); } void BuildOrder::addOptionalElement(BuildOrderElement const& newOrder) { m_optionals.push_back(newOrder); } void BuildOrder::start(BWAPI::Unit* probe) { m_probe = probe; SIGNAL_ON_FRAME(BuildOrder); clearOptionals(); } BWAPI::Unit* BuildOrder::stop() { SIGNAL_OFF_FRAME(BuildOrder); return m_probe; } void BuildOrder::onFrame() { try { if (m_probe->getHitPoints() <= 0) { SIGNAL_OFF_FRAME(BuildOrder); m_onEnd(m_probe); } if (m_probe->isIdle()) { while (!m_buildQueue.front().position.isValid()) { m_buildQueue.pop(); } if (!m_buildQueue.empty() && BWAPI::Broodwar->canBuildHere(m_probe, m_buildQueue.front().position, m_buildQueue.front().type) && m_probe->build(m_buildQueue.front().position, m_buildQueue.front().type)) { m_currentBuildOrder = &m_buildQueue.front(); m_currentBuildOrder->onStart(m_currentBuildOrder, m_probe); m_buildQueue.pop(); clearOptionals(); if (m_buildQueue.empty()) { m_onEnd(m_probe); } } else { for (std::list<BuildOrderElement>::iterator it = m_optionals.begin(); it != m_optionals.end(); it++) { if (BWAPI::Broodwar->canBuildHere(m_probe, (*it).position, (*it).type) && m_probe->build((*it).position, (*it).type)) { m_currentBuildOrder = &(*it); m_currentBuildOrder->onStart(m_currentBuildOrder, m_probe); m_optionals.erase(it); break; } } } } if (m_probe && !m_probe->isConstructing()) { probeIdleFunction(m_probe, m_buildQueue.empty() ? m_probe->getTilePosition() : m_buildQueue.front().position); } } catch (void* e) { SIGNAL_OFF_FRAME(BuildOrder); m_onEnd(m_probe); } } void BuildOrder::clearOptionals() { while (m_buildQueue.front().optional) { m_optionals.push_back(m_buildQueue.front()); m_buildQueue.pop(); } }
[ [ [ 1, 2 ], [ 9, 9 ], [ 14, 17 ], [ 19, 21 ], [ 23, 25 ], [ 29, 32 ], [ 35, 38 ], [ 46, 46 ], [ 51, 51 ], [ 59, 59 ], [ 61, 61 ], [ 77, 77 ], [ 83, 83 ], [ 94, 97 ], [ 103, 103 ] ], [ [ 3, 8 ], [ 10, 13 ], [ 18, 18 ], [ 22, 22 ], [ 26, 28 ], [ 33, 34 ], [ 39, 45 ], [ 47, 50 ], [ 52, 58 ], [ 60, 60 ], [ 62, 76 ], [ 78, 82 ], [ 84, 93 ], [ 98, 102 ] ] ]
8434ba6327cbd0f1c82fc204b0a0022fe4a3542a
d425cf21f2066a0cce2d6e804bf3efbf6dd00c00
/Multiplayer/test_space.cpp
04d9d2a8f60a8ccc05771a94fdf78be3fb605585
[]
no_license
infernuslord/ja2
d5ac783931044e9b9311fc61629eb671f376d064
91f88d470e48e60ebfdb584c23cc9814f620ccee
refs/heads/master
2021-01-02T23:07:58.941216
2011-10-18T09:22:53
2011-10-18T09:22:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,467
cpp
#ifdef PRECOMPILEDHEADERS #include "Tactical All.h" #include "strategic.h" #else #include "builddefines.h" #include "Bullets.h" #include <stdio.h> #include <string.h> #include "wcheck.h" #include "stdlib.h" #include "debug.h" #include "math.h" #include "worlddef.h" #include "worldman.h" #include "renderworld.h" #include "Assignments.h" #include "Soldier Control.h" #include "Animation Control.h" #include "Animation Data.h" #include "Isometric Utils.h" #include "Event Pump.h" #include "Timer Control.h" #include "Render Fun.h" #include "Render Dirty.h" #include "mousesystem.h" #include "interface.h" #include "sysutil.h" #include "FileMan.h" #include "points.h" #include "Random.h" #include "ai.h" #include "Interactive Tiles.h" #include "soldier ani.h" #include "english.h" #include "overhead.h" #include "Soldier Profile.h" #include "Game Clock.h" #include "soldier create.h" #include "Merc Hiring.h" #include "Game Event Hook.h" #include "message.h" #include "strategicmap.h" #include "strategic.h" #include "items.h" #include "Soldier Add.h" #include "History.h" #include "Squads.h" #include "Strategic Merc Handler.h" #include "Dialogue Control.h" #include "Map Screen Interface.h" #include "Map Screen Interface Map.h" #include "screenids.h" #include "jascreens.h" #include "text.h" #include "Merc Contract.h" #include "LaptopSave.h" #include "personnel.h" #include "Auto Resolve.h" #include "Map Screen Interface Bottom.h" #include "Quests.h" #include "GameSettings.h" #endif #include "MessageIdentifiers.h" #include "RakNetworkFactory.h" #include "RakPeerInterface.h" #include "RakNetStatistics.h" #include "RakNetTypes.h" #include "BitStream.h" #include <assert.h> #include <cstdio> #include <cstring> #include <stdlib.h> #include "tactical placement gui.h" #include "connect.h" #include "network.h" #pragma pack(1) #include "text.h" #include "Types.h" #include "connect.h" #include "message.h" #include "Event pump.h" #include "Soldier Init List.h" #include "Overhead.h" #include "weapons.h" #include "Merc Hiring.h" #include "soldier profile.h" #include"laptop.h" #include "florist Order Form.h" #include "prebattle interface.h" #include "teamturns.h" extern INT8 SquadMovementGroups[ ]; #include "test_space.h" #include "soldier control.h" bool ovh_advance; bool ovh_ready; #include "opplist.h" #include "fresh_header.h" //int cnt = 40; #include "game init.h" void test_func2 (void)//now bound to "0" { ScreenMsg( FONT_LTGREEN, MSG_MPSYSTEM, L"test_func2 - function testing ground:" ); SOLDIERTYPE * pSoldier=MercPtrs[ 0 ]; //RemoveOneOpponent( pSoldier ); //SOLDIERTYPE * pSoldier2=MercPtrs[ 127 ]; // ////pSoldier->AdjustNoAPToFinishMove( TRUE ); // ////pSoldier2->bVisible = 1; //ManSeesMan(pSoldier,pSoldier2,pSoldier2->sGridNo,pSoldier2->pathing.bLevel,0,1); /* INT16 sCellX, sCellY; sCellX = CenterX( 22163 ); sCellY = CenterY( 22163 ); pSoldier->EVENT_InternalSetSoldierPosition( sCellX, sCellY ,FALSE, FALSE, FALSE );*/ //SOLDIERTYPE * pSoldier=MercPtrs[ 0 ]; //pSoldier->bLife=0; //SoldierCollapse( pSoldier ); //SoldierTakeDamage( pFirer, ANIM_CROUCH, 1, 100, TAKE_DAMAGE_BLOODLOSS, NOBODY, NOWHERE, 0, TRUE ); //TurnSoldierIntoCorpse( pFirer, FALSE, FALSE ); //SOLDIERTYPE * pSoldier=MercPtrs[ 0 ]; //// //pSoldier->fNoAPToFinishMove = TRUE; // // //fInterfacePanelDirty = DIRTYLEVEL2; ////EVENT_InitNewSoldierAnim(pSoldier,3,0,0); //pSoldier->ubDesiredHeight = ANIM_CROUCH; //SOLDIERTYPE * pSoldier=MercPtrs[ 0 ]; //pSoldier->usAnimState=50; //TurnSoldierIntoCorpse( pSoldier, TRUE, TRUE ); //gTacticalStatus.uiFlags |= SHOW_ALL_MERCS; //BeginTeamTurn (0); ; //gTacticalStatus.ubCurrentTeam = OUR_TEAM; //guiPendingOverrideEvent = LA_ENDUIOUTURNLOCK; //ExitCombatMode(); //fInterfacePanelDirty = DIRTYLEVEL2; //InitPlayerUIBar( FALSE ); //UIHandleLUIEndLock( NULL ); //if( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) ) // ScreenMsg( FONT_LTGREEN, MSG_MPSYSTEM, L"combat turn based" ); //else // ScreenMsg( FONT_LTGREEN, MSG_MPSYSTEM, L"not" ); //SOLDIERTYPE * pSoldier=MercPtrs[ 0 ]; // // if ( ( gAnimControl[ pSoldier->usAnimState ].uiFlags &( ANIM_FIREREADY | ANIM_FIRE ) ) ) // { // ScreenMsg( FONT_LTGREEN, MSG_MPSYSTEM, L"Ready" ); // } // else // ScreenMsg( FONT_LTGREEN, MSG_MPSYSTEM, L"Not" ); ////fInterfacePanelDirty = DIRTYLEVEL2; ////guiPendingOverrideEvent = LU_ENDUILOCK; ////guiPendingOverrideEvent = LA_ENDUIOUTURNLOCK; // // // // ClearIntList(); // //guiPendingOverrideEvent = LU_ENDUILOCK; // guiPendingOverrideEvent = LA_ENDUIOUTURNLOCK; // fInterfacePanelDirty = DIRTYLEVEL2; // // if ( gusSelectedSoldier != NOBODY ) // { // SlideTo( NOWHERE, gusSelectedSoldier, NOBODY ,SETLOCATOR); // MercPtrs[ gusSelectedSoldier ]->DoMercBattleSound( BATTLE_SOUND_ATTN1 ); // } // InitPlayerUIBar( 0 ); //HandleTacticalUI( ); //guiPendingOverrideEvent = LA_BEGINUIOURTURNLOCK; //int n = 0; //for(cnt=40+n ; cnt < 40+5+n ; cnt++) //{ // //QuickCreateProfileMerc( CIV_TEAM, cnt );jk // //RecruitRPC( cnt ); //Sleep(3000); //} //QuickCreateProfileMerc( CIV_TEAM, cnt ); //RecruitRPC( cnt ); //cnt++; //HandleDoorChangeFromGridNo( pSoldier, 18451, FALSE ); //OBJECTTYPE Object; //for (cnt=0; cnt<20;cnt++) //{ //CreateItem( 201, 100, &Object ); // //AutoPlaceObject( pSoldier, &Object, TRUE ); // // //INT16 sCellX, sCellY; ////ConvertGridNoToCellXY( 13576, &sCellX, &sCellY ); // // sCellX = CenterX( 13576 ); // sCellY = CenterY( 13576 ); // // //pSoldier->dXPos = sCellX; // //pSoldier->dYPos = sCellY; // // //pSoldier->sX = (INT16)sCellX; // //pSoldier->sY = (INT16)sCellY; // EVENT_InitNewSoldierAnim( pSoldier, 6, 0, FALSE ); //EVENT_SetSoldierPositionForceDelete( pSoldier, (FLOAT)sCellX, (FLOAT)sCellY ); //HaultSoldierFromSighting( pSoldier, 1 ); //pSoldier->sScheduledStop=7961; //// ////EVENT_SetSoldierPosition( pSoldier, 1140, 1170 ); //AdjustNoAPToFinishMove( pSoldier, TRUE ); //pSoldier->fTurningFromPronePosition = FALSE; // ////HaultSoldierFromSighting( pSoldier, 1 ); //UINT16 usPathData[30]; //usPathData[0]=3; //usPathData[1]=5; //usPathData[2]=7; // //pSoldier->sFinalDestination = 8446; // //pSoldier->usPathDataSize=3; //pSoldier->usPathIndex=0; // //memcpy(pSoldier->usPathingData,usPathData,sizeof(UINT16)*30); //INT16 sNewGridNo; //sNewGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, DirectionInc( (UINT8)pSoldier->usPathingData[ pSoldier->usPathDataSize ] ) ); //pSoldier->sFinalDestination = sNewGridNo; //EVENT_InitNewSoldierAnim( pSoldier, 0, 0, FALSE ); //ovh_advance=true; // // // CHAR16 string[255]; // memcpy(string,TeamTurnString[ 7 ], sizeof( CHAR16) * 255 ); // // CHAR16 name[255]; // mbstowcs( name, CLIENT_NAME, sizeof (char)*30 ); // // CHAR16 full[255]; // swprintf(full, L"%s - '%s'",string,name); //// //// // memcpy( TeamTurnString[ 7 ] , full, sizeof( CHAR16) * 255 ); } //BOOLEAN fMadeCorpse; // SOLDIERTYPE * pSoldier=MercPtrs[ 0 ]; //pSoldier->bLife = 0; // HandleSoldierDeath( pSoldier, &fMadeCorpse ); //guiPendingOverrideEvent = LA_BEGINUIOURTURNLOCK; // //guiPendingOverrideEvent = CA_MERC_SHOOT; // //guiPendingOverrideEvent = G_GETTINGITEM; // //guiPendingOverrideEvent = LU_ON_TERRAIN; // //guiPendingOverrideEvent = ET_ON_TERRAIN; // //guiPendingOverrideEvent = A_CHANGE_TO_MOVE; //HandleTacticalUI( ); //CHAR8 string[60]; // wcscpy( string, "GetVideoObject" ); //sprintf( string, "hello"); /* char szDefault[255]; sprintf(szDefault, "%s","hello"); ScreenMsg( FONT_LTGREEN, MSG_MPSYSTEM, L"%S has connected.",szDefault );*/ //manual overide //manual_overide(); //allow_bullet=1; // //if(1) //{ // stage=0; // ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"1" ); // //FireBulletGivenTarget( MercPtrs[0], 875, 995, 1, 11, -74, 0, 0 ); // // // INT32 iBullet; // BULLET * pBullet; // iBullet = CreateBullet( 0, 0, 0,11 ); // if (iBullet == -1) // { // ScreenMsg( FONT_YELLOW, MSG_MPSYSTEM, L"Failed to create bullet"); // } // pBullet = GetBulletPtr( iBullet ); // //ScreenMsg( FONT_YELLOW, MSG_MPSYSTEM, L"Created Bullet"); // pBullet->fCheckForRoof=0; // pBullet->qIncrX=-917769; // pBullet->qIncrY=-507159; // pBullet->qIncrZ=-537679; // pBullet->sHitBy=-30; // pBullet->ddHorizAngle=-2.5959375990628013; // pBullet->fAimed=1; // pBullet->ubItemStatus=0; // pBullet->qCurrX=1231159031; // pBullet->qCurrY=1221083881; // pBullet->qCurrZ=182963121; // pBullet->iImpact=28; // pBullet->iRange=200; // pBullet->sTargetGridNo=15929; // pBullet->bStartCubesAboveLevelZ=2; // pBullet->bEndCubesAboveLevelZ=0; // pBullet->iDistanceLimit=328; // SOLDIERTYPE * pFirer=MercPtrs[ 0 ]; // //FireBullet( pFirer, pBullet, FALSE ); // if(is_client)send_bullet( pBullet, 11 );//hayden //} //else //{ // stage=1; // ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"0" ); // FireBulletGivenTarget( MercPtrs[0], 875, 995, 1, 11, -74, 0, 0 ); //}
[ "jazz_ja@b41f55df-6250-4c49-8e33-4aa727ad62a1" ]
[ [ [ 1, 403 ] ] ]
782e060e676181c2e979e628f13f360a99593b7d
15732b8e4190ae526dcf99e9ffcee5171ed9bd7e
/SRC/ProtoBase/datapdu.cc
af432505c0a31e8ae097386cf13265346dc47649
[]
no_license
clovermwliu/whutnetsim
d95c07f77330af8cefe50a04b19a2d5cca23e0ae
924f2625898c4f00147e473a05704f7b91dac0c4
refs/heads/master
2021-01-10T13:10:00.678815
2010-04-14T08:38:01
2010-04-14T08:38:01
48,568,805
0
0
null
null
null
null
UTF-8
C++
false
false
9,292
cc
//Copyright (c) 2010, Information Security Institute of Wuhan Universtiy(ISIWhu) //All rights reserved. // //PLEASE READ THIS DOCUMENT CAREFULLY BEFORE UTILIZING THE PROGRAM //BY UTILIZING THIS PROGRAM, YOU AGREE TO BECOME BOUND BY THE TERMS OF //THIS LICENSE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE, DO //NOT USE THIS PROGRAM OR ANY PORTION THEREOF IN ANY FORM OR MANNER. // //This License allows you to: //1. Make copies and distribute copies of the Program's source code provide that any such copy // clearly displays any and all appropriate copyright notices and disclaimer of warranty as set // forth in this License. //2. Modify the original copy or copies of the Program or any portion thereof ("Modification(s)"). // Modifications may be copied and distributed under the terms and conditions as set forth above. // Any and all modified files must be affixed with prominent notices that you have changed the // files and the date that the changes occurred. //Termination: // If at anytime you are unable to comply with any portion of this License you must immediately // cease use of the Program and all distribution activities involving the Program or any portion // thereof. //Statement: // In this program, part of the code is from the GTNetS project, The Georgia Tech Network // Simulator (GTNetS) is a full-featured network simulation environment that allows researchers in // computer networks to study the behavior of moderate to large scale networks, under a variety of // conditions. Our work have great advance due to this project, Thanks to Dr. George F. Riley from // Georgia Tech Research Corporation. Anyone who wants to study the GTNetS can come to its homepage: // http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/ // //File Information: // // //File Name: //File Purpose: //Original Author: //Author Organization: //Construct Data: //Modify Author: //Author Organization: //Modify Data: // Georgia Tech Network Simulator - Data PDU Headers // George F. Riley. Georgia Tech, Spring 2002 #include <iostream> #include <algorithm> #include <string.h> #include "G_debug.h" #include "datapdu.h" #include "packet.h" #include "hex.h" using namespace std; // NullData Methods Data::Data() : size(0), data(nil), msgSize(0), responseSize(0), checksum(0) { DEBUG0((cout << "DataPDU() Constructor" << this << endl)); DBG((Stats::dataPdusAllocated++)); } Data::Data(Size_t s, char* d, Count_t msg, Count_t resp) : size(s), data(nil), msgSize(msg), responseSize(resp) { // Make a copy of the data if (d) { data = new char[s]; memcpy(data, d, s); } DEBUG0((cout << "DataPDU(s,d) Constructor" << this << endl)); DBG((Stats::dataPdusAllocated++)); } Data::Data(const string& s) : size(s.length() + 1), data(strdup(s.c_str())), msgSize(0), responseSize(0), checksum(0) { DEBUG0((cout << "DataPDU(string) Constructor" << this << endl)); } Data::Data(const Data& c) : size(c.Size()), data(0), msgSize(c.msgSize), responseSize(c.responseSize), checksum(c.checksum) { // Copy constructor DEBUG0((cout << "DataPDU() Copy Constructor" << this << endl)); DBG((Stats::dataPdusAllocated++)); if (c.Contents()) { // Has data data = new char[Size()]; memcpy(data, c.Contents(), Size()); } } Data::Data(char* b, Size_t& sz, Packet* p) : data(0) { // Construct from serialized buffer DEBUG0((cout << "DataPDU() Construct from buffer" << this << endl)); Size_t s = 0; b = Serializable::GetSize(b, sz, s); DEBUG0((cout << "data size is " << s << " (" << Hex8(s) << ") " << endl)); sz -= s; b = Construct(b, s); p->PushPDUBottom(this); // Add to packet } Data::~Data() { // destructor DEBUG0((cout << "DataPDU() Destructor " << this << endl)); DBG((Stats::dataPdusDeleted++)); if (data) delete [] data; } // Serialization Size_t Data::SSize() { // Size needed for serialization Size_t r = sizeof(size) + sizeof(msgSize) + sizeof(responseSize); if (data) r += size; // if associated data return r; } char* Data::Serialize(char* b, Size_t& sz) { // Serialize to a buffer b = SerializeToBuffer(b, sz, size); b = SerializeToBuffer(b, sz, msgSize); b = SerializeToBuffer(b, sz, responseSize); b = SerializeToBuffer(b, sz, checksum); DEBUG0((cout << "Serializing msgSize " << msgSize << " responseSize " << responseSize << endl)); if (data) { // Associated data DEBUG0((cout << "Serializing data, size " << size << " sz " << sz << endl)); memcpy(b, data, size); b += size; sz -= size; } return b; } char* Data::Construct(char* b, Size_t& sz) { // Construct from buffer b = ConstructFromBuffer(b, sz, size); b = ConstructFromBuffer(b, sz, msgSize); b = ConstructFromBuffer(b, sz, responseSize); b = ConstructFromBuffer(b, sz, checksum); DEBUG0((cout << "Constructed msgSize " << msgSize << " responseSize " << responseSize << endl)); if (sz && sz >= size) { // Still have remaining size, must be associated data data = new char[size]; memcpy(data, b, size); b += size; sz -= size; } if (sz) { DEBUG0((cout << "HuH? remaining size " << sz << " after data construct" << endl)); sz = 0; // ! Major hack for now till I get this debgged } return b; } PDU* Data::Copy() const { return new Data(*this); }; PDU* Data::CopyS(Size_t s) { // Copy, but with new size (assumes no associated data); return new Data(s, nil, msgSize, responseSize); } PDU* Data::CopySD(Size_t s, char* d) { // Copy, but with new size (assumes no associated data); return new Data(s, d, msgSize, responseSize); } void Data::Clear() { // Remove all pending data if (data) delete [] data; // Free memory if used data = nil; size = 0; } void Data::Add(Size_t s, const char* d) { if (data) { // Data exists, realloc and copy char* n = new char[Size() + s]; memcpy(n, data, Size()); if (d) { // New data specified memcpy(n + Size(), d, s); // Append the new data } else { memset(n + Size(), 0, s); // Apend zeros } delete [] data; // Delete the old data data = n; // Points to new one } else { // No existing data, see if new data if (d) { data = new char[s]; memcpy(data, d, s); } } size += s; } void Data::Remove(Size_t s) { Size_t r = s > Size() ? Size() : s; size -= r; // Reduce size from current if (data) { // data actually exists, realloc and copy if (size) { char* d = new char[Size()]; memcpy(d, data, Size()); delete [] data; data = d; } else { // Zero size, so don't need the data anymore delete [] data; data = nil; } } } Size_t Data::SizeFromSeq(const Seq& f, const Seq& o) { Size_t o1 = OffsetFromSeq(f,o); // Offset to start of unused data return SizeFromOffset(o1); // Amount of data after offset } Size_t Data::SizeFromOffset(Size_t o) { // Find out how much data is available from offset if (o > size) return 0; // No data at requested offset return size - o; // Available data after offset } Size_t Data::OffsetFromSeq(const Seq& f, const Seq& o) { // f is the first sequence number in this data, o is offset sequence if (o < f) return 0; // HuH? Shouldn't happen return o - f; } Data* Data::CopyFromOffset(Size_t s, Size_t o) { // Make a copy of data from starting position "o" for "s" bytes // Return nil if results in zero length data Size_t s1 = min(s, SizeFromOffset(o)); // Insure not beyond end of data if (s1 == 0) return nil; // No data requested if (data) { // Actual data exists, make copy and return it char* d1 = new char[s1]; // Allocate memory for the copy memcpy(d1, &data[o], s1); // Copy the data Data* d = new Data(s1, d1, msgSize, responseSize); // Return copy return d; } else { // No actual data, just return non-data pdu of correct size return new Data(s1, nil, msgSize, responseSize); } } Data* Data::CopyFromSeq(Size_t s, const Seq& f, const Seq& o) { Data* d = CopyFromOffset(s, OffsetFromSeq(f,o)); return d; } // Checksum management void Data::Checksum(Word_t ck) { // Set a checksum for data pdus with no actual data checksum = ck; } Word_t Data::Checksum() { if (!data) return checksum; // Use specified value if no data // Calculate the checksum Word_t* pData = (Word_t*)data; // Calculate the checksum, using 16 bit xor Word_t sum = 0; Size_t s2 = size / 2; for (Size_t i = 0; i < s2; ++i) { sum ^= pData[i]; } if (s2 * 2 < size) { // Odd size, xor in last word sum ^= (data[size-1] << 8); } return sum; }
[ "pengelmer@f37e807c-cba8-11de-937e-2741d7931076" ]
[ [ [ 1, 319 ] ] ]
19b2da2d87a066c9bcf789d06d427254c77a7011
ea800d36d39fd25ba07e8eccd4e8f8a190c55a6f
/Numerical_Integration/.svn/text-base/Romberg_integration.h.svn-base
6babb8a63995f7ac9db070f8de878acb96212b57
[]
no_license
jueqingsizhe66/NumericalCompLib
25047f0361b01d4bf70ffe52be10e75b594b77f1
22f1818b6037feca39cb71390bdb49b339a96801
refs/heads/master
2016-09-06T16:41:14.774303
2011-03-20T19:54:05
2011-03-20T19:54:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,575
#ifndef __ROMBERG_INTEGRATION_H__ #define __ROMBERG_INTEGRATION_H__ /* Basic Information */ // Author: Felix Huang // School: BJUT /* Description */ // Romberg builds a series of sequences with increasing speed to converge, // which can compute integration based on epsilon, the precision provided // Algorithm: // (1) N = 1, given epsilon, h_1 = b - a; // (2) Compute: // T_1(0) = h_1 / 2 * [f(a) + f(b)] // (3) h_2N = 1/2 * h_N // Compute: // T_2N(0) = 1/2 * T_N(0) + h_2N * SUM(1<=k<=N)(f(a + (2*k - 1)*h_2N)) // (4) M=N; N=2*N; k=1 // (5) Compute: // T_M(k) = (4^k * T_2M(k-1) - T_M(k-1)) / (4^k - 1) // (6) if (M==1) goto (7) else M=M/2; ++k; goto (5) // (7) if (|T_1(k) - T_1(k-1)| < epsilon) stop; return T_1(k) else goto (3) /* Includes */ #include <vector> using std::vector; #include "../Basic_Components/basic_widgets.h" #include "../Basic_Components/function.h" /* Declaration */ namespace Felix { // namespace begins here // h_2N = 1/2 * h_N // T_2N = 1/2 * T_N + h_2N * SUM(1<=k<=N)(f(a+(2*k-1)*h_2N)) template <typename FUNC_T> typename FUNC_T::y_type compute_T_2N(const FUNC_T &f, const typename FUNC_T::y_type &T_N, size_t N, typename FUNC_T::x_type h_N, const typename FUNC_T::x_type &a) { h_N *= typename FUNC_T::x_type(0.5); typename FUNC_T::x_type sum(0); for (size_t k = 1; k <= N; ++k) { sum += f(a + typename FUNC_T::x_type (2 * k - 1) * h_N); } return typename FUNC_T::y_type(0.5) * T_N + typename FUNC_T::x_type(h_N * sum); } // T_M(k) = (4^k * T_2M(k-1) - T_M(k-1)) / (4^k - 1) template <typename T> T compute_T_M_new(const T &T_2M, const T &T_M, int k) { T k_exp = pow(T(4), k); return (k_exp * T_2M - T_M) / (k_exp - 1); } template <typename FUNC_T> typename FUNC_T::y_type Romberg_integration(const FUNC_T &f, const typename FUNC_T::x_type &a, const typename FUNC_T::x_type &b, const typename FUNC_T::x_type &epsilon) { size_t N = 1; int k = 0; typename FUNC_T::x_type h_N = b - a; vector<typename FUNC_T::y_type> T_N_seq, T_2N_seq; // compute T_1(0) and T_2(0) T_N_seq.push_back(h_N / typename FUNC_T::x_type(2) * (f(a) + f(b))); T_2N_seq.push_back(compute_T_2N(f, T_N_seq[0], N, h_N, a)); N *= 2; h_N *= typename FUNC_T::x_type(0.5); // compute T_1(1) k = 1; T_2N_seq.push_back(compute_T_M_new(T_2N_seq[0], T_N_seq[0], k)); T_N_seq.push_back(typename FUNC_T::y_type(0)); int limit = 1; while (Felix::abs(T_2N_seq[T_2N_seq.size() - 1] - T_N_seq[T_N_seq.size() - 2]) > epsilon) { // compute T_2N(0) typename FUNC_T::y_type tmp_T_2N = compute_T_2N(f, T_2N_seq[0], N, h_N, a); N *= 2; h_N *= typename FUNC_T::x_type(0.5); // refresh T_N_seq[0] = T_2N_seq[0]; T_2N_seq[0] = tmp_T_2N; for (k = 1; k <= limit; ++k) { typename FUNC_T::y_type tmp_T_N_new = compute_T_M_new(T_2N_seq[k - 1], T_N_seq[k - 1], k); T_N_seq[k] = T_2N_seq[k]; T_2N_seq[k] = tmp_T_N_new; } // deal with the last one T_2N_seq.push_back(compute_T_M_new(T_2N_seq[k - 1], T_N_seq[k - 1], k)); T_N_seq.push_back(typename FUNC_T::y_type(0)); ++limit; } return T_2N_seq[T_N_seq.size() - 1]; } } // namespace ends here #endif /* Test Case & User Manual class F { public: typedef double x_type; typedef double y_type; double operator()(double x) const { return 4.0 / (1.0 + x * x); } }; int main() { std::cout << Felix::Romberg_integration(Felix::make_function(F()), 0.0, 1.0, 0.00001); return 0; } */
[ [ [ 1, 124 ] ] ]
55b777bbbe636f7372446b8933a2d23101ad65d8
c54f5a7cf6de3ed02d2e02cf867470ea48bd9258
/pyobjc/PyOpenGL-2.0.2.01/src/interface/GL.SUN._triangle_list.0106.inc
f9d4cfe2bfc13313f55e27f6c5f2eb9c6ae4fec1
[]
no_license
orestis/pyobjc
01ad0e731fbbe0413c2f5ac2f3e91016749146c6
c30bf50ba29cb562d530e71a9d6c3d8ad75aa230
refs/heads/master
2021-01-22T06:54:35.401551
2009-09-01T09:24:47
2009-09-01T09:24:47
16,895
8
5
null
null
null
null
UTF-8
C++
false
false
67,125
inc
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 1.3.23 * * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make * changes to this file unless you know what you are doing--modify the SWIG * interface file instead. * ----------------------------------------------------------------------------- */ #define SWIGPYTHON #ifndef SWIG_TEMPLATE_DISAMBIGUATOR # if defined(__SUNPRO_CC) # define SWIG_TEMPLATE_DISAMBIGUATOR template # else # define SWIG_TEMPLATE_DISAMBIGUATOR # endif #endif #include <Python.h> /*********************************************************************** * common.swg * * This file contains generic SWIG runtime support for pointer * type checking as well as a few commonly used macros to control * external linkage. * * Author : David Beazley ([email protected]) * * Copyright (c) 1999-2000, The University of Chicago * * This file may be freely redistributed without license or fee provided * this copyright message remains intact. ************************************************************************/ #include <string.h> #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if !defined(STATIC_LINKED) # define SWIGEXPORT(a) __declspec(dllexport) a # else # define SWIGEXPORT(a) a # endif #else # define SWIGEXPORT(a) a #endif #define SWIGRUNTIME(x) static x #ifndef SWIGINLINE #if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) # define SWIGINLINE inline #else # define SWIGINLINE #endif #endif /* This should only be incremented when either the layout of swig_type_info changes, or for whatever reason, the runtime changes incompatibly */ #define SWIG_RUNTIME_VERSION "1" /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ #ifdef SWIG_TYPE_TABLE #define SWIG_QUOTE_STRING(x) #x #define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) #define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) #else #define SWIG_TYPE_TABLE_NAME #endif #ifdef __cplusplus extern "C" { #endif typedef void *(*swig_converter_func)(void *); typedef struct swig_type_info *(*swig_dycast_func)(void **); typedef struct swig_type_info { const char *name; swig_converter_func converter; const char *str; void *clientdata; swig_dycast_func dcast; struct swig_type_info *next; struct swig_type_info *prev; } swig_type_info; static swig_type_info *swig_type_list = 0; static swig_type_info **swig_type_list_handle = &swig_type_list; /* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class<int>" == "Class<int >", etc. Return 0 when the two name types are equivalent, as in strncmp, but skipping ' '. */ static int SWIG_TypeNameComp(const char *f1, const char *l1, const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; if (*f1 != *f2) return *f1 - *f2; } return (l1 - f1) - (l2 - f2); } /* Check type equivalence in a name list like <name1>|<name2>|... */ static int SWIG_TypeEquiv(const char *nb, const char *tb) { int equiv = 0; const char* te = tb + strlen(tb); const char* ne = nb; while (!equiv && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0; if (*ne) ++ne; } return equiv; } /* Register a type mapping with the type-checking */ static swig_type_info * SWIG_TypeRegister(swig_type_info *ti) { swig_type_info *tc, *head, *ret, *next; /* Check to see if this type has already been registered */ tc = *swig_type_list_handle; while (tc) { /* check simple type equivalence */ int typeequiv = (strcmp(tc->name, ti->name) == 0); /* check full type equivalence, resolving typedefs */ if (!typeequiv) { /* only if tc is not a typedef (no '|' on it) */ if (tc->str && ti->str && !strstr(tc->str,"|")) { typeequiv = SWIG_TypeEquiv(ti->str,tc->str); } } if (typeequiv) { /* Already exists in the table. Just add additional types to the list */ if (ti->clientdata) tc->clientdata = ti->clientdata; head = tc; next = tc->next; goto l1; } tc = tc->prev; } head = ti; next = 0; /* Place in list */ ti->prev = *swig_type_list_handle; *swig_type_list_handle = ti; /* Build linked lists */ l1: ret = head; tc = ti + 1; /* Patch up the rest of the links */ while (tc->name) { head->next = tc; tc->prev = head; head = tc; tc++; } if (next) next->prev = head; head->next = next; return ret; } /* Check the typename */ static swig_type_info * SWIG_TypeCheck(char *c, swig_type_info *ty) { swig_type_info *s; if (!ty) return 0; /* Void pointer */ s = ty->next; /* First element always just a name */ do { if (strcmp(s->name,c) == 0) { if (s == ty->next) return s; /* Move s to the top of the linked list */ s->prev->next = s->next; if (s->next) { s->next->prev = s->prev; } /* Insert s as second element in the list */ s->next = ty->next; if (ty->next) ty->next->prev = s; ty->next = s; s->prev = ty; return s; } s = s->next; } while (s && (s != ty->next)); return 0; } /* Cast a pointer up an inheritance hierarchy */ static SWIGINLINE void * SWIG_TypeCast(swig_type_info *ty, void *ptr) { if ((!ty) || (!ty->converter)) return ptr; return (*ty->converter)(ptr); } /* Dynamic pointer casting. Down an inheritance hierarchy */ static swig_type_info * SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { swig_type_info *lastty = ty; if (!ty || !ty->dcast) return ty; while (ty && (ty->dcast)) { ty = (*ty->dcast)(ptr); if (ty) lastty = ty; } return lastty; } /* Return the name associated with this type */ static SWIGINLINE const char * SWIG_TypeName(const swig_type_info *ty) { return ty->name; } /* Return the pretty name associated with this type, that is an unmangled type name in a form presentable to the user. */ static const char * SWIG_TypePrettyName(const swig_type_info *type) { /* The "str" field contains the equivalent pretty names of the type, separated by vertical-bar characters. We choose to print the last name, as it is often (?) the most specific. */ if (type->str != NULL) { const char *last_name = type->str; const char *s; for (s = type->str; *s; s++) if (*s == '|') last_name = s+1; return last_name; } else return type->name; } /* Search for a swig_type_info structure */ static swig_type_info * SWIG_TypeQuery(const char *name) { swig_type_info *ty = *swig_type_list_handle; while (ty) { if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty; if (ty->name && (strcmp(name,ty->name) == 0)) return ty; ty = ty->prev; } return 0; } /* Set the clientdata field for a type */ static void SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { swig_type_info *tc, *equiv; if (ti->clientdata) return; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; equiv = ti->next; while (equiv) { if (!equiv->converter) { tc = *swig_type_list_handle; while (tc) { if ((strcmp(tc->name, equiv->name) == 0)) SWIG_TypeClientData(tc,clientdata); tc = tc->prev; } } equiv = equiv->next; } } /* Pack binary data into a string */ static char * SWIG_PackData(char *c, void *ptr, size_t sz) { static char hex[17] = "0123456789abcdef"; unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; register unsigned char uu; for (; u != eu; ++u) { uu = *u; *(c++) = hex[(uu & 0xf0) >> 4]; *(c++) = hex[uu & 0xf]; } return c; } /* Unpack binary data from a string */ static char * SWIG_UnpackData(char *c, void *ptr, size_t sz) { register unsigned char uu = 0; register int d; unsigned char *u = (unsigned char *) ptr; const unsigned char *eu = u + sz; for (; u != eu; ++u) { d = *(c++); if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); *u = uu; } return c; } /* This function will propagate the clientdata field of type to * any new swig_type_info structures that have been added into the list * of equivalent types. It is like calling * SWIG_TypeClientData(type, clientdata) a second time. */ static void SWIG_PropagateClientData(swig_type_info *type) { swig_type_info *equiv = type->next; swig_type_info *tc; if (!type->clientdata) return; while (equiv) { if (!equiv->converter) { tc = *swig_type_list_handle; while (tc) { if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata) SWIG_TypeClientData(tc, type->clientdata); tc = tc->prev; } } equiv = equiv->next; } } #ifdef __cplusplus } #endif /* ----------------------------------------------------------------------------- * SWIG API. Portion that goes into the runtime * ----------------------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * for internal method declarations * ----------------------------------------------------------------------------- */ #ifndef SWIGINTERN #define SWIGINTERN static #endif #ifndef SWIGINTERNSHORT #ifdef __cplusplus #define SWIGINTERNSHORT static inline #else /* C case */ #define SWIGINTERNSHORT static #endif /* __cplusplus */ #endif /* Common SWIG API */ #define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags) #define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags) #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) /* Python-specific SWIG API */ #define SWIG_newvarlink() SWIG_Python_newvarlink() #define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) #define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) /* Exception handling in wrappers */ #define SWIG_fail goto fail #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) #define SWIG_append_errmsg(msg) SWIG_Python_AddErrMesg(msg,0) #define SWIG_preppend_errmsg(msg) SWIG_Python_AddErrMesg(msg,1) #define SWIG_type_error(type,obj) SWIG_Python_TypeError(type,obj) #define SWIG_null_ref(type) SWIG_Python_NullRef(type) /* Contract support */ #define SWIG_contract_assert(expr, msg) \ if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else /* ----------------------------------------------------------------------------- * Constant declarations * ----------------------------------------------------------------------------- */ /* Constant Types */ #define SWIG_PY_INT 1 #define SWIG_PY_FLOAT 2 #define SWIG_PY_STRING 3 #define SWIG_PY_POINTER 4 #define SWIG_PY_BINARY 5 /* Constant information structure */ typedef struct swig_const_info { int type; char *name; long lvalue; double dvalue; void *pvalue; swig_type_info **ptype; } swig_const_info; /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ /* Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent C/C++ pointers in the python side. Very useful for debugging, but not always safe. */ #if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES) # define SWIG_COBJECT_TYPES #endif /* Flags for pointer conversion */ #define SWIG_POINTER_EXCEPTION 0x1 #define SWIG_POINTER_DISOWN 0x2 /* ----------------------------------------------------------------------------- * Alloc. memory flags * ----------------------------------------------------------------------------- */ #define SWIG_OLDOBJ 1 #define SWIG_NEWOBJ SWIG_OLDOBJ + 1 #define SWIG_PYSTR SWIG_NEWOBJ + 1 #ifdef __cplusplus } #endif /*********************************************************************** * pyrun.swg * * This file contains the runtime support for Python modules * and includes code for managing global variables and pointer * type checking. * * Author : David Beazley ([email protected]) ************************************************************************/ #ifdef __cplusplus extern "C" { #endif /* ----------------------------------------------------------------------------- * global variable support code. * ----------------------------------------------------------------------------- */ typedef struct swig_globalvar { char *name; /* Name of global variable */ PyObject *(*get_attr)(); /* Return the current value */ int (*set_attr)(PyObject *); /* Set the value */ struct swig_globalvar *next; } swig_globalvar; typedef struct swig_varlinkobject { PyObject_HEAD swig_globalvar *vars; } swig_varlinkobject; static PyObject * swig_varlink_repr(swig_varlinkobject *v) { v = v; return PyString_FromString("<Global variables>"); } static int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { swig_globalvar *var; flags = flags; fprintf(fp,"Global variables { "); for (var = v->vars; var; var=var->next) { fprintf(fp,"%s", var->name); if (var->next) fprintf(fp,", "); } fprintf(fp," }\n"); return 0; } static PyObject * swig_varlink_getattr(swig_varlinkobject *v, char *n) { swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { return (*var->get_attr)(); } var = var->next; } PyErr_SetString(PyExc_NameError,"Unknown C global variable"); return NULL; } static int swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { swig_globalvar *var = v->vars; while (var) { if (strcmp(var->name,n) == 0) { return (*var->set_attr)(p); } var = var->next; } PyErr_SetString(PyExc_NameError,"Unknown C global variable"); return 1; } static PyTypeObject varlinktype = { PyObject_HEAD_INIT(0) 0, /* Number of items in variable part (ob_size) */ (char *)"swigvarlink", /* Type name (tp_name) */ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ 0, /* Itemsize (tp_itemsize) */ 0, /* Deallocator (tp_dealloc) */ (printfunc) swig_varlink_print, /* Print (tp_print) */ (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ 0, /* tp_compare */ (reprfunc) swig_varlink_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ 0, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ #endif #ifdef COUNT_ALLOCS /* these must be last */ 0, /* tp_alloc */ 0, /* tp_free */ 0, /* tp_maxalloc */ 0, /* tp_next */ #endif }; /* Create a variable linking object for use later */ static PyObject * SWIG_Python_newvarlink(void) { swig_varlinkobject *result = 0; result = PyMem_NEW(swig_varlinkobject,1); varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */ result->ob_type = &varlinktype; result->vars = 0; result->ob_refcnt = 0; Py_XINCREF((PyObject *) result); return ((PyObject*) result); } static void SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v; swig_globalvar *gv; v= (swig_varlinkobject *) p; gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); gv->name = (char *) malloc(strlen(name)+1); strcpy(gv->name,name); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; v->vars = gv; } /* ----------------------------------------------------------------------------- * errors manipulation * ----------------------------------------------------------------------------- */ static void SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { if (!PyCObject_Check(obj)) { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); const char *cstr = str ? PyString_AsString(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); } Py_DECREF(str); return; } } else { const char *otype = (char *) PyCObject_GetDesc(obj); if (otype) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PyCObject(%s)' is received", type, otype); return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); } else { PyErr_Format(PyExc_TypeError, "unexpected type is received"); } } static SWIGINLINE void SWIG_Python_NullRef(const char *type) { if (type) { PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type); } else { PyErr_Format(PyExc_TypeError, "null reference was received"); } } static int SWIG_Python_AddErrMesg(const char* mesg, int infront) { if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); } else { PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); } Py_DECREF(old_str); } return 1; } else { return 0; } } static int SWIG_Python_ArgFail(int argnum) { if (PyErr_Occurred()) { /* add information about failing argument */ char mesg[256]; sprintf(mesg, "argument number %d:", argnum); return SWIG_Python_AddErrMesg(mesg, 1); } else { return 0; } } /* ----------------------------------------------------------------------------- * pointers/data manipulation * ----------------------------------------------------------------------------- */ /* Convert a pointer value */ static int SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { swig_type_info *tc; char *c = 0; static PyObject *SWIG_this = 0; int newref = 0; PyObject *pyobj = 0; void *vptr; if (!obj) return 0; if (obj == Py_None) { *ptr = 0; return 0; } #ifdef SWIG_COBJECT_TYPES if (!(PyCObject_Check(obj))) { if (!SWIG_this) SWIG_this = PyString_FromString("this"); pyobj = obj; obj = PyObject_GetAttr(obj,SWIG_this); newref = 1; if (!obj) goto type_error; if (!PyCObject_Check(obj)) { Py_DECREF(obj); goto type_error; } } vptr = PyCObject_AsVoidPtr(obj); c = (char *) PyCObject_GetDesc(obj); if (newref) Py_DECREF(obj); goto type_check; #else if (!(PyString_Check(obj))) { if (!SWIG_this) SWIG_this = PyString_FromString("this"); pyobj = obj; obj = PyObject_GetAttr(obj,SWIG_this); newref = 1; if (!obj) goto type_error; if (!PyString_Check(obj)) { Py_DECREF(obj); goto type_error; } } c = PyString_AS_STRING(obj); /* Pointer values must start with leading underscore */ if (*c != '_') { if (strcmp(c,"NULL") == 0) { if (newref) { Py_DECREF(obj); } *ptr = (void *) 0; return 0; } else { if (newref) { Py_DECREF(obj); } goto type_error; } } c++; c = SWIG_UnpackData(c,&vptr,sizeof(void *)); if (newref) { Py_DECREF(obj); } #endif type_check: if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; *ptr = SWIG_TypeCast(tc,vptr); } if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); } return 0; type_error: PyErr_Clear(); if (pyobj && !obj) { obj = pyobj; if (PyCFunction_Check(obj)) { /* here we get the method pointer for callbacks */ char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); c = doc ? strstr(doc, "swig_ptr: ") : 0; if (c) { c += 10; if (*c == '_') { c++; c = SWIG_UnpackData(c,&vptr,sizeof(void *)); goto type_check; } } } } if (flags & SWIG_POINTER_EXCEPTION) { if (ty) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); } else { SWIG_Python_TypeError("C/C++ pointer", obj); } } return -1; } /* Convert a pointer value, signal an exception on a type mismatch */ static void * SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); if (flags & SWIG_POINTER_EXCEPTION) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } } return result; } /* Convert a packed value value */ static int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) { swig_type_info *tc; char *c = 0; if ((!obj) || (!PyString_Check(obj))) goto type_error; c = PyString_AS_STRING(obj); /* Pointer values must start with leading underscore */ if (*c != '_') goto type_error; c++; c = SWIG_UnpackData(c,ptr,sz); if (ty) { tc = SWIG_TypeCheck(c,ty); if (!tc) goto type_error; } return 0; type_error: PyErr_Clear(); if (flags & SWIG_POINTER_EXCEPTION) { if (ty) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); } else { SWIG_Python_TypeError("C/C++ packed data", obj); } } return -1; } /* Create a new pointer string */ static char * SWIG_Python_PointerStr(char *buff, void *ptr, const char *name, size_t bsz) { char *r = buff; if ((2*sizeof(void *) + 2) > bsz) return 0; *(r++) = '_'; r = SWIG_PackData(r,&ptr,sizeof(void *)); if (strlen(name) + 1 > (bsz - (r - buff))) return 0; strcpy(r,name); return buff; } /* Create a new pointer object */ static PyObject * SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { PyObject *robj; if (!ptr) { Py_INCREF(Py_None); return Py_None; } #ifdef SWIG_COBJECT_TYPES robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL); #else { char result[1024]; SWIG_Python_PointerStr(result, ptr, type->name, 1024); robj = PyString_FromString(result); } #endif if (!robj || (robj == Py_None)) return robj; if (type->clientdata) { PyObject *inst; PyObject *args = Py_BuildValue((char*)"(O)", robj); Py_DECREF(robj); inst = PyObject_CallObject((PyObject *) type->clientdata, args); Py_DECREF(args); if (inst) { if (own) { PyObject_SetAttrString(inst,(char*)"thisown",Py_True); } robj = inst; } } return robj; } static PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { char result[1024]; char *r = result; if ((2*sz + 2 + strlen(type->name)) > 1024) return 0; *(r++) = '_'; r = SWIG_PackData(r,ptr,sz); strcpy(r,type->name); return PyString_FromString(result); } /* ----------------------------------------------------------------------------- * constants/methods manipulation * ----------------------------------------------------------------------------- */ /* Install Constants */ static void SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { int i; PyObject *obj; for (i = 0; constants[i].type; i++) { switch(constants[i].type) { case SWIG_PY_INT: obj = PyInt_FromLong(constants[i].lvalue); break; case SWIG_PY_FLOAT: obj = PyFloat_FromDouble(constants[i].dvalue); break; case SWIG_PY_STRING: if (constants[i].pvalue) { obj = PyString_FromString((char *) constants[i].pvalue); } else { Py_INCREF(Py_None); obj = Py_None; } break; case SWIG_PY_POINTER: obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); break; case SWIG_PY_BINARY: obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); break; default: obj = 0; break; } if (obj) { PyDict_SetItemString(d,constants[i].name,obj); Py_DECREF(obj); } } } /* Fix SwigMethods to carry the callback ptrs when needed */ static void SWIG_Python_FixMethods(PyMethodDef *methods, swig_const_info *const_table, swig_type_info **types, swig_type_info **types_initial) { int i; for (i = 0; methods[i].ml_name; ++i) { char *c = methods[i].ml_doc; if (c && (c = strstr(c, "swig_ptr: "))) { int j; swig_const_info *ci = 0; char *name = c + 10; for (j = 0; const_table[j].type; j++) { if (strncmp(const_table[j].name, name, strlen(const_table[j].name)) == 0) { ci = &(const_table[j]); break; } } if (ci) { size_t shift = (ci->ptype) - types; swig_type_info *ty = types_initial[shift]; size_t ldoc = (c - methods[i].ml_doc); size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; char *ndoc = (char*)malloc(ldoc + lptr + 10); char *buff = ndoc; void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue: (void *)(ci->lvalue); strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); buff += 10; SWIG_Python_PointerStr(buff, ptr, ty->name, lptr); methods[i].ml_doc = ndoc; } } } } /* ----------------------------------------------------------------------------- * Lookup type pointer * ----------------------------------------------------------------------------- */ #if PY_MAJOR_VERSION < 2 /* PyModule_AddObject function was introduced in Python 2.0. The following function is copied out of Python/modsupport.c in python version 2.3.4 */ static int PyModule_AddObject(PyObject *m, char *name, PyObject *o) { PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); return -1; } if (!o) { PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); return -1; } dict = PyModule_GetDict(m); if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", PyModule_GetName(m)); return -1; } if (PyDict_SetItemString(dict, name, o)) return -1; Py_DECREF(o); return 0; } #endif static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} /* Sentinel */ }; static void SWIG_Python_LookupTypePointer(swig_type_info ***type_list_handle) { PyObject *module, *pointer; void *type_pointer; /* first check if module already created */ type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); if (type_pointer) { *type_list_handle = (swig_type_info **) type_pointer; } else { PyErr_Clear(); /* create a new module and variable */ module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); pointer = PyCObject_FromVoidPtr((void *) (*type_list_handle), NULL); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } } } #ifdef __cplusplus } #endif /* -------- TYPES TABLE (BEGIN) -------- */ #define SWIGTYPE_p_GLsizei swig_types[0] #define SWIGTYPE_p_GLshort swig_types[1] #define SWIGTYPE_p_GLboolean swig_types[2] #define SWIGTYPE_size_t swig_types[3] #define SWIGTYPE_p_GLushort swig_types[4] #define SWIGTYPE_p_GLenum swig_types[5] #define SWIGTYPE_p_GLvoid swig_types[6] #define SWIGTYPE_p_GLint swig_types[7] #define SWIGTYPE_p_char swig_types[8] #define SWIGTYPE_p_GLclampd swig_types[9] #define SWIGTYPE_p_GLclampf swig_types[10] #define SWIGTYPE_p_GLuint swig_types[11] #define SWIGTYPE_ptrdiff_t swig_types[12] #define SWIGTYPE_p_GLbyte swig_types[13] #define SWIGTYPE_p_GLbitfield swig_types[14] #define SWIGTYPE_p_GLfloat swig_types[15] #define SWIGTYPE_p_GLubyte swig_types[16] #define SWIGTYPE_p_GLdouble swig_types[17] static swig_type_info *swig_types[19]; /* -------- TYPES TABLE (END) -------- */ /*----------------------------------------------- @(target):= _triangle_list.so ------------------------------------------------*/ #define SWIG_init init_triangle_list #define SWIG_name "_triangle_list" /** * * GL.SUN.triangle_list Module for PyOpenGL * * Date: May 2001 * * Authors: Tarn Weisner Burton <[email protected]> * ***/ SWIGINTERN PyObject * SWIG_FromCharPtr(const char* cptr) { if (cptr) { size_t size = strlen(cptr); if (size > INT_MAX) { return SWIG_NewPointerObj((char*)(cptr), SWIG_TypeQuery("char *"), 0); } else { if (size != 0) { return PyString_FromStringAndSize(cptr, size); } else { return PyString_FromString(cptr); } } } Py_INCREF(Py_None); return Py_None; } /*@C:\\bin\\SWIG-1.3.23\\Lib\\python\\pymacros.swg,66,SWIG_define@*/ #define SWIG_From_int PyInt_FromLong /*@@*/ GLint PyOpenGL_round(double x) { if (x >= 0) { return (GLint) (x+0.5); } else { return (GLint) (x-0.5); } } int __PyObject_AsArray_Size(PyObject* x); #ifdef NUMERIC #define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : ((PyArray_Check(x)) ? PyArray_Size(x) : __PyObject_AsArray_Size(x))) #else /* NUMERIC */ #define _PyObject_AsArray_Size(x) ((x == Py_None) ? 0 : __PyObject_AsArray_Size(x)) #endif /* NUMERIC */ #define _PyObject_As(NAME, BASE) BASE* _PyObject_As##NAME(PyObject* source, PyObject** temp, int* len); #define _PyObject_AsArray_Cleanup(target, temp) if (temp) Py_XDECREF(temp); else PyMem_Del(target) _PyObject_As(FloatArray, float) _PyObject_As(DoubleArray, double) _PyObject_As(CharArray, signed char) _PyObject_As(UnsignedCharArray, unsigned char) _PyObject_As(ShortArray, short) _PyObject_As(UnsignedShortArray, unsigned short) _PyObject_As(IntArray, int) _PyObject_As(UnsignedIntArray, unsigned int) void* _PyObject_AsArray(GLenum type, PyObject* source, PyObject** temp, int* len); #define PyErr_XPrint() if (PyErr_Occurred()) PyErr_Print() #if HAS_DYNAMIC_EXT #define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\ RET PROC_NAME PROTO\ {\ typedef RET (APIENTRY *proc_##PROC_NAME) PROTO;\ proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\ if (proc) return proc CALL;\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ return ERROR_RET;\ } #define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\ void PROC_NAME PROTO\ {\ typedef void (APIENTRY *proc_##PROC_NAME) PROTO;\ proc_##PROC_NAME proc = (proc_##PROC_NAME)GL_GetProcAddress(#PROC_NAME);\ if (proc) proc CALL;\ else {\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ }\ } #else #define DECLARE_EXT(PROC_NAME, RET, ERROR_RET, PROTO, CALL)\ RET PROC_NAME PROTO\ {\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ return ERROR_RET;\ } #define DECLARE_VOID_EXT(PROC_NAME, PROTO, CALL)\ void PROC_NAME PROTO\ {\ PyErr_SetGLErrorMessage( GL_INVALID_OPERATION, "Dynamic function loading not implemented/supported on this platform" );\ } #endif #define _PyTuple_From(NAME, BASE) PyObject* _PyTuple_From##NAME(int len, BASE* data); _PyTuple_From(UnsignedCharArray, unsigned char) _PyTuple_From(CharArray, signed char) _PyTuple_From(UnsignedShortArray, unsigned short) _PyTuple_From(ShortArray, short) _PyTuple_From(UnsignedIntArray, unsigned int) _PyTuple_From(IntArray, int) _PyTuple_From(FloatArray, float) _PyTuple_From(DoubleArray, double) #define _PyObject_From(NAME, BASE) PyObject* _PyObject_From##NAME(int nd, int* dims, BASE* data, int own); _PyObject_From(UnsignedCharArray, unsigned char) _PyObject_From(CharArray, signed char) _PyObject_From(UnsignedShortArray, unsigned short) _PyObject_From(ShortArray, short) _PyObject_From(UnsignedIntArray, unsigned int) _PyObject_From(IntArray, int) _PyObject_From(FloatArray, float) _PyObject_From(DoubleArray, double) PyObject* _PyObject_FromArray(GLenum type, int nd, int *dims, void* data, int own); void* SetupPixelRead(int rank, GLenum format, GLenum type, int *dims); void SetupPixelWrite(int rank); void* SetupRawPixelRead(GLenum format, GLenum type, int n, const int *dims, int* size); void* _PyObject_AsPointer(PyObject* x); /* The following line causes a warning on linux and cygwin The function is defined in interface_utils.c, which is linked to each extension module. For some reason, though, this declaration doesn't get recognised as a declaration prototype for that function. */ void init_util(); typedef void *PTR; typedef struct { void (*_decrement)(void* pointer); void (*_decrementPointer)(GLenum pname); int (*_incrementLock)(void *pointer); int (*_incrementPointerLock)(GLenum pname); void (*_acquire)(void* pointer); void (*_acquirePointer)(GLenum pname); #if HAS_DYNAMIC_EXT PTR (*GL_GetProcAddress)(const char* name); #endif int (*InitExtension)(const char *name, const char** procs); PyObject *_GLerror; PyObject *_GLUerror; } util_API; static util_API *_util_API = NULL; #define decrementLock(x) (*_util_API)._decrement(x) #define decrementPointerLock(x) (*_util_API)._decrementPointer(x) #define incrementLock(x) (*_util_API)._incrementLock(x) #define incrementPointerLock(x) (*_util_API)._incrementPointerLock(x) #define acquire(x) (*_util_API)._acquire(x) #define acquirePointer(x) (*_util_API)._acquirePointer(x) #define GLerror (*_util_API)._GLerror #define GLUerror (*_util_API)._GLUerror #if HAS_DYNAMIC_EXT #define GL_GetProcAddress(x) (*_util_API).GL_GetProcAddress(x) #endif #define InitExtension(x, y) (*_util_API).InitExtension(x, (const char**)y) #define PyErr_SetGLerror(code) PyErr_SetObject(GLerror, Py_BuildValue("is", code, gluErrorString(code))); #define PyErr_SetGLUerror(code) PyErr_SetObject(GLUerror, Py_BuildValue("is", code, gluErrorString(code))); int _PyObject_Dimension(PyObject* x, int rank); #define ERROR_MSG_SEP ", " #define ERROR_MSG_SEP_LEN 2 int GLErrOccurred() { if (PyErr_Occurred()) return 1; if (CurrentContextIsValid()) { GLenum error, *errors = NULL; char *msg = NULL; const char *this_msg; int count = 0; error = glGetError(); while (error != GL_NO_ERROR) { this_msg = gluErrorString(error); if (count) { msg = realloc(msg, (strlen(msg) + strlen(this_msg) + ERROR_MSG_SEP_LEN + 1)*sizeof(char)); strcat(msg, ERROR_MSG_SEP); strcat(msg, this_msg); errors = realloc(errors, (count + 1)*sizeof(GLenum)); } else { msg = malloc((strlen(this_msg) + 1)*sizeof(char)); strcpy(msg, this_msg); errors = malloc(sizeof(GLenum)); } errors[count++] = error; error = glGetError(); } if (count) { PyErr_SetObject(GLerror, Py_BuildValue("Os", _PyTuple_FromIntArray(count, (int*)errors), msg)); free(errors); free(msg); return 1; } } return 0; } void PyErr_SetGLErrorMessage( int id, char * message ) { /* set a GLerror with an ID and string message This tries pretty hard to look just like a regular error as produced by GLErrOccurred()'s formatter, save that there's only the single error being reported. Using id 0 is probably best for any future use where there isn't a good match for the exception description in the error-enumeration set. */ PyObject * args = NULL; args = Py_BuildValue( "(i)s", id, message ); if (args) { PyErr_SetObject( GLerror, args ); Py_XDECREF( args ); } else { PyErr_SetGLerror(id); } } /* fix for SUN headers */ #if defined(GL_TRIANGLE_LIST_SUN) && !defined(GL_SUN_triangle_list) #define GL_SUN_triangle_list 1 #endif #if !EXT_DEFINES_PROTO || !defined(GL_SUN_triangle_list) DECLARE_VOID_EXT(glReplacementCodeuiSUN, (GLuint code), (code)) DECLARE_VOID_EXT(glReplacementCodeusSUN, (GLushort code), (code)) DECLARE_VOID_EXT(glReplacementCodeubSUN, (GLubyte code), (code)) DECLARE_VOID_EXT(glReplacementCodeuivSUN, (const GLuint* code), (code)) DECLARE_VOID_EXT(glReplacementCodeusvSUN, (const GLushort* code), (code)) DECLARE_VOID_EXT(glReplacementCodeubvSUN, (const GLubyte* code), (code)) DECLARE_VOID_EXT(glReplacementCodePointerSUN, (GLenum type, GLsizei stride, const void *buffer), (type, stride, buffer)) #endif static char *proc_names[] = { #if !EXT_DEFINES_PROTO || !defined(GL_SUN_triangle_list) "glReplacementCodeuiSUN", "glReplacementCodeusSUN", "glReplacementCodeubSUN", "glReplacementCodeuivSUN", "glReplacementCodeusvSUN", "glReplacementCodeubvSUN", "glReplacementCodePointerSUN", #endif NULL }; #define glInitTriangleListSUN() InitExtension("GL_SUN_triangle_list", proc_names) static char _doc_glInitTriangleListSUN[] = "glInitTriangleListSUN() -> bool"; #include <limits.h> SWIGINTERNSHORT int SWIG_CheckUnsignedLongInRange(unsigned long value, unsigned long max_value, const char *errmsg) { if (value > max_value) { if (errmsg) { PyErr_Format(PyExc_OverflowError, "value %lu is greater than '%s' minimum %lu", value, errmsg, max_value); } return 0; } return 1; } SWIGINTERN int SWIG_AsVal_unsigned_SS_long(PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { long v = PyInt_AS_LONG(obj); if (v >= 0) { if (val) *val = v; return 1; } } if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return 1; } else { if (!val) PyErr_Clear(); return 0; } } if (val) { SWIG_type_error("unsigned long", obj); } return 0; } #if UINT_MAX != ULONG_MAX SWIGINTERN int SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val) { const char* errmsg = val ? "unsigned int" : (char*)0; unsigned long v; if (SWIG_AsVal_unsigned_SS_long(obj, &v)) { if (SWIG_CheckUnsignedLongInRange(v, INT_MAX, errmsg)) { if (val) *val = (unsigned int)(v); return 1; } } else { PyErr_Clear(); } if (val) { SWIG_type_error(errmsg, obj); } return 0; } #else SWIGINTERNSHORT unsigned int SWIG_AsVal_unsigned_SS_int(PyObject *obj, unsigned int *val) { return SWIG_AsVal_unsigned_SS_long(obj,(unsigned long *)val); } #endif SWIGINTERNSHORT unsigned int SWIG_As_unsigned_SS_int(PyObject* obj) { unsigned int v; if (!SWIG_AsVal_unsigned_SS_int(obj, &v)) { /* this is needed to make valgrind/purify happier. */ memset((void*)&v, 0, sizeof(unsigned int)); } return v; } SWIGINTERNSHORT int SWIG_Check_unsigned_SS_int(PyObject* obj) { return SWIG_AsVal_unsigned_SS_int(obj, (unsigned int*)0); } static char _doc_glReplacementCodeuiSUN[] = "glReplacementCodeuiSUN(code) -> None"; SWIGINTERN int SWIG_AsVal_unsigned_SS_short(PyObject *obj, unsigned short *val) { const char* errmsg = val ? "unsigned short" : (char*)0; unsigned long v; if (SWIG_AsVal_unsigned_SS_long(obj, &v)) { if (SWIG_CheckUnsignedLongInRange(v, USHRT_MAX, errmsg)) { if (val) *val = (unsigned short)(v); return 1; } else { return 0; } } else { PyErr_Clear(); } if (val) { SWIG_type_error(errmsg, obj); } return 0; } SWIGINTERNSHORT unsigned short SWIG_As_unsigned_SS_short(PyObject* obj) { unsigned short v; if (!SWIG_AsVal_unsigned_SS_short(obj, &v)) { /* this is needed to make valgrind/purify happier. */ memset((void*)&v, 0, sizeof(unsigned short)); } return v; } SWIGINTERNSHORT int SWIG_Check_unsigned_SS_short(PyObject* obj) { return SWIG_AsVal_unsigned_SS_short(obj, (unsigned short*)0); } static char _doc_glReplacementCodeusSUN[] = "glReplacementCodeusSUN(code) -> None"; SWIGINTERN int SWIG_AsVal_unsigned_SS_char(PyObject *obj, unsigned char *val) { const char* errmsg = val ? "unsigned char" : (char*)0; unsigned long v; if (SWIG_AsVal_unsigned_SS_long(obj, &v)) { if (SWIG_CheckUnsignedLongInRange(v, UCHAR_MAX,errmsg)) { if (val) *val = (unsigned char)(v); return 1; } else { return 0; } } else { PyErr_Clear(); } if (val) { SWIG_type_error(errmsg, obj); } return 0; } SWIGINTERNSHORT int SWIG_Check_unsigned_SS_char(PyObject* obj) { return SWIG_AsVal_unsigned_SS_char(obj, (unsigned char*)0); } static char _doc_glReplacementCodeubSUN[] = "glReplacementCodeubSUN(code) -> None"; static char _doc_glReplacementCodeuivSUN[] = "glReplacementCodeuivSUN(code) -> None"; static char _doc_glReplacementCodeusvSUN[] = "glReplacementCodeusvSUN(code) -> None"; static char _doc_glReplacementCodeubvSUN[] = "glReplacementCodeubvSUN(code) -> None"; #ifndef GL_SUN_triangle_list #define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 #endif void _glReplacementCodePointerSUN(GLenum type, GLsizei stride, GLvoid *pointer) { decrementPointerLock(GL_REPLACEMENT_CODE_ARRAY_SUN); acquire(pointer); glReplacementCodePointerSUN(type, stride, pointer); } SWIGINTERN int SWIG_CheckLongInRange(long value, long min_value, long max_value, const char *errmsg) { if (value < min_value) { if (errmsg) { PyErr_Format(PyExc_OverflowError, "value %ld is less than '%s' minimum %ld", value, errmsg, min_value); } return 0; } else if (value > max_value) { if (errmsg) { PyErr_Format(PyExc_OverflowError, "value %ld is greater than '%s' maximum %ld", value, errmsg, max_value); } return 0; } return 1; } SWIGINTERN int SWIG_AsVal_long(PyObject * obj, long* val) { if (PyInt_Check(obj)) { if (val) *val = PyInt_AS_LONG(obj); return 1; } if (PyLong_Check(obj)) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { if (val) *val = v; return 1; } else { if (!val) PyErr_Clear(); return 0; } } if (val) { SWIG_type_error("long", obj); } return 0; } #if INT_MAX != LONG_MAX SWIGINTERN int SWIG_AsVal_int(PyObject *obj, int *val) { const char* errmsg = val ? "int" : (char*)0; long v; if (SWIG_AsVal_long(obj, &v)) { if (SWIG_CheckLongInRange(v, INT_MIN,INT_MAX, errmsg)) { if (val) *val = (int)(v); return 1; } else { return 0; } } else { PyErr_Clear(); } if (val) { SWIG_type_error(errmsg, obj); } return 0; } #else SWIGINTERNSHORT int SWIG_AsVal_int(PyObject *obj, int *val) { return SWIG_AsVal_long(obj,(long*)val); } #endif SWIGINTERNSHORT int SWIG_Check_int(PyObject* obj) { return SWIG_AsVal_int(obj, (int*)0); } static char _doc_glReplacementCodePointerSUN[] = "glReplacementCodePointerSUN(type, stride, pointer) -> None"; static char _doc_glReplacementCodePointerubSUN[] = "glReplacementCodePointerubSUN(pointer) -> None"; static char _doc_glReplacementCodePointerusSUN[] = "glReplacementCodePointerusSUN(pointer) -> None"; static char _doc_glReplacementCodePointeruiSUN[] = "glReplacementCodePointeruiSUN(pointer) -> None"; PyObject *__info() { if (glInitTriangleListSUN()) { PyObject *info = PyList_New(0); return info; } Py_INCREF(Py_None); return Py_None; } #ifdef __cplusplus extern "C" { #endif static PyObject *_wrap_glInitTriangleListSUN(PyObject *self, PyObject *args) { PyObject *resultobj; int result; if(!PyArg_ParseTuple(args,(char *)":glInitTriangleListSUN")) goto fail; { result = (int)glInitTriangleListSUN(); if (GLErrOccurred()) { return NULL; } } { resultobj = SWIG_From_int((int)(result)); } return resultobj; fail: return NULL; } static PyObject *_wrap_glReplacementCodeuiSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLuint arg1 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:glReplacementCodeuiSUN",&obj0)) goto fail; { arg1 = (GLuint)(SWIG_As_unsigned_SS_int(obj0)); if (SWIG_arg_fail(1)) SWIG_fail; } { glReplacementCodeuiSUN(arg1); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_glReplacementCodeusSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLushort arg1 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:glReplacementCodeusSUN",&obj0)) goto fail; { arg1 = (GLushort)(SWIG_As_unsigned_SS_short(obj0)); if (SWIG_arg_fail(1)) SWIG_fail; } { glReplacementCodeusSUN(arg1); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_glReplacementCodeubSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLubyte arg1 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:glReplacementCodeubSUN",&obj0)) goto fail; { if (PyInt_Check(obj0) || PyLong_Check(obj0)) { arg1= (GLubyte)(PyInt_AsLong( obj0 )); } else if (PyString_Check (obj0)) { /* what is a GLshort's size? */ arg1= (GLubyte) PyString_AsString(obj0)[0]; } } { glReplacementCodeubSUN(arg1); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; return resultobj; fail: return NULL; } static PyObject *_wrap_glReplacementCodeuivSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLuint *arg1 = (GLuint *) 0 ; PyObject *temp_1 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:glReplacementCodeuivSUN",&obj0)) goto fail; { arg1 = _PyObject_AsUnsignedIntArray(obj0, &temp_1, NULL); } { glReplacementCodeuivSUN((GLuint const *)arg1); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; { _PyObject_AsArray_Cleanup(arg1, temp_1); } return resultobj; fail: { _PyObject_AsArray_Cleanup(arg1, temp_1); } return NULL; } static PyObject *_wrap_glReplacementCodeusvSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLushort *arg1 = (GLushort *) 0 ; PyObject *temp_1 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:glReplacementCodeusvSUN",&obj0)) goto fail; { arg1 = _PyObject_AsUnsignedShortArray(obj0, &temp_1, NULL); } { glReplacementCodeusvSUN((GLushort const *)arg1); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; { _PyObject_AsArray_Cleanup(arg1, temp_1); } return resultobj; fail: { _PyObject_AsArray_Cleanup(arg1, temp_1); } return NULL; } static PyObject *_wrap_glReplacementCodeubvSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLubyte *arg1 = (GLubyte *) 0 ; PyObject *temp_1 ; PyObject * obj0 = 0 ; if(!PyArg_ParseTuple(args,(char *)"O:glReplacementCodeubvSUN",&obj0)) goto fail; { arg1 = _PyObject_AsUnsignedCharArray(obj0, &temp_1, NULL); } { glReplacementCodeubvSUN((GLubyte const *)arg1); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; { _PyObject_AsArray_Cleanup(arg1, temp_1); } return resultobj; fail: { _PyObject_AsArray_Cleanup(arg1, temp_1); } return NULL; } static PyObject *_wrap_glReplacementCodePointerSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLenum arg1 ; GLsizei arg2 ; void *arg3 = (void *) 0 ; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; PyObject * obj2 = 0 ; if(!PyArg_ParseTuple(args,(char *)"OOO:glReplacementCodePointerSUN",&obj0,&obj1,&obj2)) goto fail; { arg1 = (GLenum)(SWIG_As_unsigned_SS_int(obj0)); if (SWIG_arg_fail(1)) SWIG_fail; } { if (PyInt_Check(obj1) || PyLong_Check(obj1)) { arg2= (GLsizei)(PyInt_AsLong( obj1 )); } else if (PyFloat_Check(obj1)) { double arg2_temp_float; arg2_temp_float = PyFloat_AsDouble(obj1); if (arg2_temp_float >= (INT_MAX-0.5)) { PyErr_SetString(PyExc_ValueError, "Value too large to be converted to a size measurement"); return NULL; } else if (arg2_temp_float <= -0.5) { PyErr_SetString(PyExc_ValueError, "Value less than 0, cannot be converted to a size measurement"); return NULL; } arg2 = (GLsizei) PyOpenGL_round( arg2_temp_float ); } } { arg3 = _PyObject_AsPointer(obj2); } { _glReplacementCodePointerSUN(arg1,arg2,arg3); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; { } return resultobj; fail: { } return NULL; } static PyObject *_wrap_glReplacementCodePointerubSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLenum arg1 ; GLsizei arg2 ; GLubyte *arg3 = (GLubyte *) 0 ; PyObject * obj0 = 0 ; { arg1 = GL_UNSIGNED_BYTE; } { arg2 = 0; } if(!PyArg_ParseTuple(args,(char *)"O:glReplacementCodePointerubSUN",&obj0)) goto fail; { arg3 = _PyObject_AsUnsignedCharArray(obj0, NULL, NULL); } { _glReplacementCodePointerSUN(arg1,arg2,arg3); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; { } return resultobj; fail: { } return NULL; } static PyObject *_wrap_glReplacementCodePointerusSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLenum arg1 ; GLsizei arg2 ; GLushort *arg3 = (GLushort *) 0 ; PyObject * obj0 = 0 ; { arg1 = GL_UNSIGNED_SHORT; } { arg2 = 0; } if(!PyArg_ParseTuple(args,(char *)"O:glReplacementCodePointerusSUN",&obj0)) goto fail; { arg3 = _PyObject_AsUnsignedShortArray(obj0, NULL, NULL); } { _glReplacementCodePointerSUN(arg1,arg2,arg3); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; { } return resultobj; fail: { } return NULL; } static PyObject *_wrap_glReplacementCodePointeruiSUN(PyObject *self, PyObject *args) { PyObject *resultobj; GLenum arg1 ; GLsizei arg2 ; GLuint *arg3 = (GLuint *) 0 ; PyObject * obj0 = 0 ; { arg1 = GL_UNSIGNED_INT; } { arg2 = 0; } if(!PyArg_ParseTuple(args,(char *)"O:glReplacementCodePointeruiSUN",&obj0)) goto fail; { arg3 = _PyObject_AsUnsignedIntArray(obj0, NULL, NULL); } { _glReplacementCodePointerSUN(arg1,arg2,arg3); if (PyErr_Occurred()) { return NULL; } } Py_INCREF(Py_None); resultobj = Py_None; { } return resultobj; fail: { } return NULL; } static PyObject *_wrap___info(PyObject *self, PyObject *args) { PyObject *resultobj; PyObject *result; if(!PyArg_ParseTuple(args,(char *)":__info")) goto fail; { result = (PyObject *)__info(); if (PyErr_Occurred()) { return NULL; } } { resultobj= result; } return resultobj; fail: return NULL; } static PyMethodDef SwigMethods[] = { { (char *)"glInitTriangleListSUN", _wrap_glInitTriangleListSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodeuiSUN", _wrap_glReplacementCodeuiSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodeusSUN", _wrap_glReplacementCodeusSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodeubSUN", _wrap_glReplacementCodeubSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodeuivSUN", _wrap_glReplacementCodeuivSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodeusvSUN", _wrap_glReplacementCodeusvSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodeubvSUN", _wrap_glReplacementCodeubvSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodePointerSUN", _wrap_glReplacementCodePointerSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodePointerubSUN", _wrap_glReplacementCodePointerubSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodePointerusSUN", _wrap_glReplacementCodePointerusSUN, METH_VARARGS, NULL}, { (char *)"glReplacementCodePointeruiSUN", _wrap_glReplacementCodePointeruiSUN, METH_VARARGS, NULL}, { (char *)"__info", _wrap___info, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ static swig_type_info _swigt__p_GLsizei[] = {{"_p_GLsizei", 0, "int *|GLsizei *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLshort[] = {{"_p_GLshort", 0, "short *|GLshort *", 0, 0, 0, 0},{"_p_GLshort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLboolean[] = {{"_p_GLboolean", 0, "unsigned char *|GLboolean *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__size_t[] = {{"_size_t", 0, "size_t", 0, 0, 0, 0},{"_size_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLushort[] = {{"_p_GLushort", 0, "unsigned short *|GLushort *", 0, 0, 0, 0},{"_p_GLushort", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLenum[] = {{"_p_GLenum", 0, "unsigned int *|GLenum *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLvoid[] = {{"_p_GLvoid", 0, "void *|GLvoid *", 0, 0, 0, 0},{"_p_GLvoid", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLint[] = {{"_p_GLint", 0, "int *|GLint *", 0, 0, 0, 0},{"_p_GLint", 0, 0, 0, 0, 0, 0},{"_p_GLsizei", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_char[] = {{"_p_char", 0, "char *", 0, 0, 0, 0},{"_p_char", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLclampd[] = {{"_p_GLclampd", 0, "double *|GLclampd *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLclampf[] = {{"_p_GLclampf", 0, "float *|GLclampf *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLuint[] = {{"_p_GLuint", 0, "unsigned int *|GLuint *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__ptrdiff_t[] = {{"_ptrdiff_t", 0, "ptrdiff_t", 0, 0, 0, 0},{"_ptrdiff_t", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLbyte[] = {{"_p_GLbyte", 0, "signed char *|GLbyte *", 0, 0, 0, 0},{"_p_GLbyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLbitfield[] = {{"_p_GLbitfield", 0, "unsigned int *|GLbitfield *", 0, 0, 0, 0},{"_p_GLuint", 0, 0, 0, 0, 0, 0},{"_p_GLbitfield", 0, 0, 0, 0, 0, 0},{"_p_GLenum", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLfloat[] = {{"_p_GLfloat", 0, "float *|GLfloat *", 0, 0, 0, 0},{"_p_GLfloat", 0, 0, 0, 0, 0, 0},{"_p_GLclampf", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLubyte[] = {{"_p_GLubyte", 0, "unsigned char *|GLubyte *", 0, 0, 0, 0},{"_p_GLboolean", 0, 0, 0, 0, 0, 0},{"_p_GLubyte", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info _swigt__p_GLdouble[] = {{"_p_GLdouble", 0, "double *|GLdouble *", 0, 0, 0, 0},{"_p_GLclampd", 0, 0, 0, 0, 0, 0},{"_p_GLdouble", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}}; static swig_type_info *swig_types_initial[] = { _swigt__p_GLsizei, _swigt__p_GLshort, _swigt__p_GLboolean, _swigt__size_t, _swigt__p_GLushort, _swigt__p_GLenum, _swigt__p_GLvoid, _swigt__p_GLint, _swigt__p_char, _swigt__p_GLclampd, _swigt__p_GLclampf, _swigt__p_GLuint, _swigt__ptrdiff_t, _swigt__p_GLbyte, _swigt__p_GLbitfield, _swigt__p_GLfloat, _swigt__p_GLubyte, _swigt__p_GLdouble, 0 }; /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ static swig_const_info swig_const_table[] = { { SWIG_PY_POINTER, (char*)"__version__", 0, 0, (void *)"1.21.6.1", &SWIGTYPE_p_char}, { SWIG_PY_POINTER, (char*)"__date__", 0, 0, (void *)"2004/11/14 23:19:05", &SWIGTYPE_p_char}, { SWIG_PY_POINTER, (char*)"__author__", 0, 0, (void *)"Tarn Weisner Burton <[email protected]>", &SWIGTYPE_p_char}, { SWIG_PY_POINTER, (char*)"__doc__", 0, 0, (void *)"http://oss.sgi.com/projects/ogl-sample/registry/SUN/triangle_list.txt", &SWIGTYPE_p_char}, {0, 0, 0, 0.0, 0, 0}}; #ifdef __cplusplus } #endif #ifdef SWIG_LINK_RUNTIME #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # if defined(_MSC_VER) || defined(__GNUC__) # define SWIGIMPORT(a) extern a # else # if defined(__BORLANDC__) # define SWIGIMPORT(a) a _export # else # define SWIGIMPORT(a) a # endif # endif #else # define SWIGIMPORT(a) a #endif #ifdef __cplusplus extern "C" #endif SWIGEXPORT(void *) SWIG_ReturnGlobalTypeList(void *); #endif #ifdef __cplusplus extern "C" #endif SWIGEXPORT(void) SWIG_init(void) { static PyObject *SWIG_globals = 0; static int typeinit = 0; PyObject *m, *d; int i; if (!SWIG_globals) SWIG_globals = SWIG_newvarlink(); /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_types_initial); m = Py_InitModule((char *) SWIG_name, SwigMethods); d = PyModule_GetDict(m); if (!typeinit) { #ifdef SWIG_LINK_RUNTIME swig_type_list_handle = (swig_type_info **) SWIG_ReturnGlobalTypeList(swig_type_list_handle); #else # ifndef SWIG_STATIC_RUNTIME SWIG_Python_LookupTypePointer(&swig_type_list_handle); # endif #endif for (i = 0; swig_types_initial[i]; i++) { swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]); } typeinit = 1; } SWIG_InstallConstants(d,swig_const_table); PyDict_SetItemString(d,"__version__", SWIG_FromCharPtr("1.21.6.1")); PyDict_SetItemString(d,"__date__", SWIG_FromCharPtr("2004/11/14 23:19:05")); { PyDict_SetItemString(d,"__api_version__", SWIG_From_int((int)(262))); } PyDict_SetItemString(d,"__author__", SWIG_FromCharPtr("Tarn Weisner Burton <[email protected]>")); PyDict_SetItemString(d,"__doc__", SWIG_FromCharPtr("http://oss.sgi.com/projects/ogl-sample/registry/SUN/triangle_list.txt")); #ifdef NUMERIC PyArray_API = NULL; import_array(); init_util(); PyErr_Clear(); #endif { PyObject *util = PyImport_ImportModule("OpenGL.GL._GL__init__"); if (util) { PyObject *api_object = PyDict_GetItemString(PyModule_GetDict(util), "_util_API"); if (PyCObject_Check(api_object)) _util_API = (util_API*)PyCObject_AsVoidPtr(api_object); } } { PyDict_SetItemString(d,"GL_TRIANGLE_LIST_SUN", SWIG_From_int((int)(0x81D7))); } { PyDict_SetItemString(d,"GL_REPLACEMENT_CODE_SUN", SWIG_From_int((int)(0x81D8))); } { PyDict_SetItemString(d,"GL_RESTART_SUN", SWIG_From_int((int)(0x01))); } { PyDict_SetItemString(d,"GL_REPLACE_MIDDLE_SUN", SWIG_From_int((int)(0x02))); } { PyDict_SetItemString(d,"GL_REPLACE_OLDEST_SUN", SWIG_From_int((int)(0x03))); } { PyDict_SetItemString(d,"GL_REPLACEMENT_CODE_ARRAY_SUN", SWIG_From_int((int)(0x85C0))); } { PyDict_SetItemString(d,"GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN", SWIG_From_int((int)(0x85C1))); } { PyDict_SetItemString(d,"GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN", SWIG_From_int((int)(0x85C2))); } { PyDict_SetItemString(d,"GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN", SWIG_From_int((int)(0x85C3))); } { PyDict_SetItemString(d,"GL_R1UI_V3F_SUN", SWIG_From_int((int)(0x85C4))); } { PyDict_SetItemString(d,"GL_R1UI_C4UB_V3F_SUN", SWIG_From_int((int)(0x85C5))); } { PyDict_SetItemString(d,"GL_R1UI_C3F_V3F_SUN", SWIG_From_int((int)(0x85C6))); } { PyDict_SetItemString(d,"GL_R1UI_N3F_V3F_SUN", SWIG_From_int((int)(0x85C7))); } { PyDict_SetItemString(d,"GL_R1UI_C4F_N3F_V3F_SUN", SWIG_From_int((int)(0x85C8))); } { PyDict_SetItemString(d,"GL_R1UI_T2F_V3F_SUN", SWIG_From_int((int)(0x85C9))); } { PyDict_SetItemString(d,"GL_R1UI_T2F_N3F_V3F_SUN", SWIG_From_int((int)(0x85CA))); } { PyDict_SetItemString(d,"GL_R1UI_T2F_C4F_N3F_V3F_SUN", SWIG_From_int((int)(0x85CB))); } }
[ "ronaldoussoren@f55f28a5-9edb-0310-a011-a803cfcd5d25" ]
[ [ [ 1, 2295 ] ] ]
ccd2d0971eea0bac4a809dc1d32cef24e2f2090a
e2e49023f5a82922cb9b134e93ae926ed69675a1
/tools/utilcpp/include/utilcpp/Singleton.hpp
878fdc2bfef41ce147b5f15198543f7d3f6a98df
[]
no_license
invy/mjklaim-freewindows
c93c867e93f0e2fe1d33f207306c0b9538ac61d6
30de8e3dfcde4e81a57e9059dfaf54c98cc1135b
refs/heads/master
2021-01-10T10:21:51.579762
2011-12-12T18:56:43
2011-12-12T18:56:43
54,794,395
1
0
null
null
null
null
UTF-8
C++
false
false
1,278
hpp
#ifndef HGUARD_UTILCPP_SINGLETON_HPP #define HGUARD_UTILCPP_SINGLETON_HPP #pragma once #include <boost/noncopyable.hpp> #include "utilcpp/Assert.hpp" namespace util { template<typename T> class Singleton : boost::noncopyable { static T* ms_singleton; protected: Singleton() { UTILCPP_ASSERT_NULL( ms_singleton ); ms_singleton = static_cast<T*>(this); } ~Singleton() { UTILCPP_ASSERT_NOT_NULL( ms_singleton ); ms_singleton = nullptr; } public: static inline void create() { UTILCPP_ASSERT_NULL( ms_singleton ); new T(); } static inline T& instance() { UTILCPP_ASSERT_NOT_NULL( ms_singleton ); return *ms_singleton; } static inline void destroy() { UTILCPP_ASSERT_NOT_NULL( ms_singleton ); delete ms_singleton; ms_singleton = nullptr; } static inline bool isValid() { return ms_singleton; } }; template <typename T> T* Singleton <T>::ms_singleton = nullptr; } #endif
[ "klaim@localhost" ]
[ [ [ 1, 63 ] ] ]
f4dd19936f4af8f05588eefbebfce84f938ce052
9c62af23e0a1faea5aaa8dd328ba1d82688823a5
/rl/tags/techdemo2/engine/core/include/PhysicalThing.h
12435a263a876a2607d2646355499840b45cbb7f
[ "ClArtistic", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jacmoe/dsa-hl-svn
55b05b6f28b0b8b216eac7b0f9eedf650d116f85
97798e1f54df9d5785fb206c7165cd011c611560
refs/heads/master
2021-04-22T12:07:43.389214
2009-11-27T22:01:03
2009-11-27T22:01:03
null
0
0
null
null
null
null
ISO-8859-3
C++
false
false
4,626
h
/* This source file is part of Rastullahs Lockenpracht. * Copyright (C) 2003-2005 Team Pantheon. http://www.team-pantheon.de * * This program is free software; you can redistribute it and/or modify * it under the terms of the Clarified Artistic License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * Clarified Artistic License for more details. * * You should have received a copy of the Clarified Artistic License * along with this program; if not you can get it here * http://www.jpaulmorrison.com/fbp/artistic2.htm. */ #ifndef __PhysicalThing_H__ #define __PhysicalThing_H__ #include "CorePrerequisites.h" #include "PhysicsContactListener.h" #include "PhysicsManager.h" #include <OgreNewt.h> namespace rl { class Actor; class MeshObject; class _RlCoreExport PhysicalThing { public: PhysicalThing( PhysicsManager::GeometryTypes geomType, PhysicalObject* po, Real mass, bool hullModifier = false); /// Klasse Polymorph machen, damit SWIG glücklich ist. virtual ~PhysicalThing(); Ogre::Vector3 getPosition() const; void setPosition(const Ogre::Vector3& pos); void setPosition(Ogre::Real x, Ogre::Real y, Ogre::Real z); Ogre::Quaternion getOrientation() const; void setOrientation(const Ogre::Quaternion& orienation); void setOrientation(Ogre::Real w, Ogre::Real x, Ogre::Real y, Ogre::Real z); void setVelocity(const Ogre::Vector3& velocity); Ogre::Vector3 getVelocity(); // Sets the vector, that will always point up. void setUpConstraint(const Ogre::Vector3& upVector = Ogre::Vector3::UNIT_Y); Ogre::Vector3 getUpConstraint() const; void clearUpConstraint(); // Sets whether to use default gravity, or override it with its own void setGravityOverride(bool override, const Ogre::Vector3& gravity); void setGravityOverride(bool override, Ogre::Real x = 0.0f, Ogre::Real y = 0.0f, Ogre::Real z = 0.0f); Actor* getActor() const; OgreNewt::Body* _getBody() const; void _update(); void _setActor(Actor* actor); void _attachToSceneNode(Ogre::SceneNode* node); void _attachToBone(MeshObject* object, const std::string& boneName); void _detachFromSceneNode(Ogre::SceneNode* node); void onApplyForceAndTorque(); void addForce(const Ogre::Vector3& force); void freeze(); void unfreeze(); Ogre::Real getMass() const; void setMass(Ogre::Real mass); void createPhysicsProxy(SceneNode* node); /** Called to update the collision of the physical thing, in order to adapt * to a new animation state. * @warning This is only applicable to ConvexHullCollisions. * @throw IllegalStateException, if PhysicalThing does not represent a ConvexHullCollision */ void updateCollisionHull(); /** Called to update the collision of the physical thing, in order to adapt * to a new animation state. */ void fitToPose(const Ogre::String& name); void setContactListener(PhysicsContactListener* listener); PhysicsContactListener* getContactListener() const; void prepareUserControl(OgreNewt::MaterialID* material); void unprepareUserControl(); private: Actor* mActor; OgreNewt::Body* mBody; OgreNewt::BasicJoints::UpVector* mUpVectorJoint; Ogre::Vector3 mOffset; Ogre::Quaternion mOrientationBias; Ogre::Vector3 mPendingForce; bool mOverrideGravity; Ogre::Vector3 mGravity; PhysicsContactListener* mContactListener; typedef std::map<Ogre::String, OgreNewt::CollisionPtr> CollisionMap; CollisionMap mPoseCollisions; Ogre::Real mMass; PhysicsManager::GeometryTypes mGeometryType; PhysicalObject* mPhysicalObject; bool mHullModifier; void setOffset(const Ogre::Vector3& offset); void setOrientationBias(const Ogre::Quaternion& orientation); PhysicsManager::GeometryTypes getGeometryType() const; void setBody(OgreNewt::Body* body); OgreNewt::CollisionPtr createCollision( const AxisAlignedBox& aabb, Vector3* offset = NULL, Quaternion* orientation = NULL, Vector3* inertiaCoefficients = NULL) const; }; } #endif
[ "tanis@4c79e8ff-cfd4-0310-af45-a38c79f83013" ]
[ [ [ 1, 131 ] ] ]
711b315dc9391cd5a27fdf5192e19e6cbaecc47e
f55665c5faa3d79d0d6fe91fcfeb8daa5adf84d0
/Depend/MyGUI/Wrappers/WrapperGenerator/Wrapper.h
1fdf8090eb0828d449f4ecaf1f0ebceb32342f02
[]
no_license
lxinhcn/starworld
79ed06ca49d4064307ae73156574932d6185dbab
86eb0fb8bd268994454b0cfe6419ffef3fc0fc80
refs/heads/master
2021-01-10T07:43:51.858394
2010-09-15T02:38:48
2010-09-15T02:38:48
47,859,019
2
1
null
null
null
null
WINDOWS-1251
C++
false
false
4,541
h
/*! @file @author Albert Semenov @date 01/2009 */ #ifndef __WRAPPER_H__ #define __WRAPPER_H__ #include "Utility.h" #include "ClassHolder.h" namespace wrapper { class Wrapper : public ICommonTypeHolder { public: typedef std::vector<ClassAttribute> VectorClassAttribute; public: Wrapper() : mRoot(nullptr) { } virtual ~Wrapper() { delete mRoot; mRoot = 0; } virtual VectorPairString getTypeInfo(const std::string& _type) { MapTypeInfo::const_iterator type = mPairTypeInfo.find( utility::trim_result(_type) ); if (type == mPairTypeInfo.end()) return VectorPairString(); return type->second.tags; } virtual std::string getTemplatePrefix(const std::string& _template, const std::string& _rettype, const VectorParam& _params, const std::string& _namespace) { std::string result; result += getCustomParamPrefix(_template, utility::trim_result(getFullDefinition(_rettype, mRoot, _namespace)), 0); for (size_t index = 0; index < _params.size(); ++index) { result += getCustomParamPrefix(_template, utility::trim_result(getFullDefinition(_params[index].type, mRoot, _namespace)), index + 1); } return result; } bool initialise(const std::string& _filename) { xml::Document doc; const std::string filename = _filename; if ( !doc.open(filename) ) { std::cout << doc.getLastError() << std::endl; return false; } xml::ElementEnumerator child_item = doc.getRoot()->getElementEnumerator(); while (child_item.next()) { if (child_item->getName() == "Item") { mClassAttribute.push_back(ClassAttribute(child_item.current())); } else if (child_item->getName() == "TypeHolder") { xml::ElementEnumerator child = child_item->getElementEnumerator(); while (child.next("TypeInfo")) { TypeInfo info; xml::ElementEnumerator item = child->getElementEnumerator(); while (item.next()) { if (item->getName() == "Custom") { info.custom.name = item->findAttribute("name"); xml::ElementEnumerator infos = item->getElementEnumerator(); while (infos.next()) { if (infos->getName() == "Template") { info.custom.templates.push_back(infos->getContent()); } else if (infos->getName() == "Param") { info.custom.params.push_back(utility::parseSizeT(infos->getContent())); } } } else { info.tags.push_back(PairString(item->getName(), item->getContent())); } } mPairTypeInfo[child->findAttribute("name")] = info; } } } // загружаем индексный файл доксигена xml::Document doc_doxygen; const std::string filename_doxygen = "doxygen/xml/index.xml"; if ( !doc_doxygen.open(filename_doxygen) ) { std::cout << doc.getLastError() << std::endl; return false; } mRoot = new wrapper::Compound(doc_doxygen.getRoot(), "doxygenindex"); return true; } void wrap() { // очищаем шаблоны для добавления for (VectorClassAttribute::iterator item = mClassAttribute.begin(); item != mClassAttribute.end(); ++item) { (*item).initialise(mRoot, this); } for (VectorClassAttribute::iterator item = mClassAttribute.begin(); item != mClassAttribute.end(); ++item) { (*item).wrap(); } } std::string getCustomParamPrefix(const std::string& _template, const std::string& _type, size_t _num) { std::string result; MapTypeInfo::const_iterator type = mPairTypeInfo.find( utility::trim_result(_type) ); if (type == mPairTypeInfo.end()) return result; const CustomTypeInfo& info = type->second.custom; bool find = false; for (VectorString::const_iterator iter = info.templates.begin(); iter != info.templates.end(); ++iter) { if ((*iter) == _template) { find = true; break; } } if (!find) return result; for (VectorSizeT::const_iterator iter = info.params.begin(); iter != info.params.end(); ++iter) { if ((*iter) == _num) { result = utility::toString(info.name, *iter, "_"); break; } } return result; } private: Compound* mRoot; VectorClassAttribute mClassAttribute; MapTypeInfo mPairTypeInfo; }; } // namespace wrapper #endif // __WRAPPER_H__
[ "albertclass@a94d7126-06ea-11de-b17c-0f1ef23b492c" ]
[ [ [ 1, 170 ] ] ]