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

This commit is contained in:
kervala 2016-11-19 19:46:40 +01:00
parent 8dd3157847
commit 888b27f87a
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 wideToUtf8(str) (ucstring((ucchar*)str).toUtf8())
#define utf8ToWide(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str()) #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 // wrapper for fopen to be able to open files with an UTF-8 filename
FILE* nlfopen(const std::string &filename, const std::string &mode); 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 ? // Text or dialog ?
if (dialog) if (dialog)
{ {
// Dialog message // Dialog message
MessageBox (it.GetMAXHWnd(), msg, title, MB_OK|MB_ICONEXCLAMATION); MessageBox (it.GetMAXHWnd(), utf8ToTStr(msg), utf8ToTStr(title), MB_OK|MB_ICONEXCLAMATION);
} }
else else
{ {
// Text message // Text message
mprintf ((string(msg) + "\n").c_str()); mprintf (utf8ToTStr(msg + "\n"));
} }
// Output in log // 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 it if a max interface
* \param dialog is true to see the message in a dilog, false to see it in the script window. * \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 // The second arg
string matFilename[2]; string matFilename[2];
matFilename[0] = arg_list[2]->to_string(); matFilename[0] = tStrToUtf8(arg_list[2]->to_string());
matFilename[1] = arg_list[3]->to_string(); matFilename[1] = tStrToUtf8(arg_list[3]->to_string());
// The third arg // The third arg
bool checkOnly = (arg_list[4]->to_bool() != FALSE); 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); nlassert (node);
// The second arg // The second arg
string fileName = arg_list[1]->to_string(); string fileName = tStrToUtf8(arg_list[1]->to_string());
// The fourth arg // The fourth arg
bool errorInDialog = (arg_list[2]->to_bool() != FALSE); 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); nlassert (node);
// The second arg // The second arg
string fileName = arg_list[1]->to_string(); string fileName = tStrToUtf8(arg_list[1]->to_string());
// The second arg // The second arg
int transitionNumber = arg_list[2]->to_int(); int transitionNumber = arg_list[2]->to_int();
@ -1002,7 +1002,7 @@ Value* export_zone_cf (Value** arg_list, int count)
nlassert (node); nlassert (node);
// The second arg // The second arg
string fileName = arg_list[1]->to_string(); string fileName = tStrToUtf8(arg_list[1]->to_string());
// The thrid arg // The thrid arg
Array *array = (Array*)arg_list[2]; 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); type_check (cell->get(2), String, message);
// Get the strings // Get the strings
categories[i].first = cell->get(1)->to_string(); categories[i].first = tStrToUtf8(cell->get(1)->to_string());
categories[i].second = cell->get(2)->to_string(); categories[i].second = tStrToUtf8(cell->get(2)->to_string());
} }
// Get a Object pointer // 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; int errorCode = arg_list[0]->to_int()-1;
// Error code // 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); type_check(arg_list[0], String, message);
// The first arg // The first arg
const char *dir = arg_list[0]->to_string(); const std::string dir = tStrToUtf8(arg_list[0]->to_string());
// Set the directory // 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); nlassert (node);
// The second arg // The second arg
string fileName = arg_list[1]->to_string(); string fileName = tStrToUtf8(arg_list[1]->to_string());
// The thrid arg // The thrid arg
int xMin = arg_list[2]->to_int(); int xMin = arg_list[2]->to_int();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -322,7 +322,7 @@ void CLocatedProperties::goPostRender()
_MaxNbParticles->update(); _MaxNbParticles->update();
} }
// in all cases, show the current number of particles being used // 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); nlassert(loc);
_LBTarget->attachTarget(loc); _LBTarget->attachTarget(loc);
m_AvailableTargets.DeleteString(indexs[k] - k); m_AvailableTargets.DeleteString(indexs[k] - k);
int l = m_Targets.AddString(loc->getName().c_str()); int l = m_Targets.AddString(utf8ToTStr(loc->getName()));
m_Targets.SetItemData(l, (DWORD) loc); m_Targets.SetItemData(l, (DWORD_PTR) loc);
} }
UpdateData(FALSE); UpdateData(FALSE);
// //
@ -135,7 +135,7 @@ void CLocatedTargetDlg::OnRemoveTarget()
nlassert(loc); nlassert(loc);
_LBTarget->detachTarget(loc); _LBTarget->detachTarget(loc);
m_Targets.DeleteString(indexs[k] - k); 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); m_AvailableTargets.SetItemData(l, (DWORD) loc);
} }

View file

