Changed: Macros to convert to/from TCHAR* and std::string

--HG--
branch : develop
This commit is contained in:
kervala 2016-11-19 19:46:40 +01:00
parent 9941fcf82b
commit 8d82472586
43 changed files with 331 additions and 362 deletions

View file

@ -286,6 +286,15 @@ inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp(
#define wideToUtf8(str) (ucstring((ucchar*)str).toUtf8())
#define utf8ToWide(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
// macros helper to convert UTF-8 std::string and TCHAR*
#ifdef _UNICODE
#define tStrToUtf8(str) (ucstring((ucchar*)(LPCWSTR)str).toUtf8())
#define utf8ToTStr(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
#else
#define tStrToUtf8(str) ((LPCSTR)str)
#define utf8ToTStr(str) (str.c_str())
#endif
// wrapper for fopen to be able to open files with an UTF-8 filename
FILE* nlfopen(const std::string &filename, const std::string &mode);

View file

@ -160,22 +160,22 @@ bool CMaxToLigo::loadLigoConfigFile (CLigoConfig& config, Interface& it, bool di
// ***************************************************************************
void CMaxToLigo::errorMessage (const char *msg, const char *title, Interface& it, bool dialog)
void CMaxToLigo::errorMessage(const std::string &msg, const std::string &title, Interface& it, bool dialog)
{
// Text or dialog ?
if (dialog)
{
// Dialog message
MessageBox (it.GetMAXHWnd(), msg, title, MB_OK|MB_ICONEXCLAMATION);
MessageBox (it.GetMAXHWnd(), utf8ToTStr(msg), utf8ToTStr(title), MB_OK|MB_ICONEXCLAMATION);
}
else
{
// Text message
mprintf ((string(msg) + "\n").c_str());
mprintf (utf8ToTStr(msg + "\n"));
}
// Output in log
nlwarning ("LIGO ERROR : %s", msg);
nlwarning ("LIGO ERROR : %s", msg.c_str());
}
// ***************************************************************************

View file

@ -70,7 +70,7 @@ public:
* \param it if a max interface
* \param dialog is true to see the message in a dilog, false to see it in the script window.
*/
static void errorMessage (const char *msg, const char *title, Interface& it, bool dialog);
static void errorMessage (const std::string &msg, const std::string &title, Interface& it, bool dialog);
};
}

View file

@ -326,8 +326,8 @@ Value* export_transition_cf (Value** arg_list, int count)
// The second arg
string matFilename[2];
matFilename[0] = arg_list[2]->to_string();
matFilename[1] = arg_list[3]->to_string();
matFilename[0] = tStrToUtf8(arg_list[2]->to_string());
matFilename[1] = tStrToUtf8(arg_list[3]->to_string());
// The third arg
bool checkOnly = (arg_list[4]->to_bool() != FALSE);
@ -700,7 +700,7 @@ Value* check_zone_with_material_cf (Value** arg_list, int count)
nlassert (node);
// The second arg
string fileName = arg_list[1]->to_string();
string fileName = tStrToUtf8(arg_list[1]->to_string());
// The fourth arg
bool errorInDialog = (arg_list[2]->to_bool() != FALSE);
@ -834,7 +834,7 @@ Value* check_zone_with_transition_cf (Value** arg_list, int count)
nlassert (node);
// The second arg
string fileName = arg_list[1]->to_string();
string fileName = tStrToUtf8(arg_list[1]->to_string());
// The second arg
int transitionNumber = arg_list[2]->to_int();
@ -1002,7 +1002,7 @@ Value* export_zone_cf (Value** arg_list, int count)
nlassert (node);
// The second arg
string fileName = arg_list[1]->to_string();
string fileName = tStrToUtf8(arg_list[1]->to_string());
// The thrid arg
Array *array = (Array*)arg_list[2];
@ -1047,8 +1047,8 @@ Value* export_zone_cf (Value** arg_list, int count)
type_check (cell->get(2), String, message);
// Get the strings
categories[i].first = cell->get(1)->to_string();
categories[i].second = cell->get(2)->to_string();
categories[i].first = tStrToUtf8(cell->get(1)->to_string());
categories[i].second = tStrToUtf8(cell->get(2)->to_string());
}
// Get a Object pointer
@ -1369,7 +1369,7 @@ Value* get_error_string_cf (Value** arg_list, int count)
int errorCode = arg_list[0]->to_int()-1;
// Error code
return new String ((char*)CLigoError::getStringError ((CLigoError::TError)errorCode));
return new String (utf8ToTStr(CLigoError::getStringError ((CLigoError::TError)errorCode)));
}
// ***************************************************************************
@ -1384,10 +1384,10 @@ Value* set_directory_cf (Value** arg_list, int count)
type_check(arg_list[0], String, message);
// The first arg
const char *dir = arg_list[0]->to_string();
const std::string dir = tStrToUtf8(arg_list[0]->to_string());
// Set the directory
return (chdir (dir)==0)?&true_value:&false_value;
return (chdir (dir.c_str())==0)?&true_value:&false_value;
}
// ***************************************************************************
@ -1876,7 +1876,7 @@ Value* make_snapshot_cf (Value** arg_list, int count)
nlassert (node);
// The second arg
string fileName = arg_list[1]->to_string();
string fileName = tStrToUtf8(arg_list[1]->to_string());
// The thrid arg
int xMin = arg_list[2]->to_int();

View file

@ -147,7 +147,7 @@ void CAnimationSetDlg::OnAddAnimation ()
CString name = path + filename;
// Load the animation
_ObjView->loadAnimation (name, instance);
_ObjView->loadAnimation (tStrToUtf8(name), instance);
// Touch the channel mixer
_ObjView->reinitChannels ();
@ -158,7 +158,7 @@ void CAnimationSetDlg::OnAddAnimation ()
}
catch (Exception& e)
{
MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
}
}
}
@ -188,7 +188,7 @@ void CAnimationSetDlg::OnAddSkelWt()
CString filename=fileDlg.GetNextPathName(pos);
// Load the animation
_ObjView->loadSWT (filename, instance);
_ObjView->loadSWT (tStrToUtf8(filename), instance);
// Touch the channel mixer
_ObjView->reinitChannels ();
@ -199,7 +199,7 @@ void CAnimationSetDlg::OnAddSkelWt()
}
catch (Exception& e)
{
MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
}
}
}
@ -233,9 +233,8 @@ void CAnimationSetDlg::refresh (BOOL update)
uint i;
for (i=0; i<_ObjView->getNumInstance (); i++)
{
char name[512];
_splitpath (_ObjView->getInstance (i)->Saved.ShapeFilename.c_str(), NULL, NULL, name, NULL);
EditedObject.InsertString (-1, name);
std::string name = NLMISC::CFile::getFilenameWithoutExtension(_ObjView->getInstance(i)->Saved.ShapeFilename);
EditedObject.InsertString (-1, utf8ToTStr(name));
}
// Get edited object
@ -270,7 +269,7 @@ void CAnimationSetDlg::refresh (BOOL update)
CAnimation *anim = object->AnimationSet.getAnimation (object->AnimationSet.getAnimationIdByName (name));
// Insert an intem
HTREEITEM item=Tree.InsertItem (name);
HTREEITEM item=Tree.InsertItem(utf8ToTStr(name));
Tree.SetItemData (item, i);
nlassert (item!=NULL);
@ -281,7 +280,7 @@ void CAnimationSetDlg::refresh (BOOL update)
while (ite!=setString.end())
{
// Add this string
HTREEITEM newItem = Tree.InsertItem (ite->c_str(), item);
HTREEITEM newItem = Tree.InsertItem (utf8ToTStr(*ite), item);
Tree.SetItemData (newItem, 0xffffffff);
// Get the track
@ -296,20 +295,17 @@ void CAnimationSetDlg::refresh (BOOL update)
keyTrack->getKeysInRange (track->getBeginTime ()-1, track->getEndTime ()+1, keys);
// Print track info
char name[512];
_snprintf (name, 512, "%s (%f - %f) %d keys", typeid(*track).name(), track->getBeginTime (), track->getEndTime (), keys.size());
HTREEITEM keyItem = Tree.InsertItem (name, newItem);
Tree.SetItemData (keyItem, 0xffffffff);
name = toString("%s (%f - %f) %u keys", typeid(*track).name(), track->getBeginTime(), track->getEndTime(), (uint32)keys.size());
}
else
{
// Print track info
char name[512];
_snprintf (name, 512, "%s (%f - %f)", typeid(*track).name(), track->getBeginTime (), track->getEndTime ());
HTREEITEM keyItem = Tree.InsertItem (name, newItem);
Tree.SetItemData (keyItem, 0xffffffff);
name = toString("%s (%f - %f)", typeid(*track).name(), track->getBeginTime(), track->getEndTime());
}
HTREEITEM keyItem = Tree.InsertItem(utf8ToTStr(name), newItem);
Tree.SetItemData(keyItem, 0xffffffff);
ite++;
}
}
@ -325,7 +321,7 @@ void CAnimationSetDlg::refresh (BOOL update)
CSkeletonWeight *swt = object->AnimationSet.getSkeletonWeight (object->AnimationSet.getSkeletonWeightIdByName (name));
// Insert an intem
HTREEITEM item=SkelTree.InsertItem (name);
HTREEITEM item=SkelTree.InsertItem(utf8ToTStr(name));
nlassert (item!=NULL);
// Get number of node in this skeleton weight
@ -334,11 +330,10 @@ void CAnimationSetDlg::refresh (BOOL update)
// Add the nodein the tree
for (uint n=0; n<numNode; n++)
{
char percent[512];
sprintf (percent, "%s (%f%%)", swt->getNodeName (n).c_str(), swt->getNodeWeight(n)*100);
std::string percent = toString("%s (%f%%)", swt->getNodeName(n).c_str(), swt->getNodeWeight(n)*100);
// Add this string
SkelTree.InsertItem (percent, item);
SkelTree.InsertItem (utf8ToTStr(percent), item);
}
}
@ -346,7 +341,7 @@ void CAnimationSetDlg::refresh (BOOL update)
for (i=0; i<object->Saved.PlayList.size(); i++)
{
// Insert an intem
int item=PlayList.InsertString (-1, object->Saved.PlayList[i].c_str());
int item=PlayList.InsertString (-1, utf8ToTStr(object->Saved.PlayList[i]));
nlassert (item!=LB_ERR);
}
}
@ -374,7 +369,7 @@ void CAnimationSetDlg::refresh (BOOL update)
// Insert an intem
TCHAR text[512];
PlayList.GetText( i, text);
object->Saved.PlayList[i] = text;
object->Saved.PlayList[i] = tStrToUtf8(text);
}
CDialog::UpdateData (update);

View file

@ -355,7 +355,7 @@ void CAttribDlg::init(HBITMAP bitmap, sint x, sint y, CWnd *pParent)
for (uint k = 0; k < getNumScheme(); ++k)
{
m_Scheme.InsertString(k, getSchemeName(k).c_str());
m_Scheme.InsertString(k, utf8ToTStr(getSchemeName(k)));
}

View file

