Esempio n. 1
0
void IImgLayer::Init(const LPRECT lprc)
{
	assert(m_IsInited == false);

	if (m_IsInited == false) {
		//create new update data queue
		ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );
		if(m_pUpdateDataForeGrnd_List){
			delete m_pUpdateDataForeGrnd_List;
			m_pUpdateDataForeGrnd_List = NULL;
		}
		if(m_pUpdateDataBackGrnd_List){
			delete m_pUpdateDataBackGrnd_List;
			m_pUpdateDataBackGrnd_List = NULL;
		}
		m_pUpdateDataForeGrnd_List = new LPUpdateData_List;
		m_pUpdateDataBackGrnd_List = new LPUpdateData_List;
		ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );

		m_LayerRect = (*lprc);

		if(m_Img){
			delete m_Img;
			m_Img = NULL;
		}
		m_Img = new IplImageExt();
		m_Img->Init(
			lprc->right - lprc->left,
			lprc->bottom - lprc->top,
			IPL_DEPTH_8U,
			4);

		m_IsInited = true;
	}
}
Esempio n. 2
0
void IImgLayer::End()
{
	assert(m_IsInited == true);

	if (m_IsInited) {
		//delete update data queue
		ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );
		if(m_pUpdateDataForeGrnd_List){
			delete m_pUpdateDataForeGrnd_List;
			m_pUpdateDataForeGrnd_List = NULL;
		}
		if(m_pUpdateDataBackGrnd_List){
			delete m_pUpdateDataBackGrnd_List;
			m_pUpdateDataBackGrnd_List = NULL;
		}
		ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );

		//release image
		if(m_Img){
			delete m_Img;
			m_Img = NULL;
		}

		m_IsInited = false;
	}
}
Esempio n. 3
0
void ImgLayer::ClearUpdateData()
{
	ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );
	m_pEditQueueForeGrnd->clear();
	ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );

	IImgLayer::ClearUpdateData();
}
Esempio n. 4
0
void IImgLayer::LockUpdateData()
{
	ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );

	LPUpdateData_List* utmp = m_pUpdateDataForeGrnd_List;
	m_pUpdateDataForeGrnd_List = m_pUpdateDataBackGrnd_List;
	m_pUpdateDataBackGrnd_List = utmp;

	ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );
}
Esempio n. 5
0
bool CDialogDef::GumpSetup( int iPage, CClient * pClient, CObjBase * pObjSrc, lpctstr Arguments )
{
    ADDTOCALLSTACK("CDialogDef::GumpSetup");
    CResourceLock	s;

    m_uiControls	= 0;
    m_uiTexts		= 0;
    m_pObj			= pObjSrc;
    m_iOriginX		= 0;
    m_iOriginY		= 0;
    m_wPage			= (word)(iPage);
    m_fNoDispose	= false;

    CScriptTriggerArgs	Args(iPage, 0, pObjSrc);
    //DEBUG_ERR(("Args.m_s1_raw %s  Args.m_s1 %s  Arguments 0x%x\n",Args.m_s1_raw, Args.m_s1, Arguments));
    Args.m_s1_raw = Args.m_s1 = Arguments;

    // read text first
    if ( g_Cfg.ResourceLock( s, CResourceID( RES_DIALOG, GetResourceID().GetResIndex(), RES_DIALOG_TEXT ) ) )
    {
        while ( s.ReadKey())
        {
            if ( m_uiTexts >= (CountOf(m_sText) - 1) )
                break;
            m_pObj->ParseText( s.GetKeyBuffer(), pClient->GetChar() );
            m_sText[m_uiTexts] = s.GetKey();
            m_uiTexts++;
        }
    }
    else
    {
        // no gump text?
    }

    // read the main dialog
    if ( !ResourceLock( s ) )
        return false;
    if ( !s.ReadKey() )		// read the size.
        return false;

    // starting x,y location.
    int64 iSizes[2];
    tchar * pszBuf = s.GetKeyBuffer();
    m_pObj->ParseText( pszBuf, pClient->GetChar() );

    Str_ParseCmds( pszBuf, iSizes, CountOf(iSizes) );
    m_x		= (int)(iSizes[0]);
    m_y		= (int)(iSizes[1]);

    if ( OnTriggerRunVal( s, TRIGRUN_SECTION_TRUE, pClient->GetChar(), &Args ) == TRIGRET_RET_TRUE )
        return false;
    return true;
}
Esempio n. 6
0
void ImgLayer::LockUpdateData()
{
	//swap back groud qeue to fore ground qeue
	ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );

	EditQueue* etmp = m_pEditQueueForeGrnd;
	m_pEditQueueForeGrnd = m_pEditQueueBackGrnd;
	m_pEditQueueBackGrnd = etmp;

	ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );

	IImgLayer::LockUpdateData();
}
Esempio n. 7
0
TRIGRET_TYPE CRegionResourceDef::OnTrigger( LPCTSTR pszTrigName, CTextConsole * pSrc, CScriptTriggerArgs * pArgs )
{
	ADDTOCALLSTACK("CRegionResourceDef::OnTrigger");
	// Attach some trigger to the cchar. (PC or NPC)
	// RETURN: true = block further action.

	CResourceLock s;
	if ( ResourceLock( s ))
	{
		TRIGRET_TYPE iRet = CScriptObj::OnTriggerScript( s, pszTrigName, pSrc, pArgs );
		return iRet;
	}
	return TRIGRET_RET_DEFAULT;
}
Esempio n. 8
0
void IImgLayer::ClearUpdateData()
{
	ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );

	LPUpdateData_List::iterator itr = m_pUpdateDataForeGrnd_List->begin();
	for(; itr != m_pUpdateDataForeGrnd_List->end(); itr++){
		if(*itr){
			delete (*itr);
		}
	}
	m_pUpdateDataForeGrnd_List->clear();

	ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );
}
Esempio n. 9
0
void ImgLayer::Init(const LPRECT lprc)
{
	IImgLayer::Init(lprc);

	//create new edit node queue
	ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );

	m_pEditQueueForeGrnd = new EditQueue;
	m_pEditQueueBackGrnd = new EditQueue;

	ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );

	m_IsLockPixelAlpha = false;
	m_IsLockVisiblePixel = false;
	m_IsLockLayerPosition = false;
	m_IsClipWithUnderLayer = false;

}
Esempio n. 10
0
/*
	描画イメージのアップデート
	@param[in] lprc アップデートする範囲
*/
void ImgLayer::UpdateEditNode(LPRECT lprc)
{
	ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );

	if (!m_pEditQueueForeGrnd->empty()) {
		EditQueue::iterator itr = m_pEditQueueForeGrnd->begin();
		for (; itr != m_pEditQueueForeGrnd->end(); itr++) {
			if ((*itr).flag == EDIT_FLAG::ADD_EDIT) {
				if ((*itr).pNode->node_flag == NODE_FLAG::EDIT_DRAW) {
					AddEditNode(dynamic_cast<EditNode*>((*itr).pNode), lprc);
				}
				else if ((*itr).pNode->node_flag == NODE_FLAG::MOVE_IMG) {
					MoveNode* pNode = dynamic_cast<MoveNode*>((*itr).pNode);
					assert(pNode);
	
					m_LayerRect.left += pNode->move_x;
					m_LayerRect.right += pNode->move_x;
					m_LayerRect.top += pNode->move_y;
					m_LayerRect.bottom += pNode->move_y;

					delete pNode;
					(*itr).pNode = NULL;
				}
			}
			else if ((*itr).flag == EDIT_FLAG::SUB_EDIT) {
				if ((*itr).pNode->node_flag == NODE_FLAG::EDIT_DRAW) {
					SubEditNode(dynamic_cast<EditNode*>((*itr).pNode), lprc);
				}
				else if ((*itr).pNode->node_flag == NODE_FLAG::MOVE_IMG) {
					assert(0);
					//MoveNode* pNode = dynamic_cast<MoveNode*>((*itr).pNode);
					//assert(pNode);
	
					//m_LayerRect.left -= pNode->move_x;
					//m_LayerRect.right -= pNode->move_x;
					//m_LayerRect.top -= pNode->move_y;
					//m_LayerRect.bottom -= pNode->move_y;
				}
			}
		}
	}

	ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );
}
Esempio n. 11
0
void IImgLayer::PushUpdateData(LPUPDATE_DATA data)
{
	ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );
	m_pUpdateDataBackGrnd_List->push_back( data );
	ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );

	//call event
	ImgLayerEventListener_List::iterator el_itr = m_ImgLayerEventListener_List.begin();
	for(; el_itr != m_ImgLayerEventListener_List.end(); el_itr++){
		if((*el_itr)->IsLockLayerEvent() == false && (*el_itr)->IsCalledImgLayer() == false){
			//無限にイベント呼び出しが続かないようにフラグを立てる
			(*el_itr)->SetCalledImgLayer(true);
			//
			(*el_itr)->OnImgLayerPushUpdateData(data);
		}

		(*el_itr)->SetCalledImgLayer(false);
	}
}
Esempio n. 12
0
void ImgLayer::PushSubEditNodeQueue(IEditNode* pNode)
{
	ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );

	if (!m_pEditQueueBackGrnd->empty()) {
		EditQueue::iterator itr = m_pEditQueueBackGrnd->begin();
		for (; itr != m_pEditQueueBackGrnd->end(); itr++) {
			if (((*itr).pNode == pNode) && ((*itr).flag == EDIT_FLAG::SUB_EDIT)) {
				ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );
				return;
			}
		}
	}
	EditQueueNode qnode;
	qnode.pNode = pNode;
	qnode.flag = EDIT_FLAG::SUB_EDIT;
	m_pEditQueueBackGrnd->push_back(qnode);

	ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );
}
Esempio n. 13
0
void ImgLayer::End()
{
	assert( _CrtCheckMemory() );

	//delete edit node queue
	ResourceLock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );

	if (m_pEditQueueForeGrnd) {
		EditQueue::iterator itr = m_pEditQueueForeGrnd->begin();
		for (; itr != m_pEditQueueForeGrnd->end(); itr++) {
			if ((*itr).pNode->node_flag == NODE_FLAG::MOVE_IMG) {
				delete (*itr).pNode;
			}
		}
		m_pEditQueueForeGrnd->clear();
		delete m_pEditQueueForeGrnd;
		m_pEditQueueForeGrnd = NULL;
	}
	if (m_pEditQueueBackGrnd) {
		EditQueue::iterator itr = m_pEditQueueBackGrnd->begin();
		for (; itr != m_pEditQueueBackGrnd->end(); itr++) {
			if ((*itr).pNode->node_flag == NODE_FLAG::MOVE_IMG) {
				delete (*itr).pNode;
			}
		}
		m_pEditQueueBackGrnd->clear();
		delete m_pEditQueueBackGrnd;
		m_pEditQueueBackGrnd = NULL;
	}

	ResourceUnlock( IE_LAYER_RESOURCE_ID::EDITNODE_QUEUE );

	IImgLayer::End();

	assert( _CrtCheckMemory() );
}
Esempio n. 14
0
bool CWebPageDef::ServPagePost( CClient * pClient, LPCTSTR pszURLArgs, TCHAR * pContentData, int iContentLength )
{
	ADDTOCALLSTACK("CWebPageDef::ServPagePost");
	UNREFERENCED_PARAMETER(pszURLArgs);
	// RETURN: true = this was the page of interest.

	ASSERT(pClient);

	if ( pContentData == NULL || iContentLength <= 0 )
		return( false );
	if ( ! HasTrigger(XTRIG_UNKNOWN))	// this form has no triggers.
		return( false );

	// Parse the data.
	pContentData[iContentLength] = 0;
	TCHAR * ppArgs[64];
	size_t iArgs = Str_ParseCmds(pContentData, ppArgs, COUNTOF(ppArgs), "&");
	if (( iArgs <= 0 ) || ( iArgs >= 63 ))
		return false;

	// T or TXT or TEXT = the text fields.
	// B or BTN or BUTTON = the buttons
	// C or CHK or CHECK = the check boxes

	CDialogResponseArgs resp;
	DWORD dwButtonID = ULONG_MAX;
	for ( size_t i = 0; i < iArgs; i++ )
	{
		TCHAR * pszNum = ppArgs[i];
		while ( IsAlpha(*pszNum) )
			pszNum++;

		int iNum = ATOI(pszNum);
		while ( *pszNum )
		{
			if ( *pszNum == '=' )
			{
				pszNum++;
				break;
			}
			pszNum++;
		}
		switch ( toupper(ppArgs[i][0]) )
		{
			case 'B':
				dwButtonID = iNum;
				break;
			case 'C':
				if ( !iNum )
					continue;
				if ( ATOI(pszNum) )
				{
					resp.m_CheckArray.Add( iNum );
				}
				break;
			case 'T':
				if ( iNum > 0 )
				{
					TCHAR *pszData = Str_GetTemp();
					HtmlDeCode( pszData, pszNum );
					resp.AddText(static_cast<WORD>(iNum), pszData);
				}
				break;
		}
	}

	// Use the data in RES_WEBPAGE block.
	CResourceLock s;
	if ( !ResourceLock(s) )
		return false;

	// Find the correct entry point.
	while ( s.ReadKeyParse())
	{
		if ( !s.IsKeyHead("ON", 2) || ( (DWORD)s.GetArgVal() != dwButtonID ))
			continue;
		OnTriggerRunVal(s, TRIGRUN_SECTION_TRUE, pClient, &resp);
		return true;
	}

	// Put up some sort of failure page ?

	return( false );
}
Esempio n. 15
0
int CWebPageDef::ServPageRequest( CClient * pClient, LPCTSTR pszURLArgs, CGTime * pdateIfModifiedSince )
{
	ADDTOCALLSTACK("CWebPageDef::ServPageRequest");
	UNREFERENCED_PARAMETER(pszURLArgs);
	// Got a web page request from the client.
	// ARGS:
	//  pszURLArgs = args on the URL line ex. http://www.hostname.com/dir?args
	// RETURN:
	//  HTTP error code = 0=200 page was served.

	ASSERT(pClient);

	if ( HasTrigger(WTRIG_Load))
	{
		CResourceLock s;
		if ( ResourceLock(s))
		{
			if (CScriptObj::OnTriggerScript( s, sm_szTrigName[WTRIG_Load], pClient, NULL ) == TRIGRET_RET_TRUE)
				return( 0 );	// Block further action.
		}
	}

	if ( m_privlevel )
	{
		if ( !pClient->m_pAccount )
			return 401;	// Authorization required
		if ( pClient->GetPrivLevel() < m_privlevel )
			return 403;	// Forbidden
	}

	CGTime datetime = CGTime::GetCurrentTime();

	LPCTSTR pszName;
	bool fGenerate = false;

	if ( m_type == WEBPAGE_TEMPLATE ) // my version of cgi
	{
		pszName = GetDstName();
		if ( pszName[0] == '\0' )
		{
			pszName = "temppage.htm";
			fGenerate = true;
		}
		else
		{
			fGenerate = ! m_iUpdatePeriod;
		}

		// The page must be generated on demand.
		if ( ! WebPageUpdate( fGenerate, pszName, pClient ))
			return 500;
	}
	else
	{
		pszName = GetName();
	}

	// Get proper Last-Modified: time.
	time_t dateChange;
	DWORD dwSize;
	if ( ! CFileList::ReadFileInfo( pszName, dateChange, dwSize ))
	{
		return 500;
	}

	const char *sDate = datetime.FormatGmt(NULL);	// current date.

	if ( !fGenerate && !pdateIfModifiedSince && (pdateIfModifiedSince->IsTimeValid() && pdateIfModifiedSince->GetTime() > dateChange) )
	{
		TCHAR *pszTemp = Str_GetTemp();
		sprintf(pszTemp, "HTTP/1.1 304 Not Modified\r\nDate: %s\r\nServer: " GRAY_TITLE " V " GRAY_VERSION "\r\nContent-Length: 0\r\n\r\n", sDate);
		new PacketWeb(pClient, (BYTE*)pszTemp, strlen(pszTemp));
		return 0;
	}

	// Now serve up the page.
	CGFile FileRead;
	if ( ! FileRead.Open( pszName, OF_READ|OF_BINARY ))
		return 500;

	// Send the header first.
	TCHAR szTmp[8*1024];
	size_t iLen = sprintf(szTmp,
		"HTTP/1.1 200 OK\r\n" // 100 Continue
		"Date: %s\r\n"
		"Server: " GRAY_TITLE " V " GRAY_VERSION "\r\n"
		"Accept-Ranges: bytes\r\n"
		"Content-Type: %s\r\n",
		static_cast<LPCTSTR>(sDate),
		static_cast<LPCTSTR>(sm_szPageType[m_type]) // type of the file. image/gif, image/x-xbitmap, image/jpeg
		);

	if ( m_type == WEBPAGE_TEMPLATE )
		iLen += sprintf(szTmp + iLen, "Expires: 0\r\n");
	else
		iLen += sprintf(szTmp + iLen, "Last-Modified: %s\r\n",  CGTime(dateChange).FormatGmt(NULL));

	iLen += sprintf( szTmp + iLen,
		"Content-Length: %lu\r\n"
		"\r\n",
		dwSize
		);

	PacketWeb packet;
	packet.setData((BYTE*)szTmp, iLen);
	packet.send(pClient);

	for (;;)
	{
		iLen = FileRead.Read( szTmp, sizeof( szTmp ) );
		if ( iLen <= 0 )
			break;
		packet.setData((BYTE*)szTmp, iLen);
		packet.send(pClient);
		//dwSize -= iLen;
		if ( iLen < sizeof( szTmp ) )
		{
			// memset( szTmp+iLen, 0, sizeof(szTmp)-iLen );
			break;
		}
	}
	return 0;
}
Esempio n. 16
0
/**
 *  MessageDraw draws MAX_VIEWED_MESSAGES of message lines on the
 *  currently active screen at given x and y coordinate.  The amount of
 *  space from line to line is also given by an interleave variable.
 *
 *  NOTE: 
 *  It is assumed that the currently active screen is where the messages
 *  need to be drawn.
 *
 *  @param x -- Starting x to draw
 *  @param y -- Starting y to draw
 *  @param interleave -- How far down to next line
 *  @param color -- Color of text
 *
 *<!-----------------------------------------------------------------------*/