@ -574,7 +574,7 @@ void CMainFrame::OnFileLoadconfig()
{ {
// Open the file // Open the file
CIFile file; CIFile file;
if (file.open ((const char*)fileDlg.GetPathName())) if (file.open(tStrToUtf8(fileDlg.GetPathName())))
{ {
try try
{ {
@ -592,7 +592,7 @@ void CMainFrame::OnFileLoadconfig()
} }
catch (Exception& e) 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 else
@ -685,7 +685,7 @@ void CMainFrame::OnFileOpen()
if (name.Find(_T(".ig")) != -1) if (name.Find(_T(".ig")) != -1)
{ {
// Load the instance group // Load the instance group
if (ObjView->loadInstanceGroup (name)) if (ObjView->loadInstanceGroup (tStrToUtf8(name)))
{ {
// Reset the camera // Reset the camera
OnResetCamera(); OnResetCamera();
@ -697,7 +697,7 @@ void CMainFrame::OnFileOpen()
else else
{ {
// Add it in the array // 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) if (fileDlg2.DoModal()==IDOK)
{ {
// Load the shape with a skeleton // Load the shape with a skeleton
if (ObjView->loadMesh (meshFilename, fileDlg2.GetPathName())) if (ObjView->loadMesh (meshFilename, tStrToUtf8(fileDlg2.GetPathName())))
{ {
// Reset the camera // Reset the camera
OnResetCamera(); OnResetCamera();
@ -756,7 +756,7 @@ void CMainFrame::OnFileSaveconfig()
} }
// Open the file // Open the file
COFile file; COFile file;
if (file.open ((const char*)fileDlg.GetPathName())) if (file.open (tStrToUtf8(fileDlg.GetPathName())))
{ {
try try
{ {
@ -764,7 +764,7 @@ void CMainFrame::OnFileSaveconfig()
} }
catch (Exception& e) 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 else
@ -832,7 +832,7 @@ void CMainFrame::OnViewSetmovespeed()
if (valueDlg.DoModal ()==IDOK) if (valueDlg.DoModal ()==IDOK)
{ {
// Get deflaut value // 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) if (sceneRotDlg.DoModal() == IDOK)
{ {
// read value. // read value.
_LastSceneRotX= (float)atof(sceneRotDlg.RotX); NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotX), _LastSceneRotX);
_LastSceneRotY= (float)atof(sceneRotDlg.RotY); NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotY), _LastSceneRotY);
_LastSceneRotZ= (float)atof(sceneRotDlg.RotZ); NLMISC::fromString(tStrToUtf8(sceneRotDlg.RotZ), _LastSceneRotZ);
float rotx= degToRad(_LastSceneRotX); float rotx= degToRad(_LastSceneRotX);
float roty= degToRad(_LastSceneRotY); float roty= degToRad(_LastSceneRotY);
float rotz= degToRad(_LastSceneRotZ); 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)); CInstanceInfo *instance = ObjView->getInstance (ObjView->getCameraInstance (pCmdUI->m_nID - ID_SCENE_CAMERA_FIRST));
nlassert (instance->Camera); 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 else
{ {

View file

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

View file

@ -165,19 +165,19 @@ void CMultiTexDlg::readValues(bool alternate)
char buf[128]; char buf[128];
if (!alternate) if (!alternate)
{ {
sprintf(buf, "%.3f", _MTP->getScrollSpeed(0).x); GetDlgItem(IDC_U_SPEED_1)->SetWindowText(buf); GetDlgItem(IDC_U_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).x)));
sprintf(buf, "%.3f", _MTP->getScrollSpeed(0).y); GetDlgItem(IDC_V_SPEED_1)->SetWindowText(buf); GetDlgItem(IDC_V_SPEED_1)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(0).y)));
sprintf(buf, "%.3f", _MTP->getScrollSpeed(1).x); GetDlgItem(IDC_U_SPEED_2)->SetWindowText(buf); GetDlgItem(IDC_U_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).x)));
sprintf(buf, "%.3f", _MTP->getScrollSpeed(1).y); GetDlgItem(IDC_V_SPEED_2)->SetWindowText(buf); GetDlgItem(IDC_V_SPEED_2)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getScrollSpeed(1).y)));
} }
else else
{ {
if (_MTP->isAlternateTexEnabled()) if (_MTP->isAlternateTexEnabled())
{ {
sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(0).x); GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(buf); GetDlgItem(IDC_U_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).x)));
sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(0).y); GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(buf); GetDlgItem(IDC_V_SPEED_1_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(0).y)));
sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(1).x); GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(buf); GetDlgItem(IDC_U_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).x)));
sprintf(buf, "%.3f", _MTP->getAlternateScrollSpeed(1).y); GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(buf); GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(utf8ToTStr(NLMISC::toString("%.3f", _MTP->getAlternateScrollSpeed(1).y)));
} }
else else
{ {
@ -187,7 +187,6 @@ void CMultiTexDlg::readValues(bool alternate)
GetDlgItem(IDC_V_SPEED_2_ALTERNATE)->SetWindowText(_T("")); 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]; TCHAR sModulePath[256];
int res = GetModuleFileName(hModule, sModulePath, 256); nlassert(res); int res = GetModuleFileName(hModule, sModulePath, 256); nlassert(res);
nldebug("Object viewer module path is '%s'", sModulePath); nldebug("Object viewer module path is '%s'", sModulePath);
_splitpath (sModulePath, SDrive, SDir, NULL, NULL);
_makepath (sModulePath, SDrive, SDir, "object_viewer", ".cfg"); std::string path = NLMISC::CFile::getPath(tStrToUtf8(sModulePath));
return sModulePath;
return NLMISC::CPath::standardizeDosPath(path) + "object_viewer.cfg";
} }
@ -535,7 +536,7 @@ void CObjectViewer::loadConfigFile()
} }
catch (Exception& e) 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 // The windows path
uint dSize = ::GetWindowsDirectory(NULL, 0); uint dSize = ::GetWindowsDirectory(NULL, 0);
nlverify(dSize); nlverify(dSize);
char *wd = new char[dSize];
TCHAR *wd = new TCHAR[dSize];
nlverify(::GetWindowsDirectory(wd, dSize)); nlverify(::GetWindowsDirectory(wd, dSize));
_FontPath=wd; _FontPath = tStrToUtf8(wd) + "\\fonts\\arial.ttf";
_FontPath+="\\fonts\\arial.ttf"; delete[] wd;
// The font generator // The font generator
_FontGenerator = NL3D::newCFontGenerator ( _FontPath ); _FontGenerator = NL3D::newCFontGenerator ( _FontPath );
delete[] wd;
// The viewport // The viewport
CViewport viewport; CViewport viewport;
@ -823,7 +824,8 @@ bool CObjectViewer::initUI (HWND parent)
} }
catch (NLMISC::EStream &e) 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(); iF.close();
@ -838,7 +840,8 @@ bool CObjectViewer::initUI (HWND parent)
} }
catch (Exception& e) 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; sint64 timeDiff = newTime - lastTime;
float fps = timeDiff > 0 ? (float)(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime)) : 1000.0f; float fps = timeDiff > 0 ? (float)(1.0 / NLMISC::CTime::ticksToSecond (newTime-lastTime)) : 1000.0f;
lastTime=newTime; lastTime=newTime;
char msgBar[1024];
uint nbPlayingSources, nbSources; uint nbPlayingSources, nbSources;
if (CSoundSystem::getAudioMixer()) if (CSoundSystem::getAudioMixer())
{ {
@ -1299,17 +1301,19 @@ void CObjectViewer::go ()
} }
// Display std info. // 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", 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", _Direct3d ? "Direct3d":"OpenGL",
in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips, (float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024), in.NLines+in.NPoints+in.NQuads*2+in.NTriangles+in.NTriangleStrips,
(float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024), (float)CNELU::Driver->getUsedTextureMemory () / (float)(1024*1024),
(_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(), (float)CNELU::Driver->profileAllocatedTextureMemory () / (float)(1024*1024),
nbPlayingSources, (_SceneCenter-CNELU::Camera->getMatrix().getPos()).norm(),
nbSources, nbPlayingSources,
fps nbSources,
); fps
);
// Display // Display
_MainFrame->StatusBar.SetWindowText (msgBar); _MainFrame->StatusBar.SetWindowText (utf8ToTStr(msgBar));
// Display Vegetable info. // Display Vegetable info.
if(_VegetableDlg!=NULL) if(_VegetableDlg!=NULL)
@ -1790,9 +1794,8 @@ void CObjectViewer::serial (NLMISC::IStream& f)
else else
{ {
// Error message // Error message
char message[512]; std::string message = toString("File not found %s", readed[i].ShapeFilename.c_str());
smprintf (message, 512, "File not found %s", readed[i].ShapeFilename.c_str()); _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (message, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
// Stop loading // Stop loading
break; break;
@ -1826,9 +1829,8 @@ void CObjectViewer::serial (NLMISC::IStream& f)
catch (Exception &e) catch (Exception &e)
{ {
// Error message // Error message
char message[512]; std::string message = toString("Error loading shape %s: %s", readed[i].ShapeFilename.c_str(), e.what());
smprintf (message, 512, "Error loading shape %s: %s", readed[i].ShapeFilename.c_str(), e.what()); _MainFrame->MessageBox (utf8ToTStr(message), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (message, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
// Stop loading // Stop loading
break; 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()); //AFX_MANAGE_STATE(AfxGetStaticModuleState());
// Add to the path
char drive[256];
char dir[256];
char path[256];
// Add search path for the mesh // Add search path for the mesh
_splitpath (igFilename, drive, dir, NULL, NULL); CPath::addSearchPath (NLMISC::CFile::getPath(igFilename));
_makepath (path, drive, dir, NULL, NULL);
CPath::addSearchPath (path);
// Open a file // Open a file
CIFile file; CIFile file;
@ -1906,16 +1900,15 @@ bool CObjectViewer::loadInstanceGroup(const char *igFilename)
{ {
// clean // clean
delete ig; 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; return false;
} }
} }
else else
{ {
// Create a message // Create a message
char msg[512]; std::string msg = toString("Can't open the file %s for reading.", igFilename.c_str());
_snprintf (msg, 512, "Can't open the file %s for reading.", igFilename); _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
return false; 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()); AFX_MANAGE_STATE(AfxGetStaticModuleState());
// Add to the path // Add to the path
char drive[256];
char dir[256];
char path[256];
// Add search path for the skeleton // Add search path for the skeleton
if (skeleton) if (skeleton.empty())
{ {
_splitpath (skeleton, drive, dir, NULL, NULL); CPath::addSearchPath (NLMISC::CFile::getPath(skeleton));
_makepath (path, drive, dir, NULL, NULL);
CPath::addSearchPath (path);
} }
// Open a file // Open a file
@ -1957,7 +1945,7 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
bool skelError=false; bool skelError=false;
// Continue ? // Continue ?
if (skeleton&&(strcmp (skeleton, "")!=0)) if (!skeleton.empty())
{ {
// Open a file // Open a file
@ -1975,7 +1963,7 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
} }
catch (Exception& e) 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 // error
skelError=true; skelError=true;
@ -1984,9 +1972,8 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
else else
{ {
// Create a message // Create a message
char msg[512]; std::string msg = NLMISC::toString("Can't open the file %s for reading.", skeleton.c_str());
_snprintf (msg, 512, "Can't open the file %s for reading.", meshFilename); _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
// error // error
skelError=true; skelError=true;
@ -2007,12 +1994,10 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
for (uint i=0; i<meshFilename.size(); i++) for (uint i=0; i<meshFilename.size(); i++)
{ {
// Filename // Filename
const char *fileName = meshFilename[i].c_str(); const std::string fileName = meshFilename[i];
// Add search path for the mesh // Add search path for the mesh
_splitpath (fileName, drive, dir, NULL, NULL); CPath::addSearchPath (NLMISC::CFile::getPath(fileName));
_makepath (path, drive, dir, NULL, NULL);
CPath::addSearchPath (path);
// Shape pointer // Shape pointer
IShape *shapeMesh=NULL; IShape *shapeMesh=NULL;
@ -2031,16 +2016,15 @@ bool CObjectViewer::loadMesh (std::vector<std::string> &meshFilename, const char
} }
catch (Exception& e) 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; continue;
} }
} }
else else
{ {
// Create a message // Create a message
char msg[512]; std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str());
_snprintf (msg, 512, "Can't open the file %s for reading.", fileName); _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
continue; 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()); 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()); listBones.push_back (transformSkel->Bones[bone].getBoneName());
// Get name of the mesh // Get name of the mesh
char nameMesh[512]; std::string nameMesh = NLMISC::CFile::getFilenameWithoutExtension(meshName);
_splitpath (meshName, NULL, NULL, nameMesh, NULL);
// Select a bones // Select a bones
std::string message = "Select a bone to stick " + string (nameMesh); 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()); 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()); 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()); AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -2408,7 +2391,7 @@ void CObjectViewer::setSingleAnimation (NL3D::CAnimation* pAnim, const char* nam
_SelectedObject = instance; _SelectedObject = instance;
// Add the animation // 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 // Add the animation to the animationSet
_AnimationSetDlg->UpdateData (TRUE); _AnimationSetDlg->UpdateData (TRUE);
@ -2866,7 +2849,7 @@ void CObjectViewer::enableDynamicObjectLightingTest(NLPACS::CGlobalRetriever *gl
if (!_ObjectLightTestShape.empty()) if (!_ObjectLightTestShape.empty())
{ {
string str= string("Path not found for Light Test Shape: ") + _ObjectLightTestShape; 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. // disable.
_ObjectLightTest= NULL; _ObjectLightTest= NULL;
@ -3241,7 +3224,7 @@ bool CObjectViewer::createVegetableLandscape()
// close the progress dialog // close the progress dialog
dlgProgress.DestroyWindow(); 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. // remove first possibly created collisions objects.
if(_VegetableCollisionEntity) 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 // 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); _ListInstance[instance]->Saved.AnimationFileName.push_back (filename);
// Rebuild the animationSet // 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 // Open the file
CIFile file; CIFile file;
if (file.open (fileName)) if (file.open (fileName))
{ {
// Get the animation name // Get the animation name
char name[256]; std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName);
_splitpath (fileName, NULL, NULL, name, NULL);
// Make an animation // Make an animation
CAnimation *anim=new CAnimation; CAnimation *anim=new CAnimation;
@ -3575,22 +3557,20 @@ void CObjectViewer::loadAnimation (const char* fileName, uint instance)
else else
{ {
// Create a message // Create a message
char msg[512]; std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str());
_snprintf (msg, 512, "Can't open the file %s for reading.", fileName); _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (msg, "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 // Open the file
CIFile file; CIFile file;
if (file.open (fileName)) if (file.open (fileName))
{ {
// Get the animation name // Get the animation name
char name[256]; std::string name = NLMISC::CFile::getFilenameWithoutExtension(fileName);
_splitpath (fileName, NULL, NULL, name, NULL);
// Get the skeleton pointer // Get the skeleton pointer
CSkeletonWeight* skel=new CSkeletonWeight; CSkeletonWeight* skel=new CSkeletonWeight;
@ -3599,7 +3579,7 @@ void CObjectViewer::loadSWT (const char* fileName, uint instance)
skel->serial (file); skel->serial (file);
// Add an animation // Add an animation
_ListInstance[instance]->AnimationSet.addSkeletonWeight (name, skel); _ListInstance[instance]->AnimationSet.addSkeletonWeight (name.c_str(), skel);
// Add the filename in the list // Add the filename in the list
_ListInstance[instance]->Saved.SWTFileName.push_back (fileName); _ListInstance[instance]->Saved.SWTFileName.push_back (fileName);
@ -3607,9 +3587,8 @@ void CObjectViewer::loadSWT (const char* fileName, uint instance)
else else
{ {
// Create a message // Create a message
char msg[512]; std::string msg = NLMISC::toString("Can't open the file %s for reading.", fileName.c_str());
_snprintf (msg, 512, "Can't open the file %s for reading.", fileName); _MainFrame->MessageBox (utf8ToTStr(msg), _T("NeL object viewer"), MB_OK|MB_ICONEXCLAMATION);
_MainFrame->MessageBox (msg, "NeL object viewer", MB_OK|MB_ICONEXCLAMATION);
} }
} }
@ -3712,8 +3691,8 @@ void CObjectViewer::shootScene()
CNELU::Driver->setupViewport (CViewport ()); CNELU::Driver->setupViewport (CViewport ());
// The file name // The file name
string filename = NLMISC::CFile::getFilenameWithoutExtension ((const char*)fileDlg.GetPathName ()); string filename = NLMISC::CFile::getFilenameWithoutExtension(tStrToUtf8(fileDlg.GetPathName()));
string extension = NLMISC::CFile::getExtension ((const char*)fileDlg.GetPathName ()); string extension = NLMISC::CFile::getExtension (tStrToUtf8(fileDlg.GetPathName()));
// The file name without extension // The file name without extension
bool jpeg = toLower (extension) == "jpg"; bool jpeg = toLower (extension) == "jpg";
@ -3792,13 +3771,15 @@ void CObjectViewer::shootScene()
} }
else 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; break;
} }
} }
catch (Exception &e) 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; break;
} }
} }
@ -3815,7 +3796,7 @@ void CObjectViewer::drawFXUserMatrix()
{ {
CString fxUserMatrix; CString fxUserMatrix;
fxUserMatrix.LoadString(IDS_FX_USER_MATRIX); fxUserMatrix.LoadString(IDS_FX_USER_MATRIX);
fxUserMatrixStr = (LPCTSTR) fxUserMatrix; fxUserMatrixStr = tStrToUtf8(fxUserMatrix);
stringRetrieved = true; stringRetrieved = true;
} }
nlassert(_ParticleDlg); nlassert(_ParticleDlg);
@ -3830,7 +3811,7 @@ void CObjectViewer::drawFXMatrix()
{ {
CString fx; CString fx;
fx.LoadString(IDS_FX_MATRIX); fx.LoadString(IDS_FX_MATRIX);
fxStr = (LPCTSTR) fx; fxStr = tStrToUtf8(fx);
stringRetrieved = true; stringRetrieved = true;
} }
drawNamedMatrix(_ParticleDlg->getPSWorldMatrix(), fxStr, NLMISC::CRGBA::Blue, -0.2f, 10.f); drawNamedMatrix(_ParticleDlg->getPSWorldMatrix(), fxStr, NLMISC::CRGBA::Blue, -0.2f, 10.f);
@ -3844,7 +3825,7 @@ void CObjectViewer::drawSceneMatrix()
{ {
CString sceneMatrix; CString sceneMatrix;
sceneMatrix.LoadString(IDS_SCENE_MATRIX); sceneMatrix.LoadString(IDS_SCENE_MATRIX);
sceneMatrixStr = (LPCTSTR) sceneMatrix; sceneMatrixStr = tStrToUtf8(sceneMatrix);
stringRetrieved = true; stringRetrieved = true;
} }
drawNamedMatrix(_SceneRoot->getMatrix(), sceneMatrixStr, NLMISC::CRGBA::White, 0.f, 10.f); drawNamedMatrix(_SceneRoot->getMatrix(), sceneMatrixStr, NLMISC::CRGBA::White, 0.f, 10.f);