@ -22,7 +22,7 @@
// CChooseName dialog
CChooseName::CChooseName(const TCHAR *initialName, CWnd* pParent /*=NULL*/)
CChooseName::CChooseName(const CString &initialName, CWnd* pParent /*=NULL*/)
: CDialog(CChooseName::IDD, pParent)
{
//{{AFX_DATA_INIT(CChooseName)
@ -33,7 +33,7 @@ CChooseName::CChooseName(const TCHAR *initialName, CWnd* pParent /*=NULL*/)
std::string CChooseName::getName()
{
return std::string(m_Name);
return tStrToUtf8(m_Name);
}
void CChooseName::DoDataExchange(CDataExchange* pDX)

View file

@ -32,7 +32,7 @@ class CChooseName : public CDialog
{
// Construction
public:
CChooseName(const TCHAR *initialName, CWnd* pParent = NULL); // standard constructor
CChooseName(const CString &initialName, CWnd* pParent = NULL); // standard constructor
std::string getName();

View file

@ -52,10 +52,11 @@ void CChoosePoolID::OnOK()
{
CString val;
GetDlgItem(IDC_POOL_ID)->GetWindowText(val);
if (::sscanf((LPCTSTR) val, "%d", &PoolID) == 1)
if (NLMISC::fromString(tStrToUtf8(val), PoolID))
{
GetDlgItem(IDC_POOL_NAME)->GetWindowText(val);
Name = (LPCTSTR) val;
Name = tStrToUtf8(val);
CDialog::OnOK();
}
else
@ -67,10 +68,12 @@ void CChoosePoolID::OnOK()
BOOL CChoosePoolID::OnInitDialog()
{
CDialog::OnInitDialog();
char val[128];
sprintf(val, "%d", PoolID);
GetDlgItem(IDC_POOL_ID)->SetWindowText(val);
GetDlgItem(IDC_POOL_NAME)->SetWindowText(Name.c_str());
std::string val = NLMISC::toString(PoolID);
GetDlgItem(IDC_POOL_ID)->SetWindowText(utf8ToTStr(val));
GetDlgItem(IDC_POOL_NAME)->SetWindowText(utf8ToTStr(Name));
if (_FreezeID)
{
GetDlgItem(IDC_POOL_ID)->EnableWindow(FALSE);

View file

@ -72,7 +72,7 @@ BOOL CCreateFileDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText((LPCTSTR) _Title);
GetDlgItem(IDC_LOCATION)->SetWindowText(_DefaultBasePath.c_str());
GetDlgItem(IDC_LOCATION)->SetWindowText(utf8ToTStr(_DefaultBasePath));
if (!_DefaultBasePath.empty())
{
GetDlgItem(IDC_FILENAME)->SetFocus();
@ -90,10 +90,10 @@ void CCreateFileDlg::OnOK()
{
CString filename;
GetDlgItem(IDC_FILENAME)->GetWindowText(filename);
_Filename = (LPCTSTR) filename;
_Filename = tStrToUtf8(filename);
CString location;
GetDlgItem(IDC_LOCATION)->GetWindowText(location);
_Path = (LPCTSTR) location;
_Path = tStrToUtf8(location);
if (_Path.empty())
{
localizedMessageBox(*this, IDS_EMPTY_PATH, IDS_ERROR, MB_ICONEXCLAMATION);

View file

@ -173,7 +173,7 @@ void CDirectionAttr::OnDestroy()
void CDirectionAttr::OnGlobalDirection()
{
nlassert(_DirectionWrapper);
CChooseName chooseName(_DirectionWrapper->getGlobalVectorValueName().c_str());
CChooseName chooseName(utf8ToTStr(_DirectionWrapper->getGlobalVectorValueName()));
if (chooseName.DoModal() == IDOK)
{

View file

@ -76,7 +76,7 @@ std::string CEditEx::getString() const
{
TCHAR buf[128];
GetWindowText(buf, sizeof(buf));
return std::string(buf);
return tStrToUtf8(buf);
}
void CEditEx::setSInt(sint value)
@ -130,21 +130,25 @@ void CEditEx::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
bool CEditEx::isValid()
{
int iValue;
float fValue;
switch(_Type)
{
case SIntType:
return sscanf(getString().c_str(), "%d", &iValue) == 1;
break;
{
sint value;
return NLMISC::fromString(getString(), value);
}
case UIntType:
return sscanf(getString().c_str(), "%d", &iValue) == 1 && iValue >= 0;
break;
{
uint value;
return NLMISC::fromString(getString(), value);
}
case FloatType:
return sscanf(getString().c_str(), "%f", &fValue) == 1;
break;
default:
return true;
break;
{
float value;
return NLMISC::fromString(getString(), value);
}
default: break;
}
return true;
}

View file

@ -101,7 +101,7 @@ bool CEditMorphMeshDlg::getShapeNameFromDlg(std::string &name)
NLMISC::CPath::addSearchPath (path);
*/
name = fd.GetPathName();
name = tStrToUtf8(fd.GetPathName());
return true;
}
@ -135,7 +135,7 @@ void CEditMorphMeshDlg::OnAdd()
_CM->setShapes(&shapeNames[0], (uint)shapeNames.size());
std::vector<sint> numVerts;
_CM->getShapeNumVerts(numVerts);
m_MeshList.AddString(getShapeDescStr(index, numVerts[index]).c_str());
m_MeshList.AddString(utf8ToTStr(getShapeDescStr(index, numVerts[index])));
GetDlgItem(IDC_REMOVE)->EnableWindow(TRUE);
}
touchPSState();
@ -265,7 +265,7 @@ void CEditMorphMeshDlg::updateMeshList()
m_MeshList.ResetContent();
for (uint k = 0; k < _CM->getNumShapes(); ++k)
{
m_MeshList.AddString(getShapeDescStr(k, numVerts[k]).c_str());
m_MeshList.AddString(utf8ToTStr(getShapeDescStr(k, numVerts[k])));
}
m_MeshList.SetCurSel(0);
updateValidFlag();
@ -322,12 +322,12 @@ std::string CEditMorphMeshDlg::getShapeDescStr(uint shapeIndex, sint numVerts) c
{
CString verts;
verts.LoadString(IDS_VERTICES);
std::string msg = _CM->getShape(shapeIndex) + " (" + NLMISC::toString(numVerts) + " " + (LPCTSTR) verts + ")";
std::string msg = _CM->getShape(shapeIndex) + " (" + NLMISC::toString(numVerts) + " " + tStrToUtf8(verts) + ")";
return msg;
}
else
{
std::string result = _CM->getShape(shapeIndex) + " (" + (LPCTSTR) CMeshDlg::getShapeErrorString(numVerts) + ")";
std::string result = _CM->getShape(shapeIndex) + " (" + tStrToUtf8(CMeshDlg::getShapeErrorString(numVerts)) + ")";
return result;
}
}

View file

@ -195,7 +195,7 @@ void CEditPSSound::OnChangeSoundName()
{
nlassert(_Sound);
UpdateData();
_Sound->setSoundName(NLMISC::CSheetId((LPCTSTR)m_SoundName, "sound"));
_Sound->setSoundName(NLMISC::CSheetId(tStrToUtf8(m_SoundName), "sound"));
updateModifiedFlag();
}
@ -209,7 +209,7 @@ void CEditPSSound::OnSpawn()
// play the currently selected sound
void CEditPSSound::OnPlaySound()
{
CSoundSystem::play(std::string((LPCTSTR)m_SoundName));
CSoundSystem::play(tStrToUtf8(m_SoundName));
}
void CEditPSSound::OnMute()

View file

@ -85,7 +85,7 @@ void CEmitterDlg::initEmittedType()
NL3D::CPSLocated *loc = dynamic_cast<NL3D::CPSLocated *>(ps->getProcess(k));
if (loc) // is this a located
{
m_EmittedTypeCtrl.AddString(loc->getName().c_str());
m_EmittedTypeCtrl.AddString(utf8ToTStr(loc->getName()));
_LocatedList.push_back(loc);
if (loc == _Emitter->getEmittedType())
{

View file

@ -119,7 +119,7 @@ void CLBExternIDDlg::OnChangeIdValue()
TCHAR buf[6];
::memset(buf, 0, 6);
GetDlgItem(IDC_ID_VALUE)->GetWindowText(buf, 6);
_ID = StringToID(buf);
_ID = StringToID(tStrToUtf8(buf).c_str());
if (_ID)
{
GetDlgItem(IDOK)->EnableWindow(TRUE);

View file

@ -114,7 +114,7 @@ void CLocatedBindableDialog::init(CParticleDlg* pParent)
// z-test
((CButton *) GetDlgItem(IDC_ZTEST))->SetCheck(material->isZTestEnabled() ? BST_CHECKED : BST_UNCHECKED);
// z-bias
GetDlgItem(IDC_ZBIAS)->SetWindowText(NLMISC::toString("%.2f", -material->getZBias()).c_str());
GetDlgItem(IDC_ZBIAS)->SetWindowText(utf8ToTStr(NLMISC::toString("%.2f", -material->getZBias())));
}
else
{

View file

@ -322,7 +322,7 @@ void CLocatedProperties::goPostRender()
_MaxNbParticles->update();
}
// in all cases, show the current number of particles being used
GetDlgItem(IDC_CURR_NUM_PARTS)->SetWindowText(NLMISC::toString(_Located->getSize()).c_str());
GetDlgItem(IDC_CURR_NUM_PARTS)->SetWindowText(utf8ToTStr(NLMISC::toString(_Located->getSize())));
}
//****************************************************************************************************************

View file

@ -112,8 +112,8 @@ void CLocatedTargetDlg::OnAddTarget()
nlassert(loc);
_LBTarget->attachTarget(loc);
m_AvailableTargets.DeleteString(indexs[k] - k);
int l = m_Targets.AddString(loc->getName().c_str());
m_Targets.SetItemData(l, (DWORD) loc);
int l = m_Targets.AddString(utf8ToTStr(loc->getName()));
m_Targets.SetItemData(l, (DWORD_PTR) loc);
}
UpdateData(FALSE);
//
@ -135,7 +135,7 @@ void CLocatedTargetDlg::OnRemoveTarget()
nlassert(loc);
_LBTarget->detachTarget(loc);
m_Targets.DeleteString(indexs[k] - k);
int l = m_AvailableTargets.AddString(loc->getName().c_str());
int l = m_AvailableTargets.AddString(utf8ToTStr(loc->getName()));
m_AvailableTargets.SetItemData(l, (DWORD) loc);
}

View file

@ -574,7 +574,7 @@ void CMainFrame::OnFileLoadconfig()
{
// Open the file
CIFile file;
if (file.open ((const char*)fileDlg.GetPathName()))
if (file.open(tStrToUtf8(fileDlg.GetPathName())))
{
try
{
@ -592,7 +592,7 @@ void CMainFrame::OnFileLoadconfig()
}
catch (Exception& e)
{
MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
}
}
else
@ -685,7 +685,7 @@ void CMainFrame::OnFileOpen()
if (name.Find(_T(".ig")) != -1)
{
// Load the instance group
if (ObjView->loadInstanceGroup (name))
if (ObjView->loadInstanceGroup (tStrToUtf8(name)))
{
// Reset the camera
OnResetCamera();
@ -697,7 +697,7 @@ void CMainFrame::OnFileOpen()
else
{
// Add it in the array
meshFilename.push_back ((const char*)name);
meshFilename.push_back (tStrToUtf8(name));
}
}
@ -710,7 +710,7 @@ void CMainFrame::OnFileOpen()
if (fileDlg2.DoModal()==IDOK)
{
// Load the shape with a skeleton
if (ObjView->loadMesh (meshFilename, fileDlg2.GetPathName()))
if (ObjView->loadMesh (meshFilename, tStrToUtf8(fileDlg2.GetPathName())))
{
// Reset the camera
OnResetCamera();
@ -756,7 +756,7 @@ void CMainFrame::OnFileSaveconfig()
}
// Open the file
COFile file;
if (file.open ((const char*)fileDlg.GetPathName()))
if (file.open (tStrToUtf8(fileDlg.GetPathName())))
{
try
{
@ -764,7 +764,7 @@ void CMainFrame::OnFileSaveconfig()
}
catch (Exception& e)
{
MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
}
}
else
@ -832,7 +832,7 @@ void CMainFrame::OnViewSetmovespeed()
if (valueDlg.DoModal ()==IDOK)
{
// Get deflaut value
sscanf ((const char*)valueDlg.Value, "%f", &MoveSpeed);
NLMISC::fromString(tStrToUtf8(valueDlg.Value), MoveSpeed);
}
}
@ -1392,9 +1392,10 @@ void CMainFrame::OnViewSetSceneRotation()
if (sceneRotDlg.DoModal() == IDOK)
{
// read value.
_LastSceneRotX= (float)atof(sceneRotDlg.RotX);
_LastSceneRotY= (float)atof(sceneRotDlg.RotY);
_LastSceneRotZ= (float)atof(sceneRotDlg.RotZ);
NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotX), _LastSceneRotX);
NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotY), _LastSceneRotY);
NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotZ), _LastSceneRotZ);
float rotx= degToRad(_LastSceneRotX);
float roty= degToRad(_LastSceneRotY);
float rotz= degToRad(_LastSceneRotZ);
@ -1441,7 +1442,8 @@ void CMainFrame::OnUpdateSceneCamera(CCmdUI* pCmdUI)
{
CInstanceInfo *instance = ObjView->getInstance (ObjView->getCameraInstance (pCmdUI->m_nID - ID_SCENE_CAMERA_FIRST));
nlassert (instance->Camera);
pCmdUI->SetText (("Camera "+instance->Saved.ShapeFilename).c_str ());
std::string text = NLMISC::toString("Camera %s", instance->Saved.ShapeFilename.c_str());
pCmdUI->SetText(utf8ToTStr(text));
}
else
{

View file

@ -114,7 +114,7 @@ void CMeshDlg::OnBrowseShape()
}
catch (NLMISC::Exception &e)
{
MessageBox(e.what(), "shape loading error");
MessageBox(utf8ToTStr(e.what()), _T("shape loading error"));
}
updateMeshErrorString();
}

View file

@ -165,19 +165,19 @@ void CMultiTexDlg::readValues(bool alternate)
char buf[128];
if (!alternate)
{
sprintf(buf, "%.3f", _MTP->getScrollSpeed(0).x); GetDlgItem(IDC_U_SPEED_1)->SetWindowText(buf);
sprintf(buf, "%.3f", _MTP->getScrollSpeed(0).y); GetDlgItem(IDC_V_SPEED_1)->SetWindowText(buf);
sprintf(buf, "%.3f", _MTP->getScrollSpeed(1).x); GetDlgItem(IDC_U_SPEED_2)->SetWindowText(buf);
sprintf(buf, "%.3f", _MTP->getScrollSpeed(1).y); GetDlgItem(IDC_V_SPEED_2)->SetWindowText(buf);
GetDlgItem(IDC_U_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).x)));
GetDlgItem(IDC_V_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).y)));
GetDlgItem(IDC_U_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).x)));
GetDlgItem(IDC_V_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).y)));
}
else
{
if (_MTP->isAlternateTexEnabled())
{
sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(0).x); GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(buf);
sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(0).y); GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(buf);
sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(1).x); GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(buf);
sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(1).y); GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(buf);
GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).x)));
GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).y)));
GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).x)));
GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).y)));
}
else
{
@ -187,7 +187,6 @@ void CMultiTexDlg::readValues(bool alternate)
GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(_T(""));
}
}
sprintf(buf, "%.3f", _MTP->getBumpFactor()); GetDlgItem(IDC_BUMP_FACTOR)->SetWindowText(buf);
}

