HELP WIKI & MODEL VIEWER

04/18/2020 08:17 iiamevan#1
can someone help me fixing this. Instead of viewing a model, WIKICI will popup
[Only registered and activated users can see links. Click Here To Register...]
04/18/2020 08:18 Naltalah#2
Because this code will open up the CI window if your authority is high enough. Maybe take a look at what it actually does.

Code:
BOOL CWndWiki::OnChildNotify(UINT message, UINT nID, LRESULT *pLResult)
{
	if (message == EN_CHANGE)
	{
		if (nID == WIDC_EDIT1)
			UpdateList();
	}
	else if (message == WNM_DBLCLK)
	{
		if (nID == WIDC_LISTBOX1)
		{
			{
				if (m_pListItems->GetCurSel() != -1)
				{
					if (g_pPlayer->m_dwAuthorization >= AUTH_GAMEMASTER)
					{
						SAFE_DELETE(m_pCreate);
						m_pCreate = new CWndWikiCreate();
						m_pCreate->Initialize(this);
						m_pCreate->SetItem(m_vecItems[m_pListItems->GetCurSel()]);
(This might not be the exact same code as you're using, but it will give you an idea what to look for)
04/18/2020 08:20 iiamevan#3
Quote:
Originally Posted by Naltalah View Post
Because this code will open up the CI window if your authority is high enough. Maybe take a look at what it actually does.

Code:
BOOL CWndWiki::OnChildNotify(UINT message, UINT nID, LRESULT *pLResult)
{
	if (message == EN_CHANGE)
	{
		if (nID == WIDC_EDIT1)
			UpdateList();
	}
	else if (message == WNM_DBLCLK)
	{
		if (nID == WIDC_LISTBOX1)
		{
			{
				if (m_pListItems->GetCurSel() != -1)
				{
					if (g_pPlayer->m_dwAuthorization >= AUTH_GAMEMASTER)
					{
						SAFE_DELETE(m_pCreate);
						m_pCreate = new CWndWikiCreate();
						m_pCreate->Initialize(this);
						m_pCreate->SetItem(m_vecItems[m_pListItems->GetCurSel()]);

Even if normal players, cant view a model, how to fix it?
04/18/2020 08:21 Naltalah#4
Then your modelviewer code is not in the OnChildNotify function.
04/18/2020 08:24 iiamevan#5
its here


Code:
#include "stdafx.h"

#ifdef __WIKI
#include "WndWiki.h"
#include "resdata.h"

#include "DPClient.h"

#ifdef __MODEL_VIEW
#include "WndModelView.h"
#endif

extern CDPClient g_DPlay;

DWORD WINAPI __SortThread(LPVOID lpParam)
{
	CWndWiki *pWiki = (CWndWiki*)lpParam;
	pWiki->Sort();
	return 0;
}

CWndWiki::CWndWiki()
{
	m_vecItems.clear();
	m_bUpperCase = false;
	m_cSortType = 0;
	m_hSortThread = INVALID_HANDLE_VALUE;
	m_pCreate = NULL;
}

CWndWiki::~CWndWiki()
{
	m_vecItems.clear();
	TerminateThread(m_hSortThread,0);
	SAFE_DELETE(m_pCreate);
}

BOOL CWndWiki::Initialize(CWndBase *pWndParent, DWORD dwStyle)
{
	return CWndNeuz::InitDialog(g_Neuz.GetSafeHwnd(),APP_WIKI,0,0,pWndParent);
}

void CWndWiki::OnInitialUpdate()
{
	CWndNeuz::OnInitialUpdate();

	m_pListItems = (CWndListBox*)GetDlgItem(WIDC_LISTBOX1);
	m_pComboKind = (CWndComboBox*)GetDlgItem(WIDC_COMBOBOX1);
	m_pComboJob = (CWndComboBox*)GetDlgItem(WIDC_COMBOBOX2);
	m_pEditFilter = (CWndEdit*)GetDlgItem(WIDC_EDIT1);
	
	int nIdx = 0;
	for( int i = 0; i < MAX_JOB; ++i )
	{
		if( i == JOB_PUPPETEER || i == JOB_DOPPLER || i == JOB_GATEKEEPER )
			continue;
		nIdx = m_pComboJob->AddString(prj.m_aJob[i].szName);
		m_pComboJob->SetItemData(nIdx,i);
	}
	m_pComboJob->SetCurSel(0);

	nIdx = m_pComboKind->AddString("All");
	m_pComboKind->SetItemData(nIdx,NULL_ID);

	nIdx = m_pComboKind->AddString("Weapon");
	m_pComboKind->SetItemData(nIdx,IK1_WEAPON);

	nIdx = m_pComboKind->AddString("Armor");
	m_pComboKind->SetItemData(nIdx,IK1_ARMOR);

	nIdx = m_pComboKind->AddString("Ride");
	m_pComboKind->SetItemData(nIdx,IK1_RIDE);

	nIdx = m_pComboKind->AddString("Furniture");
	m_pComboKind->SetItemData(nIdx,IK1_HOUSING);

	nIdx = m_pComboKind->AddString("Pet");
	m_pComboKind->SetItemData(nIdx,IK3_PET);

	m_pComboKind->SetCurSel(0);

	UpdateList();

	MoveParentCenter();
}

BOOL CWndWiki::OnChildNotify(UINT message, UINT nID, LRESULT *pLResult)
{
	if( message == WNM_CLICKED )
	{
		switch( nID )
		{
		case WIDC_BUTTON2:
			{
				TerminateThread(m_hSortThread,0);
				m_cSortType = 0;
				m_bUpperCase = !m_bUpperCase;
				m_hSortThread = CreateThread(0,0,__SortThread,this,0,0);
			}
			break;
		case WIDC_BUTTON3:
			{
				TerminateThread(m_hSortThread,0);
				m_cSortType = 1;
				m_bUpperCase = !m_bUpperCase;
				m_hSortThread = CreateThread(0,0,__SortThread,this,0,0);
			}
			break;
		case WIDC_BUTTON4:
			{
				TerminateThread(m_hSortThread,0);
				m_cSortType = 2;
				m_bUpperCase = !m_bUpperCase;
				m_hSortThread = CreateThread(0,0,__SortThread,this,0,0);
			}
			break;
		case WIDC_BUTTON1:
			{
				UpdateList();
			}
			break;
		}
	}
	else if( message == WNM_SELCHANGE )
	{
		if( nID == WIDC_COMBOBOX1 || nID == WIDC_COMBOBOX2 )
			UpdateList();
	}
	else if( message == EN_CHANGE )
	{
		if( nID == WIDC_EDIT1 )
			UpdateList();
	}
	else if( message == WNM_DBLCLK )
	{
		if( nID == WIDC_LISTBOX1 )
		{
#ifdef __MODEL_VIEW
			if( m_pListItems->GetCurSel() != -1 )
			{
				if( g_pPlayer->m_dwAuthorization >= AUTH_OPERATOR && GetAsyncKeyState(VK_SHIFT) & 0x8000 )
				{
					SAFE_DELETE(m_pCreate);
					m_pCreate = new CWndWikiCreate();
					m_pCreate->Initialize(this);
					m_pCreate->SetItem(m_vecItems[m_pListItems->GetCurSel()]);
				}else
				{
					ItemProp *pProp = m_vecItems[m_pListItems->GetCurSel()];
					if( pProp )
					{
						CWndModelView *pWndViewer = (CWndModelView*)g_WndMng.GetApplet(APP_MODEL_VIEW);
						if( !pWndViewer )
						{
							pWndViewer = (CWndModelView*)g_WndMng.CreateApplet(APP_MODEL_VIEW);
							if( pWndViewer )
							{
								if( !pWndViewer->SetPart(pProp) )
									pWndViewer->Destroy();
							}
						}else
							pWndViewer->SetPart(pProp);
					}
				}
			}
#else
			if( g_pPlayer->m_dwAuthorization >= AUTH_SOFTWAREENGINEER )
			{
				if( m_pListItems->GetCurSel() != -1 )
				{
					SAFE_DELETE(m_pCreate);
					m_pCreate = new CWndWikiCreate();
					m_pCreate->Initialize(this);
					m_pCreate->SetItem(m_vecItems[m_pListItems->GetCurSel()]);
				}
			}
#endif
		}
	}
	return CWndNeuz::OnChildNotify(message,nID,pLResult);
}


void CWndWiki::UpdateList()
{
	const static DWORD dwItems [] = { II_SYS_SYS_SCR_PERIN };
	DWORD dwJob = m_pComboJob->GetSelectedItemData();
	DWORD dwFilter = m_pComboKind->GetSelectedItemData();
	CString strFilter = m_pEditFilter->GetString();

	m_vecItems.clear();
	m_pListItems->ResetContent();

	for( int i = 0; i < prj.m_aPropItem.GetSize(); ++i )
	{
		ItemProp *pProp = prj.m_aPropItem.GetAt(i);
		if( pProp )
		{
			bool bInArray = false;
			for( int j = 0; j < sizeof(dwItems) / sizeof(dwItems[0]); ++j )
			{
				if( pProp->dwID == dwItems[j] )
				{
					bInArray = true;
					break;
				}
			}
			if( strstr(pProp->szName,"?") )
				continue;
			if( pProp->dwLimitLevel1 > MAX_CHARACTER_LEVEL && pProp->dwLimitLevel1 != NULL_ID )
				continue;
			if( !strlen(pProp->szName) )
				continue;
			if( !strlen(pProp->szIcon) )
				continue;
			if( bInArray )
				continue;
			if( dwJob != JOB_VAGRANT )
			{
				if( pProp->dwItemJob != dwJob )
					continue;
			}
			if( dwFilter != NULL_ID )
			{
				if( pProp->dwItemKind1 != dwFilter )
					continue;
			}
			if( strFilter.GetLength() )
			{
				CString strName = pProp->szName;
				if( !strstr(strName.MakeLower(),strFilter.MakeLower()) )
					continue;
			}
			m_vecItems.push_back(pProp);
			m_pListItems->AddString("");
		}
	}
}

bool SortByNameUpper(const ItemProp *pPropLeft, const ItemProp *pPropRight)
{
	std::string strLeft = pPropLeft->szName;
	std::string strRight = pPropRight->szName;
	return (strLeft < strRight);
}
bool SortByNameLower(const ItemProp *pPropLeft, const ItemProp *pPropRight)
{
	std::string strLeft = pPropLeft->szName;
	std::string strRight = pPropRight->szName;
	return (strLeft > strRight);
}
bool SortByLevelUpper(const ItemProp *pPropLeft, const ItemProp *pPropRight)
{
	int nLevelLeft = (pPropLeft->dwLimitLevel1 == NULL_ID ? 1 : pPropLeft->dwLimitLevel1);
	int nLevelRight = (pPropRight->dwLimitLevel1 == NULL_ID ? 1 : pPropRight->dwLimitLevel1);
	return (nLevelLeft < nLevelRight);
}
bool SortByLevelLower(const ItemProp *pPropLeft, const ItemProp *pPropRight)
{
	int nLevelLeft = (pPropLeft->dwLimitLevel1 == NULL_ID ? 1 : pPropLeft->dwLimitLevel1);
	int nLevelRight = (pPropRight->dwLimitLevel1 == NULL_ID ? 1 : pPropRight->dwLimitLevel1);
	return (nLevelLeft > nLevelRight);
}
bool SortByJobUpper(const ItemProp *pPropLeft, const ItemProp *pPropRight)
{
	return (pPropLeft->dwItemJob < pPropRight->dwItemJob);
}
bool SortByJobLower(const ItemProp *pPropLeft, const ItemProp *pPropRight)
{
	return (pPropLeft->dwItemJob > pPropRight->dwItemJob);
}

void CWndWiki::SortByName()
{
	if( m_bUpperCase )
		std::sort(m_vecItems.begin(),m_vecItems.end(), SortByNameUpper);
	else
		std::sort(m_vecItems.begin(),m_vecItems.end(), SortByNameLower);
}

void CWndWiki::SortByLevel()
{
	if( m_bUpperCase )
		std::sort(m_vecItems.begin(),m_vecItems.end(), SortByLevelUpper);
	else
		std::sort(m_vecItems.begin(),m_vecItems.end(), SortByLevelLower);
}

void CWndWiki::SortByJob()
{
	if( m_bUpperCase )
		std::sort(m_vecItems.begin(),m_vecItems.end(), SortByJobUpper);
	else
		std::sort(m_vecItems.begin(),m_vecItems.end(), SortByJobLower);
}

void CWndWiki::Sort()
{
	m_pListItems->EnableWindow(FALSE);
	switch( m_cSortType )
	{
	case 0: SortByName(); break;
	case 1: SortByJob(); break;
	case 2: SortByLevel(); break;
	}
	m_pListItems->EnableWindow(TRUE);
}

CWndWikiCreate::CWndWikiCreate()
{
	m_pPropCreate = NULL;
}

BOOL CWndWikiCreate::Initialize(CWndBase *pWndParent, DWORD dwStyle)
{
	return CWndNeuz::InitDialog(g_Neuz.GetSafeHwnd(),APP_WIKICI,WBS_MODAL,0,pWndParent);
}

void CWndWikiCreate::OnInitialUpdate()
{
	CWndNeuz::OnInitialUpdate();

	m_pStcName = (CWndStatic*)GetDlgItem(WIDC_STATIC1);
	m_pDrawCtrl = GetWndCtrl(WIDC_STATIC4);
	m_pEditAmount = (CWndEdit*)GetDlgItem(WIDC_EDIT1);
	m_pEditAmount->AddWndStyle(EBS_NUMBER);
	m_pEditAmount->SetString("1");
	m_pEditName = (CWndEdit*)GetDlgItem(WIDC_EDIT2);

	MoveParentCenter();
}

void CWndWikiCreate::OnDraw(C2DRender *p2DRender)
{
	CWndNeuz::OnDraw(p2DRender);
	if( m_pPropCreate )
	{
		CTexture *pTex = CWndBase::m_textureMng.AddTexture(p2DRender->m_pd3dDevice, MakePath(DIR_ITEM,m_pPropCreate->szIcon), 0xffff00ff);
		if( pTex )
			pTex->Render(p2DRender,CPoint(m_pDrawCtrl->rect.left+6,m_pDrawCtrl->rect.top+6));
	}
}

BOOL CWndWikiCreate::OnChildNotify(UINT message, UINT nID, LRESULT *pLResult)
{
	if( nID == WIDC_BUTTON1 )
	{
		if( m_pPropCreate )
		{
			int nAmount = atoi(m_pEditAmount->GetString());
			if( nAmount > 0 && nAmount < 100 )
			{
				g_DPlay.SendWikiCreateItem(m_pPropCreate,nAmount,m_pEditName->GetString());
				Destroy();
			}
		}
	}else if( nID == WIDC_BUTTON2 )
	{
		Destroy();
	}
	return CWndNeuz::OnChildNotify(message,nID,pLResult);
}

void CWndWikiCreate::OnMouseWndSurface(CPoint point)
{
	if( m_pDrawCtrl->rect.PtInRect(point) )
	{
		if( m_pPropCreate )
		{
			CItemElem itemElem;
			CRect rect = m_pDrawCtrl->rect;
			itemElem.m_dwItemId = m_pPropCreate->dwID;
			ClientToScreen(&point);
			ClientToScreen(&rect);
			g_WndMng.PutToolTip_Item(&itemElem,point,&rect);
		}
	}
}

void CWndWikiCreate::SetItem(ItemProp *pPropCreate)
{
	m_pPropCreate = pPropCreate;
	if( m_pPropCreate )
		m_pStcName->SetTitle(m_pPropCreate->szName);
	else
		m_pStcName->SetTitle("");
}
#endif // __WIKI
04/18/2020 08:27 Naltalah#6
Just debug your neuz then and check why it's not opening I guess. Might as well be a bug in your modelviewer. And I do have to ask this, __MODEL_VIEW is defined right?
04/18/2020 08:27 iiamevan#7
Quote:
Originally Posted by Naltalah View Post
Yeah... really easy to read. Just debug your neuz then and check why it's not opening I guess. Might as well be a bug in your modelviewer. And I do have to ask this, __MODEL_VIEW is defined right?
yes sir it is defined already
04/18/2020 08:33 Naltalah#8
Then the only solution is to debug your neuz with breakpoints on the window opening in the Wiki and see why it triggers or doesnt trigger.

If the modelviewer won't open up even tho the code is being executed, there's an error in your modelviewer and you need to debug that. From what you have posted here, everything should work correctly.
But from this point on, it's your task to find the bug.

Might as well check the MSDN about Debugging if you don't know how to do it: [Only registered and activated users can see links. Click Here To Register...]
04/18/2020 16:55 iiamevan#9
Quote:
Originally Posted by Naltalah View Post
Then the only solution is to debug your neuz with breakpoints on the window opening in the Wiki and see why it triggers or doesnt trigger.

If the modelviewer won't open up even tho the code is being executed, there's an error in your modelviewer and you need to debug that. From what you have posted here, everything should work correctly.
But from this point on, it's your task to find the bug.

Might as well check the MSDN about Debugging if you don't know how to do it: [Only registered and activated users can see links. Click Here To Register...]
its the same outcome sir