View file

@ -234,19 +234,19 @@ public:
void releaseUI (); void releaseUI ();
// Set single animtion. // 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 // Set automatic animation
void setAutoAnimation (NL3D::CAnimationSet* pAnimSet); void setAutoAnimation (NL3D::CAnimationSet* pAnimSet);
// Add a mesh // 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 // 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 // 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 // remove all instances from the scene
void removeAllInstancesFromScene(); void removeAllInstancesFromScene();
@ -262,10 +262,10 @@ public:
void shuffleTextureSet(); void shuffleTextureSet();
// Load a mesh // 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 // Load an instance group
bool loadInstanceGroup(const char *igFilename); bool loadInstanceGroup(const std::string &igFilename);
// Set ambient color // Set ambient color
void setAmbientColor (const NLMISC::CRGBA& color); void setAmbientColor (const NLMISC::CRGBA& color);
@ -289,7 +289,7 @@ public:
uint getNumInstance () const; uint getNumInstance () const;
// Add an animation // 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 // Update all objects that depend on the animation set
void refreshAnimationListeners(); void refreshAnimationListeners();
@ -308,10 +308,10 @@ public:
CChooseFrameDelay *getFrameDelayDlg() const { return _ChooseFrameDelayDlg; } CChooseFrameDelay *getFrameDelayDlg() const { return _ChooseFrameDelayDlg; }
// Load animation // Load animation
void loadAnimation (const char* fileName, uint instance); void loadAnimation(const std::string &fileName, uint instance);
// Load a skeleton template // Load a skeleton template
void loadSWT (const char* fileName, uint instance); void loadSWT(const std::string &fileName, uint instance);
/// Not exported /// Not exported
@ -387,7 +387,7 @@ public:
/// inherited from CObjectViewerInterface /// inherited from CObjectViewerInterface
void setWaterPoolManager(NL3D::CWaterPoolManager &wpm) { _Wpm = &wpm; } void setWaterPoolManager(NL3D::CWaterPoolManager &wpm) { _Wpm = &wpm; }
NL3D::CWaterPoolManager &getWaterPoolManager() { return *_Wpm; } NL3D::CWaterPoolManager &getWaterPoolManager() const { return *_Wpm; }
// Reload textures // Reload textures
void reloadTextures (); void reloadTextures ();