View file

@ -284,9 +284,10 @@ std::string CObjectViewer::getModulePath() const
TCHAR sModulePath[256];
int res = GetModuleFileName(hModule, sModulePath, 256); nlassert(res);
nldebug("Object viewer module path is '%s'", sModulePath);
_splitpath (sModulePath, SDrive, SDir, NULL, NULL);
_makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg");
return sModulePath;
std::string path = NLMISC::CFile::getPath(tStrToUtf8(sModulePath));
return NLMISC::CPath::standardizeDosPath(path) + "object_viewer.cfg";
}
@ -535,7 +536,7 @@ void CObjectViewer::loadConfigFile()
}
catch (Exception& e)
{
::MessageBox (NULL, e.what(), "Objectviewer.cfg", MB_OK|MB_ICONEXCLAMATION);
::MessageBox (NULL, utf8ToTStr(e.what()), _T("Objectviewer.cfg"), MB_OK|MB_ICONEXCLAMATION);
}
}
@ -615,14 +616,14 @@ bool CObjectViewer::initUI (HWND parent)
// The windows path
uint dSize = ::GetWindowsDirectory(NULL, 0);
nlverify(dSize);
char *wd = new char[dSize];
TCHAR *wd = new TCHAR[dSize];
nlverify(::GetWindowsDirectory(wd, dSize));
_FontPath=wd;
_FontPath+="\\fonts\\arial.ttf";
_FontPath = tStrToUtf8(wd) + "\\fonts\\arial.ttf";
delete[] wd;
// The font generator
_FontGenerator = NL3D::newCFontGenerator ( _FontPath );
delete[] wd;
// The viewport
CViewport viewport;
@ -823,7 +824,8 @@ bool CObjectViewer::initUI (HWND parent)
}
catch (NLMISC::EStream &e)
{
::MessageBox(NULL, ("Unable to load the default scheme bank file : " + std::string(e.what())).c_str(), "Object Viewer", MB_ICONEXCLAMATION);
std::string msg = toString("Unable to load the default scheme bank file : %s", e.what());
::MessageBox(NULL, utf8ToTStr(msg), _T("Object Viewer"), MB_ICONEXCLAMATION);
}
}
iF.close();
@ -838,7 +840,8 @@ bool CObjectViewer::initUI (HWND parent)
}
catch (Exception& e)
{
::MessageBox (NULL, (std::string("error while loading default.ovcgf : ") + e.what()).c_str(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string msg = toString("Error while loading default.ovcgf : %s", e.what());
::MessageBox (NULL, utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
}
}
@ -1286,7 +1289,6 @@ void CObjectViewer::go ()
sint64 timeDiff = newTime - lastTime;
float fps = timeDiff > 0 ? (float)(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime)) : 1000.0f;
lastTime=newTime;
char msgBar[1024];
uint nbPlayingSources, nbSources;
if (CSoundSystem::getAudioMixer())
{
@ -1299,17 +1301,19 @@ void CObjectViewer::go ()
}
// Display std info.
sprintf (msgBar, "%s - Nb tri: %d -Texture used (Mo): %5.2f - Texture allocated (Mo): %5.2f - Distance: %5.0f - Sounds: %d/%d - Fps: %03.1f",
_Direct3d?"Direct3d":"OpenGL",
in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips, (float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024),
(float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024),
(_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(),
nbPlayingSources,
nbSources,
fps
);
std::string msgBar = toString("%s - Nb tri: %u - Texture used (MiB): %5.2f - Texture allocated (MiB): %5.2f - Distance: %5.0f - Sounds: %u/%u - Fps: %03.1f",
_Direct3d ? "Direct3d":"OpenGL",
in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips,
(float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024),
(float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024),
(_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(),
nbPlayingSources,
nbSources,
fps
);
// Display
_MainFrame->StatusBar.SetWindowText (msgBar);
_MainFrame->StatusBar.SetWindowText (utf8ToTStr(msgBar));
// Display Vegetable info.
if(_VegetableDlg!=NULL)
@ -1790,9 +1794,8 @@ void CObjectViewer::serial (NLMISC::IStream& f)
else
{
// Error message
char message[512];
smprintf (message, 512, "File not found %s", readed[i].ShapeFilename.c_str());
_MainFrame->MessageBox (message, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string message = toString("File not found %s", readed[i].ShapeFilename.c_str());
_MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
// Stop loading
break;
@ -1826,9 +1829,8 @@ void CObjectViewer::serial (NLMISC::IStream& f)
catch (Exception &e)
{
// Error message
char message[512];
smprintf (message, 512, "Error loading shape %s: %s", readed[i].ShapeFilename.c_str(), e.what());
_MainFrame->MessageBox (message, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string message = toString("Error loading shape %s: %s", readed[i].ShapeFilename.c_str(), e.what());
_MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
// Stop loading
break;
@ -1872,20 +1874,12 @@ void CObjectViewer::serial (NLMISC::IStream& f)
// ***************************************************************************
bool CObjectViewer::loadInstanceGroup(const char *igFilename)
bool CObjectViewer::loadInstanceGroup(const std::string &igFilename)
{
//AFX_MANAGE_STATE(AfxGetStaticModuleState());
// Add to the path
char drive[256];
char dir[256];
char path[256];
// Add search path for the mesh
_splitpath (igFilename, drive, dir, NULL, NULL);
_makepath (path, drive, dir, NULL, NULL);
CPath::addSearchPath (path);
CPath::addSearchPath (NLMISC::CFile::getPath(igFilename));
// Open a file
CIFile file;
@ -1906,16 +1900,15 @@ bool CObjectViewer::loadInstanceGroup(const char *igFilename)
{
// clean
delete ig;
_MainFrame->MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
return false;
}
}
else
{
// Create a message
char msg[512];
_snprintf (msg, 512, "Can't open the file %s for reading.", igFilename);
_MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string msg = toString("Can't open the file %s for reading.", igFilename.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
return false;
}
@ -1928,21 +1921,16 @@ bool CObjectViewer::loadInstanceGroup(const char *igFilename)
// ***************************************************************************
bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char* skeleton)
bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const std::string &skeleton)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// Add to the path
char drive[256];
char dir[256];
char path[256];
// Add search path for the skeleton
if (skeleton)
if (skeleton.empty())
{
_splitpath (skeleton, drive, dir, NULL, NULL);
_makepath (path, drive, dir, NULL, NULL);
CPath::addSearchPath (path);
CPath::addSearchPath (NLMISC::CFile::getPath(skeleton));
}
// Open a file
@ -1957,7 +1945,7 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
bool skelError=false;
// Continue ?
if (skeleton&&(strcmp (skeleton, "")!=0))
if (!skeleton.empty())
{
// Open a file
@ -1975,7 +1963,7 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
}
catch (Exception& e)
{
_MainFrame->MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
// error
skelError=true;
@ -1984,9 +1972,8 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
else
{
// Create a message
char msg[512];
_snprintf (msg, 512, "Can't open the file %s for reading.", meshFilename);
_MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string msg = NLMISC::toString("Can't open the file %s for reading.", skeleton.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
// error
skelError=true;
@ -2007,12 +1994,10 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
for (uint i=0; i<meshFilename.size(); i++)
{
// Filename
const char *fileName = meshFilename[i].c_str();
const std::string fileName = meshFilename[i];
// Add search path for the mesh
_splitpath (fileName, drive, dir, NULL, NULL);
_makepath (path, drive, dir, NULL, NULL);
CPath::addSearchPath (path);
CPath::addSearchPath (NLMISC::CFile::getPath(fileName));
// Shape pointer
IShape *shapeMesh=NULL;
@ -2031,16 +2016,15 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
}
catch (Exception& e)
{
_MainFrame->MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
continue;
}
}
else
{
// Create a message
char msg[512];
_snprintf (msg, 512, "Can't open the file %s for reading.", fileName);
_MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
continue;
}
@ -2097,7 +2081,7 @@ void CObjectViewer::resetCamera ()
// ***************************************************************************
uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const char* meshName, uint skelIndex, const char* bindSkelName, bool createInstance)
uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const std::string &meshName, uint skelIndex, const char* bindSkelName, bool createInstance)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -2195,8 +2179,7 @@ uint CObjectViewer::addMesh (NL3D::IShape* pMeshShape, const char* meshName, uin
listBones.push_back (transformSkel->Bones[bone].getBoneName());
// Get name of the mesh
char nameMesh[512];
_splitpath (meshName, NULL, NULL, nameMesh, NULL);
std::string nameMesh = NLMISC::CFile::getFilenameWithoutExtension(meshName);
// Select a bones
std::string message = "Select a bone to stick " + string (nameMesh);
@ -2280,7 +2263,7 @@ bool CObjectViewer::isSkeletonPresent() const
// ***************************************************************************
uint CObjectViewer::addCamera (const NL3D::CCameraInfo &cameraInfo, const char* cameraName)
uint CObjectViewer::addCamera (const NL3D::CCameraInfo &cameraInfo, const std::string &cameraName)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -2315,7 +2298,7 @@ uint CObjectViewer::addCamera (const NL3D::CCameraInfo &cameraInfo, const char*
// ***************************************************************************
uint CObjectViewer::addSkel (NL3D::IShape* pSkelShape, const char* skelName)
uint CObjectViewer::addSkel (NL3D::IShape* pSkelShape, const std::string &skelName)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -2398,7 +2381,7 @@ void IObjectViewer::releaseInterface (IObjectViewer* view)
// ***************************************************************************
void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const char* name, uint instance)
void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const std::string &name, uint instance)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -2408,7 +2391,7 @@ void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const char* nam
_SelectedObject = instance;
// Add the animation
addAnimation (pAnim, (name+std::string(".anim")).c_str(), name, instance);
addAnimation (pAnim, name + ".anim", name, instance);
// Add the animation to the animationSet
_AnimationSetDlg->UpdateData (TRUE);
@ -2866,7 +2849,7 @@ void CObjectViewer::enableDynamicObjectLightingTest(NLPACS::CGlobalRetriever *gl
if (!_ObjectLightTestShape.empty())
{
string str= string("Path not found for Light Test Shape: ") + _ObjectLightTestShape;
::MessageBox(NULL, str.c_str(), "Dynamic Object Light Test", MB_OK|MB_ICONEXCLAMATION);
::MessageBox(NULL, utf8ToTStr(str.c_str()), _T("Dynamic Object Light Test"), MB_OK|MB_ICONEXCLAMATION);
}
// disable.
_ObjectLightTest= NULL;
@ -3241,7 +3224,7 @@ bool CObjectViewer::createVegetableLandscape()
// close the progress dialog
dlgProgress.DestroyWindow();
MessageBox(_MainFrame->m_hWnd, e.what(), "Failed to Load landscape", MB_OK | MB_APPLMODAL);
MessageBox(_MainFrame->m_hWnd, utf8ToTStr(e.what()), _T("Failed to Load landscape"), MB_OK | MB_APPLMODAL);
// remove first possibly created collisions objects.
if(_VegetableCollisionEntity)
@ -3536,10 +3519,10 @@ void CObjectViewer::refreshAnimationListeners()
}
// ***************************************************************************
void CObjectViewer::addAnimation (NL3D::CAnimation* anim, const char* filename, const char* name, uint instance)
void CObjectViewer::addAnimation(NL3D::CAnimation* anim, const std::string &filename, const std::string &name, uint instance)
{
// Add an animation
uint id = _ListInstance[instance]->AnimationSet.addAnimation (name, anim);
uint id = _ListInstance[instance]->AnimationSet.addAnimation (name.c_str(), anim);
_ListInstance[instance]->Saved.AnimationFileName.push_back (filename);
// Rebuild the animationSet
@ -3553,15 +3536,14 @@ void CObjectViewer::addAnimation (NL3D::CAnimation* anim, const char* filename,
}
// ***************************************************************************
void CObjectViewer::loadAnimation (const char* fileName, uint instance)
void CObjectViewer::loadAnimation(const std::string &fileName, uint instance)
{
// Open the file
CIFile file;
if (file.open (fileName))
{
// Get the animation name
char name[256];
_splitpath (fileName, NULL, NULL, name, NULL);
std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName);
// Make an animation
CAnimation *anim=new CAnimation;
@ -3575,22 +3557,20 @@ void CObjectViewer::loadAnimation (const char* fileName, uint instance)
else
{
// Create a message
char msg[512];
_snprintf (msg, 512, "Can't open the file %s for reading.", fileName);
_MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
}
}
// ***************************************************************************
void CObjectViewer::loadSWT (const char* fileName, uint instance)
void CObjectViewer::loadSWT (const std::string &fileName, uint instance)
{
// Open the file
CIFile file;
if (file.open (fileName))
{
// Get the animation name
char name[256];
_splitpath (fileName, NULL, NULL, name, NULL);
std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName);
// Get the skeleton pointer
CSkeletonWeight* skel=new CSkeletonWeight;
@ -3599,7 +3579,7 @@ void CObjectViewer::loadSWT (const char* fileName, uint instance)
skel->serial (file);
// Add an animation
_ListInstance[instance]->AnimationSet.addSkeletonWeight (name, skel);
_ListInstance[instance]->AnimationSet.addSkeletonWeight (name.c_str(), skel);
// Add the filename in the list
_ListInstance[instance]->Saved.SWTFileName.push_back (fileName);
@ -3607,9 +3587,8 @@ void CObjectViewer::loadSWT (const char* fileName, uint instance)
else
{
// Create a message
char msg[512];
_snprintf (msg, 512, "Can't open the file %s for reading.", fileName);
_MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str());
_MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
}
}
@ -3712,8 +3691,8 @@ void CObjectViewer::shootScene()
CNELU::Driver->setupViewport (CViewport ());
// The file name
string filename = NLMISC::CFile::getFilenameWithoutExtension ((const char*)fileDlg.GetPathName ());
string extension = NLMISC::CFile::getExtension ((const char*)fileDlg.GetPathName ());
string filename = NLMISC::CFile::getFilenameWithoutExtension(tStrToUtf8(fileDlg.GetPathName()));
string extension = NLMISC::CFile::getExtension (tStrToUtf8(fileDlg.GetPathName()));
// The file name without extension
bool jpeg = toLower (extension) == "jpg";
@ -3792,13 +3771,15 @@ void CObjectViewer::shootScene()
}
else
{
_MainFrame->MessageBox (("Can't open the file "+filenamefinal+" for writing.").c_str (), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string message = toString("Can't open the file %s for writing.", filenamefinal.c_str());
_MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
break;
}
}
catch (Exception &e)
{
_MainFrame->MessageBox (("Error during writing of the file "+filenamefinal+" : "+(string)e.what ()).c_str (), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
std::string message = toString("Error during writing of the file %s: %s", filenamefinal.c_str(), e.what());
_MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
break;
}
}
@ -3815,7 +3796,7 @@ void CObjectViewer::drawFXUserMatrix()
{
CString fxUserMatrix;
fxUserMatrix.LoadString(IDS_FX_USER_MATRIX);
fxUserMatrixStr = (LPCTSTR) fxUserMatrix;
fxUserMatrixStr = tStrToUtf8(fxUserMatrix);
stringRetrieved = true;
}
nlassert(_ParticleDlg);
@ -3830,7 +3811,7 @@ void CObjectViewer::drawFXMatrix()
{
CString fx;
fx.LoadString(IDS_FX_MATRIX);
fxStr = (LPCTSTR) fx;
fxStr = tStrToUtf8(fx);
stringRetrieved = true;
}
drawNamedMatrix(_ParticleDlg->getPSWorldMatrix(), fxStr, NLMISC::CRGBA::Blue, -0.2f, 10.f);
@ -3844,7 +3825,7 @@ void CObjectViewer::drawSceneMatrix()
{
CString sceneMatrix;
sceneMatrix.LoadString(IDS_SCENE_MATRIX);
sceneMatrixStr = (LPCTSTR) sceneMatrix;
sceneMatrixStr = tStrToUtf8(sceneMatrix);
stringRetrieved = true;
}
drawNamedMatrix(_SceneRoot->getMatrix(), sceneMatrixStr, NLMISC::CRGBA::White, 0.f, 10.f);

View file

@ -234,19 +234,19 @@ public:
void releaseUI ();
// Set single animtion.
void setSingleAnimation (NL3D::CAnimation* pAnim, const char* name, uint instance);
void setSingleAnimation (NL3D::CAnimation* pAnim, const std::string &name, uint instance);
// Set automatic animation
void setAutoAnimation (NL3D::CAnimationSet* pAnimSet);
// Add a mesh
uint addMesh (NL3D::IShape* pMeshShape, const char* meshName, uint skelIndex, const char* bindSkelName = NULL, bool createInstance = true);
uint addMesh(NL3D::IShape* pMeshShape, const std::string &meshName, uint skelIndex, const char* bindSkelName = NULL, bool createInstance = true);
// Add a camera
uint addCamera (const NL3D::CCameraInfo &cameraInfo, const char* cameraName);
uint addCamera (const NL3D::CCameraInfo &cameraInfo, const std::string &cameraName);
// Add a skel
uint addSkel (NL3D::IShape* pSkelShape, const char* skelName);
uint addSkel (NL3D::IShape* pSkelShape, const std::string &skelName);
// remove all instances from the scene
void removeAllInstancesFromScene();
@ -262,10 +262,10 @@ public:
void shuffleTextureSet();
// Load a mesh
bool loadMesh (std::vector<std::string> &meshFilename, const char* skeleton="");
bool loadMesh (std::vector<std::string> &meshFilename, const std::string &skeleton = "");
// Load an instance group
bool loadInstanceGroup(const char *igFilename);
bool loadInstanceGroup(const std::string &igFilename);
// Set ambient color
void setAmbientColor (const NLMISC::CRGBA& color);
@ -289,7 +289,7 @@ public:
uint getNumInstance () const;
// Add an animation
void addAnimation (NL3D::CAnimation* anim, const char* filename, const char* name, uint instance);
void addAnimation (NL3D::CAnimation* anim, const std::string &filename, const std::string &name, uint instance);
// Update all objects that depend on the animation set
void refreshAnimationListeners();
@ -308,10 +308,10 @@ public:
CChooseFrameDelay *getFrameDelayDlg() const { return _ChooseFrameDelayDlg; }
// Load animation
void loadAnimation (const char* fileName, uint instance);
void loadAnimation(const std::string &fileName, uint instance);
// Load a skeleton template
void loadSWT (const char* fileName, uint instance);
void loadSWT(const std::string &fileName, uint instance);
/// Not exported
@ -387,7 +387,7 @@ public:
/// inherited from CObjectViewerInterface
void setWaterPoolManager(NL3D::CWaterPoolManager &wpm) { _Wpm = &wpm; }
NL3D::CWaterPoolManager &getWaterPoolManager() { return *_Wpm; }
NL3D::CWaterPoolManager &getWaterPoolManager() const { return *_Wpm; }
// Reload textures
void reloadTextures ();

View file

@ -69,25 +69,25 @@ public:
virtual void releaseUI () = 0;
// Add a mesh
virtual uint addMesh (NL3D::IShape* pMeshShape, const char* meshName, uint skelIndex, const char* bindSkelName = NULL, bool createInstance = true) = 0;
virtual uint addMesh(NL3D::IShape* pMeshShape, const std::string &meshName, uint skelIndex, const char* bindSkelName = NULL, bool createInstance = true) = 0;
// Add a skel
virtual uint addSkel (NL3D::IShape* pSkelShape, const char* skelName) = 0;
virtual uint addSkel (NL3D::IShape* pSkelShape, const std::string &skelName) = 0;
// Add a camera
virtual uint addCamera (const NL3D::CCameraInfo &cameraInfo, const char* cameraName) = 0;
virtual uint addCamera (const NL3D::CCameraInfo &cameraInfo, const std::string &cameraName) = 0;
// remove all the instance from the scene
virtual void removeAllInstancesFromScene() = 0;
// Load a mesh
virtual bool loadMesh (std::vector<std::string> &meshFilename, const char* skeleton) = 0;
virtual bool loadMesh (std::vector<std::string> &meshFilename, const std::string &skeleton) = 0;
// Load a shape
virtual void resetCamera () = 0;
// Set single animation
virtual void setSingleAnimation (NL3D::CAnimation* pAnim, const char* name, uint instance) = 0;
virtual void setSingleAnimation (NL3D::CAnimation* pAnim, const std::string &name, uint instance) = 0;
// Set automatic animation
virtual void setAutoAnimation (NL3D::CAnimationSet* pAnimSet) = 0;

View file

@ -428,7 +428,7 @@ bool CParticleDlg::savePSAs(HWND parent, CParticleWorkspace::CNode &psNode ,cons
}
else
{
::MessageBox(parent, e.what(), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
::MessageBox(parent, utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
return false;
}
}
@ -474,7 +474,7 @@ bool CParticleDlg::loadPS(HWND parent, CParticleWorkspace::CNode &psNode, TLoadP
{
case Silent: return false; // no op
case ReportError:
::MessageBox(parent, e.what(), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION);
::MessageBox(parent, utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION);
return true;
break;
case ReportErrorSkippable:
@ -549,7 +549,7 @@ void CParticleDlg::OnCreateNewPsWorkspace()
}
catch(NLMISC::EStream &e)
{
MessageBox(e.what(), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
MessageBox(utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
}
closeWorkspace();
_PW = newPW;
@ -567,7 +567,7 @@ void CParticleDlg::OnLoadPSWorkspace()
CFileDialog fd( TRUE, _T(".pws"), _T("*.pws"), 0, szFilter);
INT_PTR result = fd.DoModal();
if (result != IDOK) return;
loadWorkspace((LPCTSTR) fd.GetPathName());
loadWorkspace(tStrToUtf8(fd.GetPathName()));
}
//**************************************************************************************************************************
@ -585,7 +585,7 @@ void CParticleDlg::loadWorkspace(const std::string &fullPath)
}
catch(NLMISC::EStream &e)
{
MessageBox(e.what(), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
MessageBox(utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_ICONEXCLAMATION);
setStatusBarText(CString(e.what()));
return;
}
@ -635,7 +635,7 @@ void CParticleDlg::saveWorkspaceStructure()
}
catch(NLMISC::EStream &e)
{
localizedMessageBox(*this, e.what(), IDS_ERROR, MB_ICONEXCLAMATION);
localizedMessageBox(*this, utf8ToTStr(e.what()), IDS_ERROR, MB_ICONEXCLAMATION);
setStatusBarText(CString(e.what()));
}
}

View file

@ -213,7 +213,7 @@ HTREEITEM CParticleTreeCtrl::buildTreeFromPS(CParticleWorkspace::CNode &node, H
if (node.isLoaded())
{
// bind particle system icon
HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, computeCaption(node).c_str(), PSIconParticleSystem, PSIconParticleSystem, 0, 0, NULL, rootHandle, prevSibling);
HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, utf8ToTStr(computeCaption(node)), PSIconParticleSystem, PSIconParticleSystem, 0, 0, NULL, rootHandle, prevSibling);
// set the param (doesn't seems to work during first creation)
SetItemData(psRoot, (LPARAM) nt);
// now, create each located
@ -228,7 +228,7 @@ HTREEITEM CParticleTreeCtrl::buildTreeFromPS(CParticleWorkspace::CNode &node, H
else
{
// bind a bitmap that say that the PS hasn't been loaded
HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, computeCaption(node).c_str(), PSIconParticleSystemNotLoaded, PSIconParticleSystemNotLoaded, 0, 0, NULL, rootHandle, prevSibling);
HTREEITEM psRoot = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, utf8ToTStr(computeCaption(node)), PSIconParticleSystemNotLoaded, PSIconParticleSystemNotLoaded, 0, 0, NULL, rootHandle, prevSibling);
SetItemData(psRoot, (LPARAM) nt);
return psRoot;
}
@ -242,7 +242,7 @@ void CParticleTreeCtrl::buildTreeFromWorkSpace(CParticleWorkspace &ws)
CNodeType *nt = new CNodeType(&ws);
_NodeTypes.push_back(nt);
// bind particle system icon
HTREEITEM rootHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, computeCaption(ws).c_str(), PSIconWorkspace, PSIconWorkspace, 0, 0, NULL, NULL, TVI_LAST);
HTREEITEM rootHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT, utf8ToTStr(computeCaption(ws)), PSIconWorkspace, PSIconWorkspace, 0, 0, NULL, NULL, TVI_LAST);
// set the param (doesn't seems to work during first creation)
SetItemData(rootHandle, (LPARAM) nt);
// now, create each particle system
@ -259,7 +259,7 @@ void CParticleTreeCtrl::createNodeFromLocated(NL3D::CPSLocated *loc, HTREEITEM
CNodeType *nt = new CNodeType(loc);
_NodeTypes.push_back(nt);
// bind located icon
HTREEITEM nodeHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM |TVIF_TEXT, loc->getName().c_str() , PSIconLocated, PSIconLocated, 0, 0, (LPARAM) nt, rootHandle, TVI_LAST);
HTREEITEM nodeHandle = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM |TVIF_TEXT, utf8ToTStr(loc->getName()) , PSIconLocated, PSIconLocated, 0, 0, (LPARAM) nt, rootHandle, TVI_LAST);
// now, insert each object that is bound to the located
for (uint l = 0; l < loc->getNbBoundObjects(); ++l)
{
@ -273,7 +273,7 @@ void CParticleTreeCtrl::createNodeFromLocatedBindable(NL3D::CPSLocatedBindable *
// we ordered the image so that they match the type for a located bindable (force, particles, collision zones...)
CNodeType *nt = new CNodeType(lb);
_NodeTypes.push_back(nt);
InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT , lb->getName().c_str() , lb->getType(), lb->getType(), PSIconForce, PSIconForce, (LPARAM) nt, rootHandle, TVI_LAST);
InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT , utf8ToTStr(lb->getName()) , lb->getType(), lb->getType(), PSIconForce, PSIconForce, (LPARAM) nt, rootHandle, TVI_LAST);
}
@ -1002,23 +1002,19 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA
{
CParticleWorkspace::CNode *ownerNode = getOwnerNode(nt);
nlassert(ownerNode);
// Add to the path
char drive[256];
char dir[256];
char path[256];
// Add search path for the texture
_splitpath (fd.GetPathName(), drive, dir, NULL, NULL);
_makepath (path, drive, dir, NULL, NULL);
NLMISC::CPath::addSearchPath (path);
NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())));
std::auto_ptr<NL3D::CShapeBank> sb(new NL3D::CShapeBank);
CParticleSystemModel *psm = NULL;
try
{
NL3D::CShapeStream ss;
NLMISC::CIFile inputFile;
inputFile.open((LPCTSTR) fd.GetPathName());
inputFile.open(tStrToUtf8(fd.GetPathName()));
ss.serial(inputFile);
std::string shapeName = NLMISC::CFile::getFilename((LPCTSTR) fd.GetPathName());
std::string shapeName = NLMISC::CFile::getFilename(tStrToUtf8(fd.GetPathName()));
sb->add(shapeName, ss.getShapePointer());
NL3D::CShapeBank *oldSB = CNELU::Scene->getShapeBank();
CNELU::Scene->setShapeBank(sb.get());
@ -1043,7 +1039,7 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA
}
catch(NLMISC::EStream &e)
{
MessageBox(e.what(), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION);
MessageBox(utf8ToTStr(e.what()), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION);
return TRUE;
}
ownerNode->setResetAutoCountFlag(false);
@ -1099,11 +1095,11 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA
{
_ParticleDlg->StartStopDlg->stop();
std::string fileName = nt->PS->getFilename();
static char BASED_CODE szFilter[] = "ps & shapes files(*.ps;*.shape)|*.ps; *.shape||";
CFileDialog fd(FALSE, ".ps", fileName.c_str(), OFN_OVERWRITEPROMPT, szFilter, this);
static TCHAR BASED_CODE szFilter[] = _T("ps & shapes files(*.ps;*.shape)|*.ps; *.shape||");
CFileDialog fd(FALSE, _T(".ps"), utf8ToTStr(fileName), OFN_OVERWRITEPROMPT, szFilter, this);
if (fd.DoModal() == IDOK)
{
_ParticleDlg->savePSAs(*this, *nt->PS, (LPCTSTR) fd.GetPathName(), false);
_ParticleDlg->savePSAs(*this, *nt->PS, tStrToUtf8(fd.GetPathName()), false);
}
}
}
@ -1253,7 +1249,7 @@ BOOL CParticleTreeCtrl::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHA
}
getOwnerNode(nt)->setModified(true);
// TODO : an enum for CPSLocatedBindable::getType would be better...
InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, toCreate->getName().c_str(), toCreate->getType(), toCreate->getType(), 0, 0, (LPARAM) newNt, father, lastSon);
InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, utf8ToTStr(toCreate->getName()), toCreate->getType(), toCreate->getType(), 0, 0, (LPARAM) newNt, father, lastSon);
touchPSState(nt);
Invalidate();
_ParticleDlg->StartStopDlg->resetAutoCount(getOwnerNode(nt));
@ -1284,7 +1280,7 @@ std::pair<CParticleTreeCtrl::CNodeType *, HTREEITEM> CParticleTreeCtrl::createL
CNodeType *newNt = new CNodeType(loc);
_NodeTypes.push_back(newNt);
// insert item in tree
HTREEITEM insertedItem = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, name.c_str(), PSIconLocated, PSIconLocated, 0, 0, (LPARAM) newNt, headItem, TVI_LAST);
HTREEITEM insertedItem = InsertItem(TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM | TVIF_TEXT, utf8ToTStr(name), PSIconLocated, PSIconLocated, 0, 0, (LPARAM) newNt, headItem, TVI_LAST);
touchPSState(newNt);
return std::make_pair(newNt, insertedItem);
}
@ -1303,7 +1299,7 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
{
case CNodeType::workspace:
{
nt->WS->setName(std::string(info->item.pszText));
nt->WS->setName(tStrToUtf8(info->item.pszText));
workspaceModifiedFlagChanged(*nt->WS); // change name (this may be called twice because of the modification callback, but this doesn't matter)
}
break;
@ -1315,10 +1311,10 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
}
else
{
nt->PS->getPSPointer()->setName(std::string(info->item.pszText));
nt->PS->getPSPointer()->setName(tStrToUtf8(info->item.pszText));
nt->PS->setModified(true);
}
this->SetItemText(info->item.hItem, computeCaption(*nt->PS).c_str());
this->SetItemText(info->item.hItem, utf8ToTStr(computeCaption(*nt->PS)));
}
break;
case CNodeType::located:
@ -1326,7 +1322,7 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
nlassert(getOwnerNode(nt));
getOwnerNode(nt)->setModified(true);
this->SetItemText(info->item.hItem, info->item.pszText);
nt->Loc->setName(std::string(info->item.pszText));
nt->Loc->setName(tStrToUtf8(info->item.pszText));
}
break;
case CNodeType::locatedBindable:
@ -1334,7 +1330,7 @@ void CParticleTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
nlassert(getOwnerNode(nt));
getOwnerNode(nt)->setModified(true);
this->SetItemText(info->item.hItem, info->item.pszText);
nt->Bind->setName(std::string(info->item.pszText));
nt->Bind->setName(tStrToUtf8(info->item.pszText));
}
break;
}
@ -1470,7 +1466,7 @@ void CParticleTreeCtrl::updateCaption(CParticleWorkspace::CNode &node)
HTREEITEM item = getTreeItem(&node);
if (!item) return;
// update name of ps to dipslay a star in front of it (this tells that the ps has been modified)
SetItemText(item, computeCaption(node).c_str());
SetItemText(item, utf8ToTStr(computeCaption(node)));
}
//****************************************************************************************************************
@ -1547,7 +1543,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws)
while (pos)
{
CString path = fd.GetNextPathName(pos);
CParticleWorkspace::CNode *node = pws.addNode((LPCTSTR) path);
CParticleWorkspace::CNode *node = pws.addNode(tStrToUtf8(path));
if (!node)
{
if (diplayNodeAlreadyInserted)
@ -1560,7 +1556,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws)
}
else
{
MessageBox(NLMISC::CFile::getFilename((LPCTSTR)path).c_str() + getStrRsc(IDS_PS_ALREADY_INSERTED), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION);
MessageBox(CString(utf8ToTStr(NLMISC::CFile::getFilename(tStrToUtf8(path)))) + getStrRsc(IDS_PS_ALREADY_INSERTED), getStrRsc(IDS_ERROR), MB_OK|MB_ICONEXCLAMATION);
}
}
continue;
@ -1595,7 +1591,7 @@ void CParticleTreeCtrl::insertNewPS(CParticleWorkspace &pws)
}
}
// update modified state
SetItemText(GetRootItem(), computeCaption(pws).c_str());
SetItemText(GetRootItem(), utf8ToTStr(computeCaption(pws)));
}
}
@ -1738,7 +1734,7 @@ void CParticleTreeCtrl::OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
switch (nt->Type)
{
case CNodeType::workspace:
pEdit->SetWindowText(nt->WS->getName().c_str());
pEdit->SetWindowText(utf8ToTStr(nt->WS->getName()));
break;
case CNodeType::particleSystem:
{
@ -1749,18 +1745,18 @@ void CParticleTreeCtrl::OnBeginlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
}
else
{
pEdit->SetWindowText(nt->PS->getPSPointer()->getName().c_str());
pEdit->SetWindowText(utf8ToTStr(nt->PS->getPSPointer()->getName()));
}
}
break;
case CNodeType::located:
{
pEdit->SetWindowText(nt->Loc->getName().c_str());
pEdit->SetWindowText(utf8ToTStr(nt->Loc->getName()));
}
break;
case CNodeType::locatedBindable:
{
pEdit->SetWindowText(nt->Bind->getName().c_str());
pEdit->SetWindowText(utf8ToTStr(nt->Bind->getName()));
}
break;
}
@ -1857,10 +1853,10 @@ void CParticleTreeCtrl::updateAllCaptions()
switch(nt->Type)
{
case CNodeType::particleSystem:
SetItemText(curr, computeCaption(*nt->PS).c_str());
SetItemText(curr, utf8ToTStr(computeCaption(*nt->PS)));
break;
case CNodeType::workspace:
SetItemText(curr, computeCaption(*nt->WS).c_str());
SetItemText(curr, utf8ToTStr(computeCaption(*nt->WS)));
break;
case CNodeType::located:
case CNodeType::locatedBindable:

View file

@ -74,7 +74,7 @@ BOOL CPickSound::OnInitDialog()
for (TNameVect::iterator it = _Names.begin(); it != _Names.end(); ++it)
{
m_NameList.AddString((*it).toString().c_str());
m_NameList.AddString(utf8ToTStr((*it).toString()));
}
_Timer = SetTimer (1, 100, NULL);
@ -111,7 +111,7 @@ void CPickSound::OnSelchange()
nlassert(m_NameList.GetTextLen(m_NameList.GetCurSel()) < 1024);
m_NameList.GetText(m_NameList.GetCurSel(), str);
_CurrName = NLMISC::CSheetId(str, "sound");
_CurrName = NLMISC::CSheetId(tStrToUtf8(str), "sound");
}
@ -123,7 +123,7 @@ void CPickSound::OnPlaySound()
stopCurrSource();
CString sName;
m_NameList.GetText(curSel, sName);
CSoundSystem::create(std::string( (LPCTSTR) sName));
CSoundSystem::create(tStrToUtf8(sName));
}
//========================================================================================

