Files
Client/GameTools/WORLDCREATOR/AmbienceList.cpp
LGram16 dd97ddec92 Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 20:17:20 +09:00

166 lines
4.4 KiB
C++

// AmbienceList.cpp : implementation file
//
#include "stdafx.h"
#include "worldcreator.h"
#include "AmbienceList.h"
#include <AmbienceStruct.h>
#include <SectorSoundMap.h>
#include <SectorDefine.h>
#include <SceneManager.h>
#include "WorldCreatorView.h"
#include "MainFrm.h"
#include <matrix.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAmbienceList dialog
extern float CharToFloat( const char * szStr );
CAmbienceList::CAmbienceList(CWnd* pParent /*=NULL*/)
: CDialog(CAmbienceList::IDD, pParent)
{
//{{AFX_DATA_INIT(CAmbienceList)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CAmbienceList::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAmbienceList)
DDX_Control(pDX, IDC_LIST, m_List);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAmbienceList, CDialog)
//{{AFX_MSG_MAP(CAmbienceList)
ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnDblclkList)
ON_NOTIFY(LVN_KEYDOWN, IDC_LIST, OnKeydownList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAmbienceList message handlers
extern const char * FloatToChar( float fvalue );
BOOL CAmbienceList::OnInitDialog()
{
CDialog::OnInitDialog();
DWORD dwStyle;
dwStyle = m_List.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE, 0 ,0);
dwStyle |= LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES;
m_List.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE, 0,dwStyle );
m_List.InsertColumn( 0, "¼½ÅÍ", LVCFMT_LEFT, 50 );
m_List.InsertColumn( 1, "x", LVCFMT_LEFT, 100 );
m_List.InsertColumn( 2, "y", LVCFMT_LEFT, 100 );
m_List.InsertColumn( 3, "z", LVCFMT_LEFT, 100 );
m_List.InsertColumn( 4, "ÃּҰŸ®", LVCFMT_LEFT, 100 );
m_List.InsertColumn( 5, "ÃÖ´ë°Å¸®", LVCFMT_LEFT, 100 );
UpdateList();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAmbienceList::UpdateList()
{
m_List.DeleteAllItems();
CSectorSoundMap & soundMap = CSectorSoundMap::GetInstance();
int nItem = 0;
for( int sX = 0; sX < 30; sX++ )
{
for( int sY = 0; sY < 30; sY++ )
{
int nAmbiences = soundMap.GetAmbienceCount( sX, sY );
for( int i = 0; i < nAmbiences; i++ )
{
SAmbience * pAmb = soundMap.GetAmbience( sX, sY, i );
CString SectorPos;
SectorPos.Format( "%d,%d", int( pAmb->m_fPosX / SECTORSIZE ), int( pAmb->m_fPosZ / SECTORSIZE ) );
m_List.InsertItem( nItem, SectorPos );
m_List.SetItemText( nItem, 1, FloatToChar( pAmb->m_fPosX ) );
m_List.SetItemText( nItem, 2, FloatToChar( pAmb->m_fPosY ) );
m_List.SetItemText( nItem, 3, FloatToChar( pAmb->m_fPosZ ) );
m_List.SetItemText( nItem, 4, FloatToChar( pAmb->m_fMinDistance ) );
m_List.SetItemText( nItem, 5, FloatToChar( pAmb->m_fMaxDistance ) );
nItem++;
}
}
}
}
void CAmbienceList::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
int curSel = m_List.GetNextItem(-1,LVNI_SELECTED);
if( curSel >= 0 )
{
float x = CharToFloat( m_List.GetItemText( curSel, 1 ) );
float y = CharToFloat( m_List.GetItemText( curSel, 2 ) );
float z = CharToFloat( m_List.GetItemText( curSel, 3 ) );
matrix *ViewPos=CSceneManager::GetCamera()->GetMatPosition();
ViewPos->_41 = x;
ViewPos->_42 = y + 500.0f;
ViewPos->_43 = z;
CMainFrame *mf=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CWorldCreatorView *av=(CWorldCreatorView *)mf->GetActiveView();
av->m_SceneManager->UpdateScene(0.0f);
}
OnOK();
*pResult = 0;
}
void CAmbienceList::OnKeydownList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
if( pLVKeyDow->wVKey == VK_DELETE )
{
int curSel = m_List.GetNextItem(-1,LVNI_SELECTED);
if( curSel >= 0 )
{
float x = CharToFloat( m_List.GetItemText( curSel, 1 ) );
float y = CharToFloat( m_List.GetItemText( curSel, 2 ) );
float z = CharToFloat( m_List.GetItemText( curSel, 3 ) );
CSectorSoundMap & soundMap = CSectorSoundMap::GetInstance();
long objID = soundMap.DeleteAmbience( x, y, z );
UpdateList();
CMainFrame *mf=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CWorldCreatorView *av=(CWorldCreatorView *)mf->GetActiveView();
if( objID != -1 )
{
av->m_SceneManager->m_MapStorage.DelMeshMap( x, y, z, objID );
av->m_SceneManager->m_HeightField.GenerateSectorSceneObjects( x/SECTORSIZE, z/SECTORSIZE );
}
}
}
*pResult = 0;
}