View file

@ -69,25 +69,25 @@ public:
virtual void releaseUI () = 0; virtual void releaseUI () = 0;
// Add a mesh // 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 // 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 // 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 // remove all the instance from the scene
virtual void removeAllInstancesFromScene() = 0; virtual void removeAllInstancesFromScene() = 0;
// Load a mesh // 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 // Load a shape
virtual void resetCamera () = 0; virtual void resetCamera () = 0;
// Set single animation // 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 // Set automatic animation
virtual void setAutoAnimation (NL3D::CAnimationSet* pAnimSet) = 0; virtual void setAutoAnimation (NL3D::CAnimationSet* pAnimSet) = 0;

View file

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

View file

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

View file

@ -74,7 +74,7 @@ BOOL CPickSound::OnInitDialog()
for (TNameVect::iterator it = _Names.begin(); it != _Names.end(); ++it) 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); _Timer = SetTimer (1, 100, NULL);
@ -111,7 +111,7 @@ void CPickSound::OnSelchange()
nlassert(m_NameList.GetTextLen(m_NameList.GetCurSel()) < 1024); nlassert(m_NameList.GetTextLen(m_NameList.GetCurSel()) < 1024);
m_NameList.GetText(m_NameList.GetCurSel(), str); 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(); stopCurrSource();
CString sName; CString sName;
m_NameList.GetText(curSel, 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); nlassert(_RotatedParticle);
UpdateData(); UpdateData();
float newValue, valueMin, valueMax; float newValue, valueMin, valueMax;
if (sscanf(m_RotSpeedMin, "%f", &newValue) == 1) if (NLMISC::fromString(tStrToUtf8(m_RotSpeedMin), newValue))
{ {
uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax); uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax);
valueMin = newValue; valueMin = newValue;
@ -144,7 +144,7 @@ void CPrecomputedRotationsDlg::OnUpdateMaxRotSpeed()
nlassert(_RotatedParticle); nlassert(_RotatedParticle);
UpdateData(); UpdateData();
float newValue, valueMin, valueMax; float newValue, valueMin, valueMax;
if (sscanf(m_RotSpeedMax, "%f", &newValue) == 1) if (NLMISC::fromString(tStrToUtf8(m_RotSpeedMax), newValue))
{ {
uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax); uint32 nbModels = _RotatedParticle->checkHintRotateTheSame(valueMin, valueMax);
valueMax = newValue; valueMax = newValue;
@ -165,7 +165,7 @@ void CPrecomputedRotationsDlg::OnUpdateNbModels()
UpdateData(); UpdateData();
float valueMin, valueMax; float valueMin, valueMax;
sint32 newNbModels; 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)) if (dynamic_cast<NL3D::CPSConstraintMesh *>(_RotatedParticle))
{ {
valid &= (newNbModels < NL3D::ConstraintMeshMaxNumPrerotatedModels); valid &= (newNbModels < NL3D::ConstraintMeshMaxNumPrerotatedModels);

View file

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

View file

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

View file

@ -23,7 +23,7 @@
// CSelectString dialog // 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) : CDialog(CSelectString::IDD, pParent)
{ {
//{{AFX_DATA_INIT(CSelectString) //{{AFX_DATA_INIT(CSelectString)
@ -77,14 +77,14 @@ BOOL CSelectString::OnInitDialog()
CDialog::OnInitDialog(); CDialog::OnInitDialog();
// Change title // Change title
SetWindowText (Title.c_str()); SetWindowText (utf8ToTStr(Title));
// Empty button ? // Empty button ?
EmptyCtrl.ShowWindow (Empty?SW_SHOW:SW_HIDE); EmptyCtrl.ShowWindow (Empty?SW_SHOW:SW_HIDE);
// Add string // Add string
for (uint s=0; s<Strings.size(); s++) 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 return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE // EXCEPTION: OCX Property Pages should return FALSE

View file

@ -30,7 +30,7 @@ class CSelectString : public CDialog
{ {
// Construction // Construction
public: 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 // Dialog Data
//{{AFX_DATA(CSelectString) //{{AFX_DATA(CSelectString)

View file

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

View file

@ -455,26 +455,24 @@ void CSlotDlg::OnSetSkeleton()
void CSlotDlg::setWindowName () void CSlotDlg::setWindowName ()
{ {
char tmp[512]; std::string tmp = NLMISC::toString("Slot %d : ", Id);
_snprintf (tmp, 512, "Slot %d : ", Id);
if (isEmpty()) if (isEmpty())
strcat (tmp, "empty"); tmp += "empty";
else else
strcat (tmp, getSlotInformation ()->Animation .c_str()); tmp += getSlotInformation ()->Animation;
CSlotInfo *information = getSlotInformation (); CSlotInfo *information = getSlotInformation ();
if (information) if (information)
{ {
std::string SkeletonName = information->Skeleton; std::string SkeletonName = information->Skeleton;
if (SkeletonName != "") if (!SkeletonName.empty())
{ {
strcat (tmp, " ("); tmp += " (" + SkeletonName + ")";
strcat (tmp, SkeletonName.c_str());
strcat (tmp, ")");
} }
} }
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; dest = defaultStr;
return; return;
} }
std::string tmpDest;
tmpDest.resize(size); std::auto_ptr<TCHAR> tmpDest(new TCHAR[size]);
result = RegQueryValueEx(hKey, name, NULL, &type, (unsigned char *) &tmpDest[0], &size); result = RegQueryValueEx(hKey, name, NULL, &type, (BYTE*)tmpDest.get(), &size);
if (result != ERROR_SUCCESS) if (result != ERROR_SUCCESS)
{ {
dest = defaultStr; dest = defaultStr;
return; return;
} }
dest = tmpDest.c_str();
dest = *tmpDest;
} }
@ -167,14 +169,15 @@ void CSnapshotToolDlg::fromRegistry()
stringFromRegistry(hKey, _T("OutputPath"), m_OutputPath, ""); stringFromRegistry(hKey, _T("OutputPath"), m_OutputPath, "");
CString filters; CString filters;
stringFromRegistry(hKey, "Filters", filters, "*.shape"); stringFromRegistry(hKey, _T("Filters"), filters, "*.shape");
std::string stdFilters((LPCTSTR) filters);
std::vector<std::string> filterList; std::vector<std::string> filterList;
NLMISC::splitString(stdFilters, ",", filterList); NLMISC::splitString(tStrToUtf8(filters), ",", filterList);
m_Filters.ResetContent(); m_Filters.ResetContent();
for (uint k = 0; k < filterList.size(); ++k) 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); 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); MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_INPUT_PATH), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION);
return; 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); MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_INPUT_PATH_NOT_FOUND), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION);
return; return;
@ -415,13 +418,13 @@ void CSnapshotToolDlg::OnGo()
MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_OUTPUT_PATH), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION); MessageBox(getStrRsc(IDS_SNAPSHOT_EMPTY_OUTPUT_PATH), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION);
return; 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) if (MessageBox(getStrRsc(IDS_SNAPSHOT_CREATE_OUTPUT_DIRECTORY), getStrRsc(IDS_OBJECT_VIEWER), MB_OKCANCEL) != IDOK)
{ {
return; 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); MessageBox(getStrRsc(IDS_SNAPSHOT_OUTPUT_PATH_CREATION_FAILED), getStrRsc(IDS_OBJECT_VIEWER), MB_ICONEXCLAMATION);
return; return;
@ -442,7 +445,7 @@ void CSnapshotToolDlg::OnGo()
m_Log.ResetContent(); m_Log.ResetContent();
m_Log.AddString(getStrRsc(IDS_GETTING_PATH_CONTENT)); m_Log.AddString(getStrRsc(IDS_GETTING_PATH_CONTENT));
std::vector<std::string> files; 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()) if (files.empty())
{ {
m_Log.AddString(getStrRsc(IDS_SNAPSHOT_NO_FILES_FOUND)); m_Log.AddString(getStrRsc(IDS_SNAPSHOT_NO_FILES_FOUND));
@ -456,7 +459,7 @@ void CSnapshotToolDlg::OnGo()
CString wildCard; CString wildCard;
m_Filters.GetText(l, wildCard); m_Filters.GetText(l, wildCard);
wildCard.MakeLower(); 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]); _FilteredFiles.push_back(files[k]);
break; break;
@ -598,7 +601,7 @@ void CSnapshotToolDlg::OnTimer(UINT_PTR nIDEvent)
try try
{ {
CShapeStream ss; CShapeStream ss;
m_Log.AddString(_FilteredFiles[0].c_str()); m_Log.AddString(utf8ToTStr(_FilteredFiles[0]));
CIFile stream(_FilteredFiles[0]); CIFile stream(_FilteredFiles[0]);
ss.serial(stream); ss.serial(stream);
nlassert(ss.getShapePointer()); nlassert(ss.getShapePointer());
@ -706,10 +709,10 @@ void CSnapshotToolDlg::OnTimer(UINT_PTR nIDEvent)
switch(m_OutputPathOption) switch(m_OutputPathOption)
{ {
case OutputPath_Custom: // custom output path 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; break;
case OutputPath_SameAsInput: // Input path case OutputPath_SameAsInput: // Input path
outputFilename = LPCTSTR(m_InputPath) + std::string("\\") + NLMISC::CFile::getFilename(outputFilename); outputFilename = tStrToUtf8(m_InputPath) + "\\" + NLMISC::CFile::getFilename(outputFilename);
break; break;
case OutputPath_CurrShapeDirectory: // current path case OutputPath_CurrShapeDirectory: // current path
// no op // no op

View file

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

View file

@ -221,7 +221,7 @@ void CSoundAnimView::save()
if (fileDlg.DoModal() == IDOK) if (fileDlg.DoModal() == IDOK)
{ {
filename = (const char*) fileDlg.GetPathName(); filename = tStrToUtf8(fileDlg.GetPathName());
} }
else else
{ {
@ -236,7 +236,7 @@ void CSoundAnimView::save()
} }
catch (Exception& e) 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()) 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 else
{ {
GetDlgItem(IDC_STICK_BONE)->SetWindowText(_T("")); 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); GetDlgItem(IDC_ENABLE_AUTO_COUNT)->EnableWindow(TRUE);
((CButton *) GetDlgItem(IDC_ENABLE_AUTO_COUNT))->SetCheck(getCurrPS()->getAutoCountFlag() ? 1 : 0); ((CButton *) GetDlgItem(IDC_ENABLE_AUTO_COUNT))->SetCheck(getCurrPS()->getAutoCountFlag() ? 1 : 0);
GetDlgItem(IDC_RESET_COUNT)->EnableWindow((_ActiveNode->getPSPointer()->getAutoCountFlag() && !_ActiveNode->getResetAutoCountFlag()) ? TRUE : FALSE); GetDlgItem(IDC_RESET_COUNT)->EnableWindow((_ActiveNode->getPSPointer()->getAutoCountFlag() && !_ActiveNode->getResetAutoCountFlag()) ? TRUE : FALSE);
@ -844,7 +844,7 @@ void CStartStopParticleSystem::OnLinkToSkeleton()
uint boneIndex; uint boneIndex;
std::string parentSkelName; std::string parentSkelName;
std::string parentBoneName; 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); _ParticleDlg->stickPSToSkeleton(_ActiveNode, skel, boneIndex, parentSkelName, parentBoneName);
} }
@ -1017,11 +1017,11 @@ void CStartStopParticleSystem::OnBrowseAnim()
} }
} }
std::vector<std::string> animList(animSet.begin(), animSet.end()); 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) if (st.DoModal() == IDOK && st.Selection != -1)
{ {
m_TriggerAnim = animList[st.Selection].c_str(); 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()); GetDlgItem(IDC_CLEAR_ANIM)->EnableWindow(!_ActiveNode->getTriggerAnim().empty());
} }
_ParticleDlg->ParticleTreeCtrl->updateCaption(*_ActiveNode); _ParticleDlg->ParticleTreeCtrl->updateCaption(*_ActiveNode);