View file

@ -124,7 +124,7 @@ void CPrecomputedRotationsDlg::OnUpdateMinRotSpeed()
nlassert(_RotatedParticle);
UpdateData();
float newValue, valueMin, valueMax;
if (sscanf(m_RotSpeedMin, "%f", &newValue) == 1)
if (NLMISC::fromString(tStrToUtf8(m_RotSpeedMin), newValue))
{
uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax);
valueMin = newValue;
@ -144,7 +144,7 @@ void CPrecomputedRotationsDlg::OnUpdateMaxRotSpeed()
nlassert(_RotatedParticle);
UpdateData();
float newValue, valueMin, valueMax;
if (sscanf(m_RotSpeedMax, "%f", &newValue) == 1)
if (NLMISC::fromString(tStrToUtf8(m_RotSpeedMax), newValue))
{
uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax);
valueMax = newValue;
@ -165,7 +165,7 @@ void CPrecomputedRotationsDlg::OnUpdateNbModels()
UpdateData();
float valueMin, valueMax;
sint32 newNbModels;
bool valid = (sscanf(m_NbModels, "%d", &newNbModels) == 1 && newNbModels > 0);
bool valid = (NLMISC::fromString(tStrToUtf8(m_NbModels), newNbModels) && newNbModels > 0);
if (dynamic_cast<NL3D::CPSConstraintMesh *>(_RotatedParticle))
{
valid &= (newNbModels < NL3D::ConstraintMeshMaxNumPrerotatedModels);

View file

@ -120,7 +120,7 @@ void CPSMoverDlg::OnUpdateXpos()
UpdateData();
NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex];
float x;
if (::sscanf(m_X, "%f", &x) == 1)
if (NLMISC::fromString(tStrToUtf8(m_X), x))
{
pos.x = x;
updateListener();
@ -137,7 +137,7 @@ void CPSMoverDlg::OnUpdateYpos()
UpdateData();
NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex];
float y;
if (::sscanf(m_Y, "%f", &y) == 1)
if (NLMISC::fromString(tStrToUtf8(m_Y), y))
{
pos.y = y;
updateListener();
@ -154,7 +154,7 @@ void CPSMoverDlg::OnUpdateZpos()
UpdateData();
NLMISC::CVector &pos = _EditedLocated->getPos()[_EditedLocatedIndex];
float z;
if (::sscanf(m_Z, "%f", &z) == 1)
if (NLMISC::fromString(tStrToUtf8(m_Z), z))
{
pos.z = z;
updateListener();

View file

@ -84,8 +84,8 @@ void CSchemeBankDlg::buildList()
SchemeManager.getSchemes(_Type, schemes);
for (TSchemeVect::const_iterator it = schemes.begin(); it != schemes.end(); ++it)
{
int index = m_SchemeList.AddString(it->first.c_str());
m_SchemeList.SetItemData(index, (unsigned long) it->second);
int index = m_SchemeList.AddString(utf8ToTStr(it->first));
m_SchemeList.SetItemData(index, (DWORD_PTR) it->second);
}
UpdateData(FALSE);
@ -98,25 +98,19 @@ void CSchemeBankDlg::OnSaveBank()
if (fd.DoModal() == IDOK)
{
// Add to the path
char drive[256];
char dir[256];
char path[256];
// Add search path for the texture
_splitpath (fd.GetPathName(), drive, dir, NULL, NULL);
_makepath (path, drive, dir, NULL, NULL);
NLMISC::CPath::addSearchPath (path);
NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())));
try
{
NLMISC::COFile iF;
iF.open(std::string( (LPCTSTR) fd.GetFileName()));
iF.open(tStrToUtf8(fd.GetFileName()));
iF.serial(SchemeManager);
}
catch (std::exception &e)
{
MessageBox(("Error saving scheme bank :" + std::string(e.what())).c_str(), "Object viewer", MB_ICONEXCLAMATION | MB_OK);
std::string message = NLMISC::toString("Error saving scheme bank : %s", e.what());
MessageBox(utf8ToTStr(message), _T("Object viewer"), MB_ICONEXCLAMATION | MB_OK);
return;
}
}
@ -129,27 +123,21 @@ void CSchemeBankDlg::OnLoadBank()
if (fd.DoModal() == IDOK)
{
// Add to the path
char drive[256];
char dir[256];
char path[256];
// Add search path for the texture
_splitpath (fd.GetPathName(), drive, dir, NULL, NULL);
_makepath (path, drive, dir, NULL, NULL);
NLMISC::CPath::addSearchPath (path);
NLMISC::CPath::addSearchPath(NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())));
CSchemeManager sm;
try
{
NLMISC::CIFile iF;
iF.open(NLMISC::CPath::lookup(std::string((LPCTSTR) fd.GetFileName())));
iF.open(NLMISC::CPath::lookup(tStrToUtf8(fd.GetFileName())));
iF.serial(sm);
SchemeManager.swap(sm);
}
catch (std::exception &e)
{
MessageBox(("Error loading scheme bank :" + std::string(e.what())).c_str(), "Object viewer", MB_ICONEXCLAMATION | MB_OK);
std::string message = NLMISC::toString("Error loading scheme bank : %s", e.what());
MessageBox(utf8ToTStr(message), _T("Object viewer"), MB_ICONEXCLAMATION | MB_OK);
return;
}
buildList();
@ -179,7 +167,7 @@ void CSchemeBankDlg::OnRename()
SchemeManager.rename(scheme, cn.getName());
int curSel = m_SchemeList.GetCurSel();
m_SchemeList.DeleteString(curSel);
int insertedPos = m_SchemeList.InsertString(curSel, cn.getName().c_str());
int insertedPos = m_SchemeList.InsertString(curSel, utf8ToTStr(cn.getName()));
m_SchemeList.SetCurSel(insertedPos);
m_SchemeList.Invalidate();
}