T_void MessageDraw(
           T_word16 x,
           T_word16 y,
           T_word16 interleave,
           T_color color)
{
    T_word16 i ;
    T_word16 current ;
    T_word16 y_pos;
    T_word16 x_pos;
    T_byte8 ncolor;
    T_resourceFile res;
    T_resource font;
    T_bitfont *p_font;

    DebugRoutine("MessageDraw") ;

    /* lock in font */
    res = ResourceOpen ("sample.res");
    font=ResourceFind (res,"FontTiny");
    p_font=ResourceLock (font);
    GrSetBitFont (p_font);

    /* Loop through up to MAX_VIEWED_MESSAGES, but stop if we reach the */
    /* end of the message list.  Keep track of the current message and */
    /* also the position on the screen. */
    for (i=0, current=G_currentMessage, y_pos = y;
         (i<MAX_VIEWED_MESSAGES) && (current < G_numMessages);
         i++, current++, y_pos+=interleave)
    {
        /* draw each character, checking for embedded color controls */
        x_pos=0;
        ncolor=G_extendedColors[7];
        MessageDrawLine(x_pos, y_pos, P_Messages[current], ncolor);
    }

#if 0
        if (P_Messages[current][0]=='^')
        {
            /* special color imbedded in string */
            val=0;
            val+=((P_Messages[current][1]-'0')*100);
            val+=((P_Messages[current][2]-'0')*10);
            val+=((P_Messages[current][3]-'0'));

            if (val < MAX_EXTENDED_COLORS)
            {
                ncolor = G_extendedColors[val];
            }
            else DebugCheck (0);
            /* hide color code chars */
            temp+=4;
        }
        GrSetCursorPosition(x, y_pos) ;
        GrDrawShadowedText(temp, ncolor, COLOR_BLACK) ;
#endif

    /* unlock the font */
    ResourceUnlock (font);
    ResourceClose (res);

    DebugEnd() ;
}
Esempio n. 17
0
bool ImgLayer::Update(const LPRECT enable_lprc, LPRECT updated_lprc)
{
	if (m_pUpdateDataForeGrnd_List->empty()) {
		return false;
	}

	UPDATE_DATA udLayer;
	bool isLayerRect = false;
	udLayer.isAll = false;

	//更新情報の縮小化
	ResourceLock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );

	LPUpdateData_List::iterator itr = m_pUpdateDataForeGrnd_List->begin();
	for (; itr != m_pUpdateDataForeGrnd_List->end(); itr++) {
		bool isAll = (*itr)->isAll;
		
		switch ((*itr)->update_flag) {
			case UPDATE_FLAG::UPDATE_LAYER_IMAGE:
				if (isAll) {//全体更新
					udLayer.isAll = isAll;
				}
				else if (udLayer.isAll == false) {//部分更新
					if (isLayerRect == false) {//範囲の初期値がないなら
						udLayer.rect = (*itr)->rect;
						isLayerRect = true;
					}
					else {//範囲がすでに存在しているなら
						OrRect(&((*itr)->rect), &(udLayer.rect), &(udLayer.rect));
					}
				}
				break;
			case UPDATE_FLAG::NO_UPDATE:
				break;
			default:
				OutputError::PushLog( LOG_LEVEL::_WARN, "ImgLayer::Update() unknown update_flag");
				break;
		}

		//最大範囲の更新だったら抜ける。
		if ((*itr)->update_flag == UPDATE_FLAG::UPDATE_LAYER_IMAGE &&
			isAll)
		{
			break;
		}
	}
	ResourceUnlock( IE_LAYER_RESOURCE_ID::UPDATE_DATA_QUEUE );

	if (udLayer.isAll) {
		udLayer.rect = m_LayerRect;
		isLayerRect = true;
	}
	if (enable_lprc) {
		AndRect(&(udLayer.rect), enable_lprc, &(udLayer.rect));
	}
	
	//update
	if (isLayerRect) {
		UpdateEditNode(&udLayer.rect);
	}
	(*updated_lprc) = udLayer.rect;

	return IImgLayer::Update(enable_lprc, updated_lprc);
}
Esempio n. 18
0
ResourceManager::ResourceManager()
{
	locks.push_back(ResourceLock(Broodwar->self()->getRace().getCenter()));
}