View file

@ -179,29 +179,22 @@ void CTextureChooser::OnBrowseTexture()
{ {
texName = (static_cast<NL3D::CTextureFile *>(_Wrapper->get()))->getFileName(); 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) if (fd.DoModal() == IDOK)
{ {
// Add to the path
char drive[256];
char dir[256];
char path[256];
// Add search path for the texture // Add search path for the texture
_splitpath (fd.GetPathName(), drive, dir, NULL, NULL); NLMISC::CPath::addSearchPath (NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName())));
_makepath (path, drive, dir, NULL, NULL);
NLMISC::CPath::addSearchPath (path);
try try
{ {
NL3D::CTextureFile *tf = new NL3D::CTextureFile(std::string(fd.GetFileName())); NL3D::CTextureFile *tf = new NL3D::CTextureFile(tStrToUtf8(fd.GetFileName()));
_Wrapper->setAndUpdateModifiedFlag(tf); _Wrapper->setAndUpdateModifiedFlag(tf);
_Texture = tf; _Texture = tf;
textureToBitmap(); textureToBitmap();
} }
catch (NLMISC::Exception &e) 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(); uint num= _VegetableDlg->getNumVegetables();
for(uint i=0; i<num; i++) 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 // Init ShapeName
// ---------- // ----------
StaticVegetableShape.SetWindowText(_Vegetable->ShapeName.c_str()); StaticVegetableShape.SetWindowText(utf8ToTStr(_Vegetable->ShapeName));
// init Creation Distance. // init Creation Distance.
// ---------- // ----------
@ -228,7 +228,7 @@ void CVegetableDensityPage::updateAngleMinFromEditText()
TCHAR stmp[256]; TCHAR stmp[256];
AngleMinEdit.GetWindowText(stmp, 256); AngleMinEdit.GetWindowText(stmp, 256);
float angleMin; float angleMin;
NLMISC::fromString(stmp, angleMin); NLMISC::fromString(tStrToUtf8(stmp), angleMin);
NLMISC::clamp(angleMin, -90, 90); NLMISC::clamp(angleMin, -90, 90);
// make a sinus, because 90 => 1, and -90 =>-1 // make a sinus, because 90 => 1, and -90 =>-1
float cosAngleMin= (float)sin(angleMin*NLMISC::Pi/180.f); float cosAngleMin= (float)sin(angleMin*NLMISC::Pi/180.f);
@ -252,7 +252,7 @@ void CVegetableDensityPage::updateAngleMaxFromEditText()
TCHAR stmp[256]; TCHAR stmp[256];
AngleMaxEdit.GetWindowText(stmp, 256); AngleMaxEdit.GetWindowText(stmp, 256);
float angleMax; float angleMax;
NLMISC::fromString(stmp, angleMax); NLMISC::fromString(tStrToUtf8(stmp), angleMax);
NLMISC::clamp(angleMax, -90, 90); NLMISC::clamp(angleMax, -90, 90);
// make a sinus, because 90 => 1, and -90 =>-1 // make a sinus, because 90 => 1, and -90 =>-1
float cosAngleMax= (float)sin(angleMax*NLMISC::Pi/180.f); float cosAngleMax= (float)sin(angleMax*NLMISC::Pi/180.f);
@ -523,22 +523,19 @@ void CVegetableDensityPage::OnButtonVegetableBrowse()
if (fd.DoModal() == IDOK) if (fd.DoModal() == IDOK)
{ {
// Add to the path // Add to the path
char drive[256]; std::string fileName = tStrToUtf8(fd.GetFileName());
char dir[256];
char path[256];
// Add search path for the .veget // Add search path for the .veget
_splitpath (fd.GetPathName(), drive, dir, NULL, NULL); std::string path = NLMISC::CFile::getPath(tStrToUtf8(fd.GetPathName()));
_makepath (path, drive, dir, NULL, NULL);
NLMISC::CPath::addSearchPath (path); NLMISC::CPath::addSearchPath (path);
try try
{ {
// verify the file can be opened. // verify the file can be opened.
NLMISC::CPath::lookup((const char*)fd.GetFileName()); NLMISC::CPath::lookup(fileName);
// update shapeName and view // update shapeName and view
_Vegetable->ShapeName= std::string(fd.GetFileName()); _Vegetable->ShapeName = fileName;
StaticVegetableShape.SetWindowText(fd.GetFileName()); StaticVegetableShape.SetWindowText(fd.GetFileName());
// update the name in the list-box // update the name in the list-box
@ -549,7 +546,7 @@ void CVegetableDensityPage::OnButtonVegetableBrowse()
} }
catch (NLMISC::EPathNotFound &ep) 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) 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); 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)));
} }