HRESULT Mesh::LoadMesh(WCHAR* directory, WCHAR* name, WCHAR* extension) { HRESULT hr; CleanUpMesh(); SetDirectory( directory ); SetName( name ); WCHAR meshfile[120]; WCHAR meshpathrel[120]; WCHAR meshpath[120]; Concat(meshfile, name, extension ); Concat(meshpathrel, directory, meshfile ); AppendToRootDir(meshpath, meshpathrel); hr = D3DXLoadMeshFromX( meshpath, D3DXMESH_MANAGED | D3DXMESH_32BIT, mDevice, NULL, &mMaterialBuffer, NULL, &mNumMaterials, &mMesh ); PD(hr, L"load mesh from file"); if(FAILED(hr)) return hr; mMaterials = (D3DXMATERIAL*)mMaterialBuffer->GetBufferPointer(); PD( AdjustMeshDecl(), L"adjust mesh delaration" ); PD( AttribSortMesh(), L"attribute sort mesh" ); PD( LoadTextures(), L"load textures" ); PD( CreateTopologyFromMesh(), L"create topology from mesh"); return D3D_OK; }
void Pathname::SetDrive(const char dr) { if (HasDrive()) { if (dr == 0) { strcpy(_path,_path+2); strcpy(_fullpath,_fullpath+2); } else { _path[0] = dr; _fullpath[0] = dr; } } else if (dr != 0) { int np = IsNetworkPath(); if (np) { _path[0] = dr; _path[1] =':'; strcpy(_path+2,_path+np); RebuildPath(); } else { char *c = (char *)alloca((strlen(_path)+4)*sizeof(*c)); sprintf(c,"%c:%s",dr,_path); SetDirectory(c); } } }
void FTP::ExecuteQueue(QueueExecOptions* op) { if(!QuequeSize) return; FTPHost oHost = Host; BOOL oShowHosts = ShowHosts; char oDir[MAX_PATH]; GetCurPath(oDir, ARRAYSIZE(oDir)); OverrideMsgCode = ocNone; ExecuteQueueINT(op); OverrideMsgCode = ocNone; //Restore plugin state if(op->RestoreState) { if(oShowHosts) { BackToHosts(); } else if(!Host.CmpConnected(&oHost)) { Host = oHost; FullConnect(); ResetCache=TRUE; } SetDirectory(oDir,0); Invalidate(); } }
bool Pathname::SetDirectorySpecial(int nSpecCode) { char buff[MAX_PATH]; if (SHGetSpecialFolderPath(GetForegroundWindow(),buff,nSpecCode,FALSE) != NOERROR) return false; SetDirectory(buff); return true; }
bool Pathname::SetTempDirectory() { char buff[1]; DWORD size = GetTempPath(1,buff); if (size == 0) return false; size++; char *p = (char *)alloca(size); if (GetTempPath(size,p) == 0) return false; SetDirectory(p); return true; }
tHandle cSensorAnalyzer::CreateView() { QWidget* pWidget = (QWidget*)m_pViewport->VP_GetWindow(); m_pWidget = new DisplayWidget(pWidget); connect(this, SIGNAL(SensorDataChanged(int,float)), m_pWidget, SLOT(SetSensorData(int,float))); connect(this, SIGNAL(DirectoryReceived(QString)), m_pWidget, SLOT(SetDirectory(QString))); connect(m_pWidget->GetDropDownWidget(), SIGNAL(currentIndexChanged(const QString&)), this, SLOT(SetConfiguration(const QString&))); return (tHandle)m_pWidget; }
virtual void Entered() { // Get the system directory, but only if this is a packaged Haiku. // Otherwise blacklisting isn't supported. if (sBootVolume != NULL && sBootVolume->IsValid() && sBootVolume->IsPackaged()) { SetDirectory(sBootVolume->SystemDirectory()); SetTitle(kDefaultMenuTitle); } else { SetDirectory(NULL); SetTitle(sBootVolume != NULL && sBootVolume->IsValid() ? "The selected boot volume doesn't support blacklisting!" : "No boot volume selected!"); } BlacklistMenu::Entered(); // rename last item if (MenuItem* item = ItemAt(CountItems() - 1)) item->SetLabel("Return to safe mode menu"); }
cPluginManager::cPluginManager(const char *Directory) { directory = NULL; lastHousekeeping = time(NULL); nextHousekeeping = -1; if (pluginManager) { fprintf(stderr, "vdr: attempt to create more than one plugin manager - exiting!\n"); exit(2); } SetDirectory(Directory); pluginManager = this; }
NS_IMETHODIMP nsFileView::SetShowHiddenFiles(bool aShowHidden) { if (aShowHidden != mShowHiddenFiles) { mShowHiddenFiles = aShowHidden; // This could be better optimized, but since the hidden // file functionality is not currently used, this will be fine. SetDirectory(mDirectoryPath); } return NS_OK; }
void TestDirNode(PCHAR DirName, PCHAR FName) { HANDLE hFile; if (CreateDirectoryOem( DirName, NULL)) printf("CreateDirectoryOem <%s>\n",DirName); else printf("CreateDirectoryOem <%s>- Fail\n",DirName); SetDirectory(DirName); hFile = CreateFileOem( FName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); if (hFile == (HANDLE) 0xFFFFFFFF) { printf("CreateFileOem<%s>- Fail\n", FName); } else { printf("CreateFileOem<%s>\n", FName); CloseHandle(hFile); } if (DeleteFileOem(FName)) printf("DeleteFileOem <%s>\n",FName); else printf("DeleteFileOem <%s>- Fail\n",FName); SetDirectory("\\"); if (RemoveDirectoryOem(DirName)) printf("RemoveDirectoryOem <%s>\n",DirName); else printf("RemoveDirectoryOem <%s>- Fail\n",DirName); }
void AG_FileSelectorSetDirectory(AG_FileSelector *fs, const char *path) { char dir[AG_PATHNAME_MAX]; Strlcpy(dir, path, sizeof(dir)); if (dir[0] != '\0' && dir[strlen(dir)-1] != AG_PATHSEPCHAR) { dir[strlen(dir)-1] = AG_PATHSEPCHAR; } AG_ObjectLock(fs->filedlg); SetDirectory(fs, dir); AG_TextboxSetString(fs->tbox, dir); AG_ObjectUnlock(fs->filedlg); }
bool Pathname::FullToRelative(const Pathname &relativeto) { if (relativeto.IsNull() || IsNull()) return false; bool h1= HasDrive(); bool h2= relativeto.HasDrive(); if (h1 != h2) return false; //rozdilny zpusob adresace - nelze vytvorit relatvni cestu if (h1== true && h2== true && toupper(GetDrive()) != toupper(relativeto.GetDrive())) return false; //ruzne disky, nelze vytvorit relativni cestu if (strncmp(_path,"\\\\",2) == 0) //sitova cesta { int slsh = 0; //citac lomitek const char *a = _path; const char *b = relativeto._path; while (toupper(*a) == toupper(*b) && *a && slsh<3) //zacatek sitove cesty musi byt stejny { if (*a =='\\') slsh++; a++;b++; } if (slsh != 3) return false; //pokud neni stejny, nelze vytvorit relativni cestu } int sublevel = 0; const char *ps1= _path; const char *ps2= relativeto._path; if (h1) {ps1 += 2;ps2 += 2;} const char *sls = ps2; while (toupper(*ps1) == toupper(*ps2) && *ps1) { if (*ps2=='\\') sls = ps2+1; ps1++;ps2++; } ps1 -= ps2-sls; if (sls) { while (sls = strchr(sls,'\\')) { sls++; sublevel++; } } char *buff = (char *)alloca((sublevel*3+strlen(ps1)+1)*sizeof(*buff)); char *pos = buff; for (int i = 0;i<sublevel;i++) {strcpy(pos,"..\\");pos += 3;} strcpy(pos,ps1); SetDrive(0); SetDirectory(buff); return true; }
void Pathname::SetServerName(const char *server) { if (HasDrive()) SetDrive(0); else { int np = IsNetworkPath(); if (np) strcpy(_path,_path+np); //str } char *buff = (char *)alloca((strlen(server)+strlen(_path)+5)*sizeof(*buff)); if (_path[0]!='\\') sprintf(buff,"\\\\%s\\%s",server,_path); else sprintf(buff,"\\\\%s%s",server,_path); SetDirectory(buff); }
bool wxGenericFileCtrl::SetPath( const wxString& path ) { if ( !wxFileName::FileExists( ( path ) ) ) return false; wxString ext; wxFileName::SplitPath( path, &m_dir, &m_fileName, &ext ); if ( !ext.empty() ) { m_fileName += wxT( "." ); m_fileName += ext; } SetDirectory( m_dir ); SetFilename( m_fileName ); return true; }
Pathname::Pathname(const char *relpath, const Pathname &abspath) { _path = _filetitle = _extension = _end =""; _fullpath = NULL; char *part; char *pth = strcpy((char *)alloca(sizeof(*relpath)+strlen(relpath)+1),relpath); part = strrchr(pth,'\\'); if (part) part++;else part = NULL; if (part) { SetFilename(part); *part = 0; SetDirectory(pth); } else SetFilename(pth); if (RelativeToFull(abspath) == false) SetNull(); }
HRESULT Mesh::LoadMesh(ID3DXMesh* mesh){ HRESULT hr; CleanUpMesh(); D3DVERTEXELEMENT9 decl[MAX_FVF_DECL_SIZE]; hr = mesh->GetDeclaration(decl); hr = mesh->CloneMesh( mesh->GetOptions(), decl, mDevice, &mMesh ); PD(hr, L"clone mesh"); ReleaseCOM(mesh) SetDirectory( L"models/" ); SetName( L"meshlab" ); PD( AdjustMeshDecl(), L"adjust mesh delaration" ); PD( AttribSortMesh(), L"attribute sort mesh" ); return D3D_OK; }
bool wxGenericFileCtrl::SetPath( const wxString& path ) { wxString dir, fn, ext; wxFileName::SplitPath(path, &dir, &fn, &ext); if ( !dir.empty() && !wxFileName::DirExists(dir) ) return false; m_dir = dir; m_fileName = fn; if ( !ext.empty() || path.Last() == '.' ) { m_fileName += wxT( "." ); m_fileName += ext; } SetDirectory( m_dir ); SetFilename( m_fileName ); return true; }
void Pathname::SetPathName(const char *pathname) { if (pathname == NULL || pathname[0] == 0) { SetNull(); return; } char *part; DWORD needsz = GetFullPathName(pathname,0,NULL,&part); char *fpth = (char *)alloca(needsz*sizeof(*fpth)); GetFullPathName(pathname,needsz,fpth,&part); part = strrchr(fpth,'\\'); if (part) part++;else part = NULL; if (part) { SetFilename(part); *part = 0; } else SetFilename(""); SetDirectory(fpth); }
//------------------------------------------------------------- // Pre : If pLastDirectory is given we will store the name of the // deepest directory (the one we're just exiting) in it // Task : Remove deepest subdirectory from path //------------------------------------------------------------- void CPath::UpDirectory(std::string *pLastDirectory /*= NULL*/) { std::string Directory; GetDirectory(Directory); StripTrailingBackslash(Directory); if(Directory.empty()) return; std::string::size_type nDelimiter =Directory.rfind(DIRECTORY_DELIMITER); if(pLastDirectory != NULL) { *pLastDirectory =Directory.substr(nDelimiter); StripLeadingBackslash(*pLastDirectory); } if(nDelimiter != std::string::npos) Directory =Directory.substr(0,nDelimiter); SetDirectory(Directory.c_str()); }
bool Pathname::RelativeToFull(const Pathname &ref) { if (ref.IsNull() || IsNull()) return false; const char *beg; if (HasDrive()) if (toupper(GetDrive()) != toupper(ref.GetDrive())) return false; else beg = _path+2; else beg = _path; const char *end = strchr(ref._path,0); if (beg[0] =='\\') { int np; if (ref.HasDrive()) end = ref._path+2; else if (np = ref.IsNetworkPath()) end = ref._path+np; else end = ref._path; } else while (strncmp(beg,"..\\",3) == 0 || strncmp(beg,".\\",2) == 0) { if (beg[1] =='.') { if (end>ref._path) { end--; while (end>ref._path && end[-1]!='\\') end--; } beg += 3; } else beg += 2; } int partln = end-ref._path; char *buff = (char *)alloca((partln+strlen(beg)+1)*sizeof(*buff)); memcpy(buff,ref._path,partln); strcpy(buff+partln,beg); SetDrive(0); SetDirectory(buff); return true; }
//============================================================ // <T>配置处理。</T> // // @return 处理结果 //============================================================ TResult FEwAssetConsole::Setup(){ // 获得应用路径 TCharC* pApplicationPath = RApplication::Instance().Parameters()->FindValue("-application"); SetDirectory(pApplicationPath); // 注册资源路径 TFsPath path; path.AssignFormat("%s/Asset", pApplicationPath); path.Replace('\\', '/'); RegisterSpace("asset", path); // 注册脚本路径 path.AssignFormat("%s/Script", pApplicationPath); path.Replace('\\', '/'); RegisterSpace("script", path); //............................................................ // 注册渲染器路径 TCharC* pSystemPath = RApplication::Instance().Parameters()->FindValue("-system"); if(pSystemPath == NULL){ pSystemPath = pApplicationPath; } path.AssignFormat("%s/Shader", pSystemPath); path.Replace('\\', '/'); RegisterSpace("shader", path); return ESuccess; }
virtual void Exited() { BlacklistMenu::Exited(); SetDirectory(NULL); }
DWORD _CRTAPI1 main( void) { DWORD dw; dw = GetEnvironmentVariableOem("TMP", achEnvTMP, MAXSTR); if (!dw || dw > MAXSTR-1) printf("GetEnvironmentVariableOem(TMP) failed dw=%ld\n",dw); else printf("TMP=<%s>\n",achEnvTMP); dw = GetWindowsDirectoryOem(achWinDir, MAXSTR); if (!dw || dw > MAXSTR-1) printf("GetWindowsDirectory failed dw=%ld\n",dw); else printf("WinDir=<%s>\n",achWinDir); dw = GetSystemDirectoryOem(achSysDir, MAXSTR); if (!dw || dw > MAXSTR-1) printf("GetSystemDirectory(achSysDir failed dw=%ld\n",dw); else printf("SysDir=<%s>\n",achWinDir); dw = GetCurrentDirectory(MAXSTR, achCurDir); if (!dw || dw > MAXSTR-1) printf("GetCurrentDirectory(achCurDir dw=%ld\n",dw); else printf("CurDir=<%s>\n",achWinDir); SetDirectory(achEnvTMP); SetDirectory(achWinDir); SetDirectory(achSysDir); SetDirectory(achCurDir); Pause(); strcpy(ach, achCurDir); strcat(ach, "\\foo"); TestDirNode(ach, "foo.foo"); SetDirectory(achCurDir); Pause(); dw = GetTempPathOem(MAXSTR, ach); if (!dw || dw > MAXSTR) printf("GetTempPathOem - Failed\n"); else { printf("GetTempPathOem<%s>\n",ach); if (!GetTempFileNameOem(".", "OEM", 0, achTmp)) printf("GetTempFileNameOem - Failed\n"); else printf("GetTempFileNameOem<%s>\n",ach); TestDirNode(ach, achTmp); } SetDirectory(achCurDir); Pause(); }
SetDirectory::SetDirectory(const std::string& filename) { SetDirectory(filename.c_str()); }
int FTP::ExpandList(PluginPanelItem *pi,int icn,FP_SizeItemList* il,BOOL FromPlugin,ExpandListCB cb,LPVOID Param) { PROC(("ExpandList","cn:%d, ilcn:%d/%d, %s, cb:%08X",icn,il ? il->Count() : 0,il ? il->MaxCount : 0,FromPlugin?"PLUGIN":"LOCAL",cb)) BOOL pSaved = Host.Home[0] && SelectFile.Length(); BOOL old_ext = hConnect ? hConnect->Host.ExtCmdView : FALSE; FTPCurrentStates olds = CurrentState; int rc; { FTPConnectionBreakable _brk(hConnect,FALSE); CurrentState = fcsExpandList; if(hConnect) { hConnect->Host.ExtCmdView = FALSE; hConnect->CurrentState = fcsExpandList; } if(!pSaved) SaveUsedDirNFile(); rc = ExpandListINT(pi,icn,il,FromPlugin,cb,Param); if(hConnect) { hConnect->Host.ExtCmdView = old_ext; hConnect->CurrentState = olds; } CurrentState = olds; } Log(("ExpandList rc=%d",rc)); #if defined(__FILELOG__) if(rc) { Log(("Expand succ ends containing:")); if(il) LogPanelItems(il->Items(), il->Count()); else Log(("Files list does not contains files")); } #endif if(!pSaved) { if(!rc) { SaveLastError _err; if(Host.Home[0]) { char str[MAX_PATH]; GetCurPath(str, ARRAYSIZE(str)); if(StrCmpI(str, Host.Home) != 0) SetDirectory(Host.Home,FP_LastOpMode); } } else { SelectFile = ""; Host.Home[0] = 0; } } return rc; }
int TmpPanel::ProcessKey(const INPUT_RECORD *Rec) { if (Rec->EventType != KEY_EVENT) return FALSE; int Key=Rec->Event.KeyEvent.wVirtualKeyCode; unsigned int ControlState=Rec->Event.KeyEvent.dwControlKeyState; if (ControlState==(SHIFT_PRESSED|LEFT_ALT_PRESSED) && Key==VK_F3) { PtrGuard CurFileName; if (IsCurrentFileCorrect(CurFileName.PtrPtr())) { struct PanelInfo PInfo = {sizeof(PanelInfo)}; Info.PanelControl(this,FCTL_GETPANELINFO,0,&PInfo); if (lstrcmp(CurFileName,L"..")!=0) { size_t Size=Info.PanelControl(this,FCTL_GETPANELITEM,PInfo.CurrentItem,0); PluginPanelItem* PPI=(PluginPanelItem*)malloc(Size); DWORD attributes=0; if (PPI) { FarGetPluginPanelItem gpi={sizeof(FarGetPluginPanelItem), Size, PPI}; Info.PanelControl(this,FCTL_GETPANELITEM,PInfo.CurrentItem,&gpi); attributes=(DWORD)PPI->FileAttributes; free(PPI); } if (attributes&FILE_ATTRIBUTE_DIRECTORY) { FarPanelDirectory dirInfo = {sizeof(dirInfo), CurFileName, nullptr, {}, nullptr}; Info.PanelControl(PANEL_PASSIVE, FCTL_SETPANELDIRECTORY, 0, &dirInfo); } else { GoToFile(CurFileName, true); } Info.PanelControl(PANEL_PASSIVE, FCTL_REDRAWPANEL,0,NULL); return(TRUE); } } } if (ControlState!=LEFT_CTRL_PRESSED && Key>=VK_F3 && Key<=VK_F8 && Key!=VK_F7) { if (!IsCurrentFileCorrect(NULL)) return(TRUE); } if (ControlState==0 && Key==VK_RETURN && Opt.AnyInPanel) { PtrGuard CurFileName; if (!IsCurrentFileCorrect(CurFileName.PtrPtr())) { Info.PanelControl(this,FCTL_SETCMDLINE,0,CurFileName.Ptr()); return(TRUE); } } if (Opt.SafeModePanel && ControlState == LEFT_CTRL_PRESSED && Key == VK_PRIOR) { PtrGuard CurFileName; if (IsCurrentFileCorrect(CurFileName.PtrPtr())) { if (lstrcmp(CurFileName,L"..")) { GoToFile(CurFileName, false); return TRUE; } } if (CurFileName.Ptr() && !lstrcmp(CurFileName,L"..")) { SetDirectory(L".",0); return TRUE; } } if (ControlState==0 && Key==VK_F7) { ProcessRemoveKey(); return TRUE; } else if (ControlState == (SHIFT_PRESSED|LEFT_ALT_PRESSED) && Key == VK_F2) { ProcessSaveListKey(); return TRUE; } else { if (StartupOptCommonPanel && ControlState==(SHIFT_PRESSED|LEFT_ALT_PRESSED)) { if (Key==VK_F12) { ProcessPanelSwitchMenu(); return(TRUE); } else if (Key >= L'0' && Key <= L'9') { SwitchToPanel(Key - L'0'); return TRUE; } } } return(FALSE); }
BOOL CParseCmd::ParseCommandLine(int argc, _TCHAR *argv[]) // Purpose : Proceses the command line, and options // Inputs : argc, argv - command line as passed to the process { // Test the number of arguments if(argc == 1) throw ErrInsufficientArgs; int wCount = 1; // Parse the command line // Check for options while(wCount < argc) { if(argv[wCount][0] != '-' && argv[wCount][0] != '/') break; else { if(argv[wCount][1] == '\0') throw ErrBadCommandFlag; switch(argv[wCount][1]) { case 'h' : // Help. i.e Show Syntax case 'H' : m_fShowSyntax = TRUE; return TRUE; case 'p' : // Use Password for Private Key Decryption case 'P' : m_dwOptions |= EOptPassword; { wCount++; DWORD pwlen=_tcslen(argv[wCount]); LPWSTR pwStr=MakeUnicodeString((LPCSTR)argv[wCount], CP_OEMCP, pwlen); wcscpy(m_pszPassword, pwStr); } break; case 'v' : // Verbose case 'V' : m_dwOptions |= EOptVerbose; break; case 's' : // Generate stub case 'S' : m_dwOptions |= EOptMakeStub; break; case 'd' : // Search directory case 'D' : m_dwOptions |= EOptDirectory; #ifdef _UNICODE SetDirectory(&argv[wCount][2]); #else { DWORD len=_tcslen(&argv[wCount][2]); LPWSTR uniStr=MakeUnicodeString(&argv[wCount][2], CP_OEMCP, len); SetDirectory(uniStr); delete [] uniStr; } #endif break; #ifdef TEST case 't': if (sscanf(&argv[wCount][2], "%x,%x,%x,%x,%x,%x", (unsigned int*) &m_dwYear, (unsigned int*) &m_dwMonth, (unsigned int*) &m_dwDay, (unsigned int*) &m_dwHours, (unsigned int*) &m_dwMinutes, (unsigned int*) &m_dwSeconds) == 6) m_fSetTimestamp = TRUE; else printf("Bad parameter -t\n"); break; #endif default : // Uh-Oh... throw ErrBadCommandFlag; } wCount++; } } // Get the source and (optionally) target filenames if(wCount < argc) { #ifdef _UNICODE SetSource(argv[wCount++]); #else DWORD len=_tcslen(argv[wCount]); LPWSTR uniStr=MakeUnicodeString(argv[wCount], CP_OEMCP, len); SetSource(uniStr); delete [] uniStr; wCount++; #endif } else throw ErrNoSourceFile; if(wCount < argc) { #ifdef _UNICODE SetTarget(argv[wCount]); #else DWORD len=_tcslen(argv[wCount]); LPWSTR uniStr=MakeUnicodeString(argv[wCount], CP_OEMCP, len); SetTarget(uniStr); delete [] uniStr; wCount++; #endif } return TRUE; }
// destructor VirtualDirIterator::~VirtualDirIterator() { SetDirectory(NULL); }
// called by OnNewDocument() // returns FALSE if the user cancels the dialog BOOL CProjectDoc::doNewFromCarlaMenu(CString& sProjectPath) { CWizNewFromCarla dlg(this); // stick in CCarlaLanguages's default font //getSourceLang()->getFont()->GetLogFont(&dlg.m_srcLangDisplayPage.m_logFont); if(IDOK != dlg.DoModal()) return FALSE; // note that during the wizard we parsed in the carla.set file sProjectPath = dlg.m_projectPage.m_sProjectPath; SetDirectory(sProjectPath); // make this the working directory if(!getSourceLang() || !getSourceLang()->getAbrev().GetLength()) { MessageBox( NULL, "This does not appear to be a valid CARLA.SET file (no \\src sMarker found)\n", NULL, MB_OK); return FALSE; } CCarlaLanguage* pLang = m_pLangDocs[0]->getLang(); ASSERTX(pLang); //pLang->setAbrev(dlg.m_srcLangDisplayPage.m_sAbrev); //pLang->setName(dlg.m_srcLangDisplayPage.m_sName); //pLang->setFont(&dlg.m_srcLangDisplayPage.m_logFont); pLang->readLangDisplayPage(dlg.m_srcLangDisplayPage); pLang->readCARLAMenuLangFile(dlg.m_cmenuPage.m_cCommentChar); if(m_pLangDocs.GetSize()==2) // if there was a target lang specified { pLang = m_pLangDocs[1]->getLang(); ASSERTX(pLang); // pLang->readCARLAMenuLangFile(dlg.m_cmenuPage.m_cCommentChar); // pLang->setAbrev(dlg.m_tarLangDisplayPage.m_sAbrev); // pLang->setName(dlg.m_tarLangDisplayPage.m_sName); //pLang->setFont(&dlg.m_tarLangDisplayPage.m_logFont); pLang->readLangDisplayPage(dlg.m_tarLangDisplayPage); pLang->readCARLAMenuLangFile(dlg.m_cmenuPage.m_cCommentChar); // if there were two languages, tell the first one (the source) to copy in the // control files for transfering to the other language. We skip asking to got // the other direction to, out of the lack of expecation that those files exist. // It might not do any harm to try, though, if someone comes up with a reason. m_pLangDocs[0]->getLang()->setConversionTargetLang(m_pLangDocs[1]->getLang()); } /* getSourceLang()->setAbrev(dlg.m_srcLangDisplayPage.m_sAbrev); getSourceLang()->setName(dlg.m_srcLangDisplayPage.m_sName); getSourceLang()->setFont(&dlg.m_srcLangDisplayPage.m_logFont); getSourceLang()->readCARLAMenuLangFile(); if(getTargetLang()) { getTargetLang()->readCARLAMenuLangFile(); getTargetLang()->setAbrev(dlg.m_tarLangDisplayPage.m_sAbrev); getTargetLang()->setName(dlg.m_tarLangDisplayPage.m_sName); getTargetLang()->setFont(&dlg.m_tarLangDisplayPage.m_logFont); // won't find any files because carlamenu is one-way transfer only, // so leave this one out // getTargetLang()->setConversionTargetLang(m_pSource); getSourceLang()->setConversionTargetLang(getTargetLang()); } */ return TRUE; }
int main(int argc, char* argv[]) { SetDirectory(); behaviac::IMemAllocator& allocator = behaviac::GetDefaultMemoryAllocator(); uint32_t allocatedSize = allocator.GetAllocatedSize(); MyCommandLine cl(argc, argv); cl.PrintHelp(); cl.ReadOptions(); g_level = cl.Level(); if (g_level == -1) { g_level = cl.SelectLevel(); } behaviac::Workspace::GetInstance()->SetFilePath("../example/spaceship/data/bt/exported"); behaviac::Workspace::GetInstance()->SetFileFormat(behaviac::Workspace::EFF_xml); //LogManager::GetInstance()->SetFlush(true); behaviac::Agent::Register<framework::WorldState>(); behaviac::Agent::RegisterInstanceName<framework::WorldState>(); framework::WorldState* pWorldState = behaviac::Agent::Create<framework::WorldState>(); pWorldState->SetIdFlag(kIdMask_Wolrd); behaviac::Agent::Register<framework::Ship>(); behaviac::Agent::Register<framework::Projectile>(); behaviac::Workspace::GetInstance()->ExportMetas("../example/spaceship/data/ships.xml"); if (!cl.IsProfiling()) { behaviac::Agent::SetIdMask(kIdMask_Wolrd | kIdMask_Opponent); } behaviac::Config::SetLogging(true); printf("game starting...\n"); /* initialize SDL */ if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { printf("SDL_Init Failed : %s\n", SDL_GetError()); } /* create window */ SDL_Window* window = SDL_CreateWindow("Space Ship", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, kWIDTH, kHEIGHT, 0); SDL_Surface* screen = SDL_GetWindowSurface(window); SDL_Renderer* sdlrenderer = SDL_CreateRenderer(window, -1, 0); SDL_SetRenderDrawColor(sdlrenderer, 0, 0, 0, 255); // Initialize SDL_ttf library if (TTF_Init() != 0) { printf("TTF_Init Failed : %s\n", TTF_GetError()); } // Load a font TTF_Font* font = TTF_OpenFont("../example/spaceship/Resources/Fonts/arial.ttf", 14); if (font == NULL) { printf("TTF_OpenFont Failed : %s\n", TTF_GetError()); TTF_Quit(); } framework::ws = behaviac::Agent::GetInstance<framework::WorldState>(0); framework::renderer = BEHAVIAC_NEW framework::Renderer(); framework::renderer->sdlrenderer = sdlrenderer; framework::GameLogic* logic = BEHAVIAC_NEW framework::GameLogic(); framework::gl = logic; GFrameHandler frame_handler; frame_handler.set_fps_limit(60); //background and player { framework::GameObject* background = BEHAVIAC_NEW framework::GameObject(); background->usesPhysics = false; background->setSprite("Backgrounds/background", true); framework::ws->addBackgroundObject(background); framework::Ship* player = behaviac::Agent::Create<framework::Ship>(); player->SetIdFlag(kIdMask_Player); player->setSprite("Hulls/Sample Hull"); player->isPlayer = true; player->projectileBrain = &makeBoringBrain; framework::ws->insertObject(player, framework::point(100, 300)); framework::ws->SetPlayer(player); } framework::ws->time = SDL_GetTicks(); framework::ws->ResetSyncSignal(); bool par_a = false; int par_b = 0; /* message pump */ while (!g_gameover) { HandleInput(); if (cl.IsProfiling()) { behaviac::Profiler::GetInstance()->BeginFrame(); } frame_handler.limit_frame(); frame_handler.calculate(); if (g_level != g_level_last) { g_level_last = g_level; loadlevel(g_level); char title[_MAX_PATH]; string_sprintf(title, "%s - press '0-9' to switch levels", gs_levels[g_level].name); SDL_SetWindowTitle(window, title); par_a = !par_a; par_b++; if (framework::ws->GetAI()) { framework::ws->GetAI()->SetVariable("par_a", par_a); framework::ws->GetAI()->SetVariable("par_b", par_b); } } logic->step(); // clear the screen SDL_RenderClear(sdlrenderer); // render all sprites framework::renderer->Render(); // Write text to surface if (framework::ws->GetPlayer()) { char playerHP[_MAX_PATH]; string_sprintf(playerHP, "Player HP : %d", framework::ws->GetPlayer()->getHealth()); renderText(sdlrenderer, font, playerHP, kWIDTH - 120, kHEIGHT - 60); char aiHP[_MAX_PATH]; if (framework::ws->GetAI()) { string_sprintf(aiHP, "AI HP : %d", framework::ws->GetAI()->getHealth()); } else { string_sprintf(aiHP, "AI Dead"); } renderText(sdlrenderer, font, aiHP, kWIDTH - 120, kHEIGHT - 40); } // Refreshing the screen SDL_RenderPresent(sdlrenderer); if (cl.IsProfiling()) { behaviac::Profiler::GetInstance()->EndFrame(); } } /* cleanup SDL */ //SDL_DestroyRenderer(sdlrenderer); //SDL_DestroyWindow(window); SDL_Quit(); behaviac::Agent::UnRegister<framework::Projectile>(); behaviac::Agent::UnRegister<framework::Ship>(); behaviac::Agent::UnRegister<framework::WorldState>(); behaviac::Agent::Destroy(pWorldState); behaviac::Agent::UnRegisterInstanceName<framework::WorldState>(); uint32_t allocatedSize1 = allocator.GetAllocatedSize(); int32_t allocDiff = allocatedSize1 - allocatedSize; if (cl.IsProfiling()) { const behaviac::string profile_data = behaviac::Profiler::GetInstance()->GetData(true, false); behaviac::string profile_data_m = "\n"; profile_data_m += profile_data; profile_data_m += "\n"; //BEHAVIAC_LOGMSG("\n%s\n", profile_data_m.c_str()); behaviac::ConsoleOut::PrintLines(profile_data_m.c_str()); } return 0; }