View file

@ -23,7 +23,7 @@
// CSelectString dialog
CSelectString::CSelectString(const std::vector<std::string>& vectString, const char* title, CWnd* pParent, bool empty)
CSelectString::CSelectString(const std::vector<std::string>& vectString, const std::string &title, CWnd* pParent, bool empty)
: CDialog(CSelectString::IDD, pParent)
{
//{{AFX_DATA_INIT(CSelectString)
@ -77,14 +77,14 @@ BOOL CSelectString::OnInitDialog()
CDialog::OnInitDialog();
// Change title
SetWindowText (Title.c_str());
SetWindowText (utf8ToTStr(Title));
// Empty button ?
EmptyCtrl.ShowWindow (Empty?SW_SHOW:SW_HIDE);
// Add string
for (uint s=0; s<Strings.size(); s++)
ListCtrl.InsertString (-1, Strings[s].c_str());
ListCtrl.InsertString (-1, utf8ToTStr(Strings[s]));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE

View file

@ -30,7 +30,7 @@ class CSelectString : public CDialog
{
// Construction
public:
CSelectString(const std::vector<std::string>& vectString, const char* title, CWnd* pParent, bool empty); // standard constructor
CSelectString(const std::vector<std::string>& vectString, const std::string &title, CWnd* pParent, bool empty); // standard constructor
// Dialog Data
//{{AFX_DATA(CSelectString)

View file

@ -206,7 +206,7 @@ void CSkeletonScaleDlg::setSkeletonToEdit(NL3D::CSkeletonModel *skel, const std
while((boneId=_SkeletonModel->Bones[boneId].getFatherId())!=-1)
name= tabStr + name;
// append to the list
_BoneList.AddString(name.c_str());
_BoneList.AddString(utf8ToTStr(name));
}
}
@ -400,9 +400,8 @@ void CSkeletonScaleDlg::applyScaleSlider(sint scrollValue)
refreshTextViews();
// update marker text
char str[256];
sprintf(str, "%d%%", (sint)(factor*100));
_StaticScaleMarkers[_SliderEdited]->SetWindowText(str);
std::string str = NLMISC::toString("%d%%", (sint)(factor*100));
_StaticScaleMarkers[_SliderEdited]->SetWindowText(utf8ToTStr(str));
}
// ***************************************************************************
@ -715,7 +714,7 @@ void CSkeletonScaleDlg::updateScalesFromText(UINT ctrlId)
return;
// get the scale info
std::string str= (const char*)(*_ScaleEdits[sid]);
std::string str = tStrToUtf8(*_ScaleEdits[sid]);
if(str.empty())
return;
float f;
@ -1225,12 +1224,14 @@ void CSkeletonScaleDlg::OnSsdButtonSaveScale()
// choose the file
std::string defaultFileName= _SkeletonFileName;
NLMISC::strFindReplace(defaultFileName, ".skel", ".scale");
CFileDialog fd(FALSE, "scale", defaultFileName.c_str(), OFN_OVERWRITEPROMPT, "SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||", this) ;
fd.m_ofn.lpstrTitle= "Save As Skeleton Scale File";
CFileDialog fd(FALSE, _T("scale"), utf8ToTStr(defaultFileName), OFN_OVERWRITEPROMPT, _T("SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||"), this) ;
fd.m_ofn.lpstrTitle = _T("Save As Skeleton Scale File");
if (fd.DoModal() == IDOK)
{
NLMISC::COFile f;
if( f.open((const char*)fd.GetPathName()) )
if (f.open(tStrToUtf8(fd.GetPathName())))
{
saveSkelScaleInStream(f);
}
@ -1251,12 +1252,14 @@ void CSkeletonScaleDlg::OnSsdButtonLoadScale()
// choose the file
std::string defaultFileName= _SkeletonFileName;
NLMISC::strFindReplace(defaultFileName, ".skel", ".scale");
CFileDialog fd(TRUE, "scale", defaultFileName.c_str(), 0, "SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||", this) ;
fd.m_ofn.lpstrTitle= "Load a Skeleton Scale File";
CFileDialog fd(TRUE, _T("scale"), utf8ToTStr(defaultFileName), 0, _T("SkelScaleFiles (*.scale)|*.scale|All Files (*.*)|*.*||"), this) ;
fd.m_ofn.lpstrTitle= _T("Load a Skeleton Scale File");
if (fd.DoModal() == IDOK)
{
NLMISC::CIFile f;
if( f.open((const char*)fd.GetPathName()) )
if (f.open(tStrToUtf8(fd.GetPathName())))
{
loadSkelScaleFromStream(f);
}

View file

@ -455,26 +455,24 @@ void CSlotDlg::OnSetSkeleton()
void CSlotDlg::setWindowName ()
{
char tmp[512];
_snprintf (tmp, 512, "Slot %d : ", Id);
std::string tmp = NLMISC::toString("Slot %d : ", Id);
if (isEmpty())
strcat (tmp, "empty");
tmp += "empty";
else
strcat (tmp, getSlotInformation ()->Animation .c_str());
tmp += getSlotInformation ()->Animation;
CSlotInfo *information = getSlotInformation ();
if (information)
{
std::string SkeletonName = information->Skeleton;
if (SkeletonName != "")
if (!SkeletonName.empty())
{
strcat (tmp, " (");
strcat (tmp, SkeletonName.c_str());
strcat (tmp, ")");
tmp += " (" + SkeletonName + ")";
}
}
GetDlgItem (IDC_SLOT_NAME)->SetWindowText (tmp);
GetDlgItem (IDC_SLOT_NAME)->SetWindowText (utf8ToTStr(tmp));
}
// ***************************************************************************

View file

@ -119,15 +119,17 @@ void CSnapshotToolDlg::stringFromRegistry(HKEY hKey, const TCHAR *name, CString
dest = defaultStr;
return;
}
std::string tmpDest;
tmpDest.resize(size);
result = RegQueryValueEx(hKey, name, NULL, &type, (unsigned char *) &tmpDest[0], &size);
std::auto_ptr<TCHAR> tmpDest(new TCHAR[size]);
result = RegQueryValueEx(hKey, name, NULL, &type, (BYTE*)tmpDest.get(), &size);
if (result != ERROR_SUCCESS)
{
dest = defaultStr;
return;
}
dest = tmpDest.c_str();
dest = *tmpDest;
}
@ -167,14 +169,15 @@ void CSnapshotToolDlg::fromRegistry()
stringFromRegistry(hKey, _T("OutputPath"), m_OutputPath, "");
CString filters;
stringFromRegistry(hKey, "Filters", filters, "*.shape");
std::string stdFilters((LPCTSTR) filters);
stringFromRegistry(hKey, _T("Filters"), filters, "*.shape");
std::vector<std::string> filterList;
NLMISC::splitString(stdFilters, ",", filterList);
NLMISC::splitString(tStrToUtf8(filters), ",", filterList);
m_Filters.ResetContent();
for (uint k = 0; k < filterList.size(); ++k)
{
m_Filters.AddString(filterList[k].c_str());
m_Filters.AddString(utf8ToTStr(filterList[k]));
}
integralTypeFromRegistry(hKey, _T("RecurseSubFolder"), (int &) m_RecurseSubFolder, FALSE);
@ -405,7 +408,7 @@ void CSnapshotToolDlg::OnGo()
MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_INPUT_PATH), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION);
return;
}
if (!NLMISC::CFile::isDirectory(LPCTSTR(m_InputPath)))
if (!NLMISC::CFile::isDirectory(tStrToUtf8(m_InputPath)))
{
MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_INPUT_PATH_NOT_FOUND), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION);
return;
@ -415,13 +418,13 @@ void CSnapshotToolDlg::OnGo()
MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_OUTPUT_PATH), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION);
return;
}
if (m_OutputPathOption == OutputPath_Custom && !NLMISC::CFile::isDirectory(LPCTSTR(m_OutputPath)))
if (m_OutputPathOption == OutputPath_Custom && !NLMISC::CFile::isDirectory(tStrToUtf8(m_OutputPath)))
{
if (MessageBox(getStrRsc(IDS_SNAPSHOT_CREATE_OUTPUT_DIRECTORY), getStrRsc(IDS_OBJECT_VIEWER), MB_OKCANCEL) != IDOK)
{
return;
}
if(!NLMISC::CFile::createDirectoryTree(LPCTSTR(m_OutputPath)))
if(!NLMISC::CFile::createDirectoryTree(tStrToUtf8(m_OutputPath)))
{
MessageBox(getStrRsc(IDS_SNAPSHOT_OUTPUT_PATH_CREATION_FAILED), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION);
return;
@ -442,7 +445,7 @@ void CSnapshotToolDlg::OnGo()
m_Log.ResetContent();
m_Log.AddString(getStrRsc(IDS_GETTING_PATH_CONTENT));
std::vector<std::string> files;
CPath::getPathContent((LPCTSTR) m_InputPath, m_RecurseSubFolder == TRUE, false, true, files);
CPath::getPathContent(tStrToUtf8(m_InputPath), m_RecurseSubFolder == TRUE, false, true, files);
if (files.empty())
{
m_Log.AddString(getStrRsc(IDS_SNAPSHOT_NO_FILES_FOUND));
@ -456,7 +459,7 @@ void CSnapshotToolDlg::OnGo()
CString wildCard;
m_Filters.GetText(l, wildCard);
wildCard.MakeLower();
if (testWildCard(toLower(NLMISC::CFile::getFilename(files[k])).c_str(), (LPCTSTR) wildCard))
if (testWildCard(toLower(NLMISC::CFile::getFilename(files[k])).c_str(), tStrToUtf8(wildCard).c_str()))
{
_FilteredFiles.push_back(files[k]);
break;
@ -598,7 +601,7 @@ void CSnapshotToolDlg::OnTimer(UINT_PTR nIDEvent)
try
{
CShapeStream ss;
m_Log.AddString(_FilteredFiles[0].c_str());
m_Log.AddString(utf8ToTStr(_FilteredFiles[0]));
CIFile stream(_FilteredFiles[0]);
ss.serial(stream);
nlassert(ss.getShapePointer());
@ -706,10 +709,10 @@ void CSnapshotToolDlg::OnTimer(UINT_PTR nIDEvent)
switch(m_OutputPathOption)
{
case OutputPath_Custom: // custom output path
outputFilename = LPCTSTR(m_OutputPath) + std::string("\\") + NLMISC::CFile::getFilename(outputFilename);
outputFilename = tStrToUtf8(m_OutputPath) + "\\" + NLMISC::CFile::getFilename(outputFilename);
break;
case OutputPath_SameAsInput: // Input path
outputFilename = LPCTSTR(m_InputPath) + std::string("\\") + NLMISC::CFile::getFilename(outputFilename);
outputFilename = tStrToUtf8(m_InputPath) + "\\" + NLMISC::CFile::getFilename(outputFilename);
break;
case OutputPath_CurrShapeDirectory: // current path
// no op

View file

@ -76,10 +76,9 @@ BOOL CSoundAnimDlg::OnInitDialog()
void CSoundAnimDlg::handle()
{
char text[256];
float sec = _AnimationDlg->getTime();
_snprintf(text, 256, "time: %.3f", sec);
GetDlgItem(IDC_SOUNDANIMINFO)->SetWindowText(text);
std::string text = toString("time: %.3f", sec);
GetDlgItem(IDC_SOUNDANIMINFO)->SetWindowText(utf8ToTStr(text));
_AnimView.updateCursor();
}
@ -137,7 +136,7 @@ void CSoundAnimDlg::updateSounds()
for (iter = sounds.begin(); iter != sounds.end(); iter++)
{
list->AddString((*iter).toString().c_str());
list->AddString(utf8ToTStr((*iter).toString()));
}
list->UpdateData();
@ -177,14 +176,13 @@ void CSoundAnimDlg::OnRemoveSound()
{
if (_SelectedMarker != 0)
{
char s[256];
CListBox* list = (CListBox*) GetDlgItem(IDC_SOUND_ANIM_LIST);
TCHAR s[256];
CListBox* list = (CListBox*) GetDlgItem(IDC_SOUND_ANIM_LIST);
if (list->GetText(list->GetCurSel(), s) != LB_ERR)
{
string name(s);
_SelectedMarker->removeSound(NLMISC::CSheetId(name, "sound"));
updateSounds();
_SelectedMarker->removeSound(NLMISC::CSheetId(tStrToUtf8(s), "sound"));
updateSounds();
}
}
}

View file

@ -221,7 +221,7 @@ void CSoundAnimView::save()
if (fileDlg.DoModal() == IDOK)
{
filename = (const char*) fileDlg.GetPathName();
filename = tStrToUtf8(fileDlg.GetPathName());
}
else
{
@ -236,7 +236,7 @@ void CSoundAnimView::save()
}
catch (Exception& e)
{
MessageBox (e.what(), "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
MessageBox (utf8ToTStr(e.what()), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
}
}
}

View file

@ -231,13 +231,13 @@ void CStartStopParticleSystem::updateUIFromState()
{
if (!_ActiveNode->getParentSkelName().empty())
{
GetDlgItem(IDC_STICK_BONE)->SetWindowText((_ActiveNode->getParentBoneName() + "." + _ActiveNode->getParentBoneName()).c_str());
GetDlgItem(IDC_STICK_BONE)->SetWindowText(utf8ToTStr(_ActiveNode->getParentBoneName() + "." + _ActiveNode->getParentBoneName()));
}
else
{
GetDlgItem(IDC_STICK_BONE)->SetWindowText(_T(""));
}
GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(_ActiveNode->getFilename().c_str());
GetDlgItem(IDC_ACTIVE_PS)->SetWindowText(utf8ToTStr(_ActiveNode->getFilename()));
GetDlgItem(IDC_ENABLE_AUTO_COUNT)->EnableWindow(TRUE);
((CButton *) GetDlgItem(IDC_ENABLE_AUTO_COUNT))->SetCheck(getCurrPS()->getAutoCountFlag() ? 1 : 0);
GetDlgItem(IDC_RESET_COUNT)->EnableWindow((_ActiveNode->getPSPointer()->getAutoCountFlag() && !_ActiveNode->getResetAutoCountFlag()) ? TRUE : FALSE);
@ -844,7 +844,7 @@ void CStartStopParticleSystem::OnLinkToSkeleton()
uint boneIndex;
std::string parentSkelName;
std::string parentBoneName;
if (ov->chooseBone((LPCTSTR) chooseBoneForPS, skel, boneIndex, &parentSkelName, &parentBoneName))
if (ov->chooseBone(tStrToUtf8(chooseBoneForPS), skel, boneIndex, &parentSkelName, &parentBoneName))
{
_ParticleDlg->stickPSToSkeleton(_ActiveNode, skel, boneIndex, parentSkelName, parentBoneName);
}
@ -1017,11 +1017,11 @@ void CStartStopParticleSystem::OnBrowseAnim()
}
}
std::vector<std::string> animList(animSet.begin(), animSet.end());
CSelectString st(animList, (LPCTSTR) getStrRsc(IDS_SELECT_ANIMATION), this, false);
CSelectString st(animList, tStrToUtf8(getStrRsc(IDS_SELECT_ANIMATION)), this, false);
if (st.DoModal() == IDOK && st.Selection != -1)
{
m_TriggerAnim = animList[st.Selection].c_str();
_ActiveNode->setTriggerAnim((LPCTSTR) m_TriggerAnim);
_ActiveNode->setTriggerAnim(tStrToUtf8(m_TriggerAnim));
GetDlgItem(IDC_CLEAR_ANIM)->EnableWindow(!_ActiveNode->getTriggerAnim().empty());
}
_ParticleDlg->ParticleTreeCtrl->updateCaption(*_ActiveNode);

View file

@ -179,29 +179,22 @@ void CTextureChooser::OnBrowseTexture()
{
texName = (static_cast<NL3D::CTextureFile *>(_Wrapper->get()))->getFileName();
}
CFileDialog fd(TRUE, ".tga", texName.c_str(), 0, NULL, this);
CFileDialog fd(TRUE, _T(".tga"), utf8ToTStr(texName), 0, NULL, this);
if (fd.DoModal() == IDOK)
{
// Add to the path
char drive[256];
char dir[256];
char path[256];
// Add search path for the texture
_splitpath (fd.GetPathName(), drive, dir, NULL, NULL);
_makepath (path, drive, dir, NULL, NULL);
NLMISC::CPath::addSearchPath (path);
NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())));
try
{
NL3D::CTextureFile *tf = new NL3D::CTextureFile(std::string(fd.GetFileName()));
NL3D::CTextureFile *tf = new NL3D::CTextureFile(tStrToUtf8(fd.GetFileName()));
_Wrapper->setAndUpdateModifiedFlag(tf);
_Texture = tf;
textureToBitmap();
}
catch (NLMISC::Exception &e)
{
MessageBox(e.what(), "error loading texture");
MessageBox(utf8ToTStr(e.what()), _T("error loading texture"));
}
}

View file

@ -249,7 +249,7 @@ BOOL CVegetableCopyDlg::OnInitDialog()
uint num= _VegetableDlg->getNumVegetables();
for(uint i=0; i<num; i++)
{
VegetableList.AddString(_VegetableDlg->getVegetableName(i).c_str());
VegetableList.AddString(utf8ToTStr(_VegetableDlg->getVegetableName(i)));
}

View file

@ -100,7 +100,7 @@ void CVegetableDensityPage::setVegetableToEdit(NL3D::CVegetable *vegetable)
{
// Init ShapeName
// ----------
StaticVegetableShape.SetWindowText(_Vegetable->ShapeName.c_str());
StaticVegetableShape.SetWindowText(utf8ToTStr(_Vegetable->ShapeName));
// init Creation Distance.
// ----------
@ -228,7 +228,7 @@ void CVegetableDensityPage::updateAngleMinFromEditText()
TCHAR stmp[256];
AngleMinEdit.GetWindowText(stmp, 256);
float angleMin;
NLMISC::fromString(stmp, angleMin);
NLMISC::fromString(tStrToUtf8(stmp), angleMin);
NLMISC::clamp(angleMin, -90, 90);
// make a sinus, because 90 => 1, and -90 =>-1
float cosAngleMin= (float)sin(angleMin*NLMISC::Pi/180.f);
@ -252,7 +252,7 @@ void CVegetableDensityPage::updateAngleMaxFromEditText()
TCHAR stmp[256];
AngleMaxEdit.GetWindowText(stmp, 256);
float angleMax;
NLMISC::fromString(stmp, angleMax);
NLMISC::fromString(tStrToUtf8(stmp), angleMax);
NLMISC::clamp(angleMax, -90, 90);
// make a sinus, because 90 => 1, and -90 =>-1
float cosAngleMax= (float)sin(angleMax*NLMISC::Pi/180.f);
@ -523,22 +523,19 @@ void CVegetableDensityPage::OnButtonVegetableBrowse()
if (fd.DoModal() == IDOK)
{
// Add to the path
char drive[256];
char dir[256];
char path[256];
std::string fileName = tStrToUtf8(fd.GetFileName());
// Add search path for the .veget
_splitpath (fd.GetPathName(), drive, dir, NULL, NULL);
_makepath (path, drive, dir, NULL, NULL);
std::string path = NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()));
NLMISC::CPath::addSearchPath (path);
try
{
// verify the file can be opened.
NLMISC::CPath::lookup((const char*)fd.GetFileName());
NLMISC::CPath::lookup(fileName);
// update shapeName and view
_Vegetable->ShapeName= std::string(fd.GetFileName());
_Vegetable->ShapeName = fileName;
StaticVegetableShape.SetWindowText(fd.GetFileName());
// update the name in the list-box
@ -549,7 +546,7 @@ void CVegetableDensityPage::OnButtonVegetableBrowse()
}
catch (NLMISC::EPathNotFound &ep)
{
MessageBox(ep.what(), "Can't open file");
MessageBox(utf8ToTStr(ep.what()), _T("Can't open file"));
}
}
}

View file

@ -118,7 +118,7 @@ void CDialogFlags::init(CSoundPlugin *plugin)
for (uint i =0; i<NLSOUND::UAudioMixer::TBackgroundFlags::NB_BACKGROUND_FLAGS; ++i)
{
static_cast<CButton*>(GetDlgItem(BG_FLAG_ID[i]))->SetCheck(flags.Flags[i] ? 1 : 0);
GetDlgItem(BG_FLAG_ID[i])->SetWindowText(_Mixer->getBackgroundFlagName(i).c_str());
GetDlgItem(BG_FLAG_ID[i])->SetWindowText(utf8ToTStr(_Mixer->getBackgroundFlagName(i)));
}