void SystemMgr::LoadScriptTextsCustom() { sLog->outString("TSCR: Loading Custom Texts..."); LoadStrings("custom_texts", TEXT_SOURCE_RANGE*2, 1+(TEXT_SOURCE_RANGE*3)); sLog->outString("TSCR: Loading Custom Texts additional data..."); QueryResult result = WorldDB.Query("SELECT entry, sound, type, language, emote FROM custom_texts"); if (!result) { sLog->outString(">> Loaded 0 additional Custom Texts data. DB table `custom_texts` is empty."); sLog->outString(); return; } uint32 uiCount = 0; do { Field* pFields = result->Fetch(); StringTextData pTemp; int32 iId = pFields[0].GetInt32(); pTemp.uiSoundId = pFields[1].GetUInt32(); pTemp.uiType = pFields[2].GetUInt32(); pTemp.uiLanguage = pFields[3].GetUInt32(); pTemp.uiEmote = pFields[4].GetUInt32(); if (iId >= 0) { sLog->outErrorDb("TSCR: Entry %i in table `custom_texts` is not a negative value.", iId); continue; } if (iId > TEXT_SOURCE_RANGE*2 || iId <= TEXT_SOURCE_RANGE*3) { sLog->outErrorDb("TSCR: Entry %i in table `custom_texts` is out of accepted entry range for table.", iId); continue; } if (pTemp.uiSoundId) { if (!GetSoundEntriesStore()->LookupEntry(pTemp.uiSoundId)) sLog->outErrorDb("TSCR: Entry %i in table `custom_texts` has soundId %u but sound does not exist.", iId, pTemp.uiSoundId); } if (!GetLanguageDescByID(pTemp.uiLanguage)) sLog->outErrorDb("TSCR: Entry %i in table `custom_texts` using Language %u but Language does not exist.", iId, pTemp.uiLanguage); if (pTemp.uiType > CHAT_TYPE_ZONE_YELL) sLog->outErrorDb("TSCR: Entry %i in table `custom_texts` has Type %u but this Chat Type does not exist.", iId, pTemp.uiType); m_mTextDataMap[iId] = pTemp; ++uiCount; } while (result->NextRow()); sLog->outString(">> Loaded %u additional Custom Texts data.", uiCount); sLog->outString(); }
void Log::Init() { _app.open("applog.txt"); _client.open("clntlog.txt"); _server.open("srvrlog.txt"); _kernel.open("kernellog.txt"); if (!LoadStrings()) CDThrowError("String codes could not be loaded"); }
int32 scriptlib::debug_reload_field_begin(lua_State *L) { check_param_count(L, 1); duel* pduel = interpreter::get_duel_info(L); uint32 flag = lua_tointeger(L, 1); pduel->clear(); pduel->game_field->core.duel_options = flag; gameConf.language LoadStrings(); return 0; }
bool CLog::Init() { appLog.open("applog.txt"); clientLog.open("clntlog.txt"); serverLog.open("srvrlog.txt"); //user errors get logged to client //load the strings file if(!LoadStrings())return false; return true; }
bool NE::Log::Init() { appLog.open("applicationLog.txt"); clientLog.open("clientLog.txt"); serverLog.open("serverlog.txt"); // Eser messages get logged to console //load the strings file if(!LoadStrings())return false; return true; }
/////////////////////////////////////////////////////////////////////////////// // Main // int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HWND hWnd = GetForegroundWindow(); *g_sUninstallPath = 0; WCHAR *sCommandLine = GetCommandLine(); WCHAR *sRemoveParam = wcsstr(sCommandLine, c_sRemoveParam); WCHAR g_bRunFromSetupDll = (wcsstr(sCommandLine, c_sSetupParam) != NULL); if (sRemoveParam != NULL) { // Launched from a temp directory with parameters "[remove] \Program Files\Fennec\" wcscpy(g_sUninstallPath, sRemoveParam + wcslen(c_sRemoveParam) + 1); } else { // Just copy this EXE and launch it from a temp location with a special parameter // to delete itself in the installation directory if (CopyAndLaunch()) return ErrOK; } // Perform uninstallation when executed with a special parameter // (or in case when CopyAndLaunch failed - just execute in place) if (!LoadStrings()) { MessageBoxW(hWnd, L"Cannot find the strings file.", L"Uninstall", MB_OK|MB_ICONWARNING); return ErrNoStrings; } if (GetInstallPath(g_sInstallPath)) { int nDlgResult = DialogBox(hInstance, (LPCTSTR)IDD_MAIN, NULL, (DLGPROC)DlgUninstall); if (nDlgResult != ErrOK) g_nResult = nDlgResult; } else { MessageBoxW(hWnd, Strings.GetString(StrID_InstallationNotFound), Strings.GetString(StrID_UninstallCaption), MB_OK|MB_ICONINFORMATION); return ErrInstallationNotFound; } return g_nResult; }
/////////////////////////////////////////////////////////////////////////////// // // InitInstance // /////////////////////////////////////////////////////////////////////////////// BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { g_hInst = hInstance; InitCommonControls(); g_sExeFileName[0] = L'\0'; if (GetModuleFileName(NULL, g_sExeFullFileName, MAX_PATH) == 0) return FALSE; wcscpy(g_sSourcePath, g_sExeFullFileName); WCHAR *sSlash = wcsrchr(g_sSourcePath, L'\\'); wcscpy(g_sExeFileName, sSlash + 1); *sSlash = L'\0'; // cut the file name g_dwExeSize = GetExeSize(); return LoadStrings(); }
void BuildAndOutputTable(FILE *fp, FILE *fpBody, FILE *fpInclude, char *UpperPrefix, char *LowerPrefix) { // Construct State Transition Table. // sm.Init(); LoadStrings(fp, fpBody, fpInclude); TestTable(fp); sm.SetUndefinedStates(false); TestTable(fp); // Optimize State Transition Table. // sm.MergeAcceptingStates(); TestTable(fp); sm.MergeAcceptingStates(); TestTable(fp); sm.MergeAcceptingStates(); TestTable(fp); sm.RemoveDuplicateRows(); TestTable(fp); sm.RemoveDuplicateRows(); TestTable(fp); sm.RemoveDuplicateRows(); TestTable(fp); sm.DetectDuplicateColumns(); // Output State Transition Table. // sm.NumberStates(); OutputControl oc; oc.fpBody = fpBody; oc.fpInclude = fpInclude; oc.UpperPrefix = UpperPrefix; oc.LowerPrefix = LowerPrefix; sm.OutputTables(&oc, NULL); }
INT CommandDelete (LPTSTR param) { /*cmd is the command that was given, in this case it will always be "del" or "delete" param is whatever is given after the command*/ LPTSTR *arg = NULL; INT args; INT i; INT nEvalArgs = 0; /* nunber of evaluated arguments */ DWORD dwFlags = 0; DWORD dwAttrFlags = 0; DWORD dwFiles = 0; LONG ch; TCHAR szOrginalArg[MAX_PATH]; /*checks the first two chars of param to see if it is /? this however allows the following command to not show help "del frog.txt /?" */ if (!StringsLoaded) { LoadStrings(); } if (!_tcsncmp (param, _T("/?"), 2)) { ConOutResPaging(TRUE,STRING_DEL_HELP1); return 0; } nErrorLevel = 0; arg = split (param, &args, FALSE); if (args == 0) { /* only command given */ error_req_param_missing (); freep (arg); return 1; } /* check for options anywhere in command line */ for (i = 0; i < args; i++) { if (*arg[i] == _T('/')) { /*found a command, but check to make sure it has something after it*/ if (_tcslen (arg[i]) >= 2) { ch = _totupper (arg[i][1]); if (ch == _T('N')) { dwFlags |= DEL_NOTHING; } else if (ch == _T('P')) { dwFlags |= DEL_PROMPT; } else if (ch == _T('Q')) { dwFlags |= DEL_QUIET; } else if (ch == _T('F')) { dwFlags |= DEL_FORCE; } else if (ch == _T('S')) { dwFlags |= DEL_SUBDIR; } else if (ch == _T('T')) { dwFlags |= DEL_TOTAL; } else if (ch == _T('W')) { dwFlags |= DEL_WIPE; } else if (ch == _T('Y')) { dwFlags |= DEL_YES; } else if (ch == _T('A')) { dwFlags |= DEL_ATTRIBUTES; /*the proper syntax for /A has a min of 4 chars i.e. /A:R or /A:-H */ if (_tcslen (arg[i]) < 4) { error_invalid_parameter_format(arg[i]); return 0; } ch = _totupper (arg[i][3]); if (_tcslen (arg[i]) == 4) { if(ch == _T('A')) { dwAttrFlags |= ATTR_ARCHIVE; } if(ch == _T('H')) { dwAttrFlags |= ATTR_HIDDEN; } if(ch == _T('S')) { dwAttrFlags |= ATTR_SYSTEM; } if(ch == _T('R')) { dwAttrFlags |= ATTR_READ_ONLY; } } if (_tcslen (arg[i]) == 5) { if(ch == _T('-')) { ch = _totupper (arg[i][4]); if(ch == _T('A')) { dwAttrFlags |= ATTR_N_ARCHIVE; } if(ch == _T('H')) { dwAttrFlags |= ATTR_N_HIDDEN; } if(ch == _T('S')) { dwAttrFlags |= ATTR_N_SYSTEM; } if(ch == _T('R')) { dwAttrFlags |= ATTR_N_READ_ONLY; } } } } } nEvalArgs++; } } /* there are only options on the command line --> error!!! there is the same number of args as there is flags, so none of the args were filenames*/ if (args == nEvalArgs) { error_req_param_missing (); freep (arg); return 1; } /* keep quiet within batch files */ if (bc != NULL) dwFlags |= DEL_QUIET; /* check for filenames anywhere in command line */ for (i = 0; i < args && !(dwFiles & 0x80000000); i++) { /*this checks to see if it isnt a flag, if it isnt, we assume it is a file name*/ if((*arg[i] == _T('/')) || (*arg[i] == _T('-'))) continue; /* We want to make a copies of the argument */ if(_tcslen(arg[i]) == 2 && arg[i][1] == _T(':')) { /* Check for C: D: ... */ GetRootPath(arg[i],szOrginalArg,MAX_PATH); } else { _tcscpy(szOrginalArg,arg[i]); } dwFiles += ProcessDirectory(szOrginalArg, &dwFlags, dwAttrFlags); } freep (arg); /*Based on MS cmd, we only tell what files are being deleted when /S is used */ if (dwFlags & DEL_TOTAL) { dwFiles &= 0x7fffffff; if (dwFiles < 2) { ConOutResPrintf(STRING_DEL_HELP3, dwFiles); } else { ConOutResPrintf(STRING_DEL_HELP4, dwFiles); } } return 0; }
// Like ReloadStrings, but clears all the strings before reloading void FStringTable::ResetStrings () { FreeData (); LoadStrings (LumpNum, -1, false); }
void FStringTable::ReloadStrings () { LoadStrings (LumpNum, -1, false); }
int main(int argc, char *argv[]){ /* * Here i need to get the TV resolution */ ecore_psl1ght_optimal_screen_resolution_get(&REAL_WIDTH, &REAL_HEIGHT); if(REAL_HEIGHT > 720){ REAL_WIDTH = 1280; REAL_HEIGHT = 720; } init_core(&core, REAL_WIDTH, REAL_HEIGHT, "Playstation Channel"); edje_start(); init_core_file(); Cursor_Y[0] = 0.25972*REAL_HEIGHT; Cursor_Y[1] = 0.5445 *REAL_HEIGHT; Cursor_X[0] = 0.1*REAL_WIDTH; // APPS (APP 1) || MEDIA (APP 4) Cursor_X[1] = 0.37421875*REAL_WIDTH; // BMANAGERS (APP 2) || RETRO (APP 5) Cursor_X[2] = 0.65*REAL_WIDTH; // GAMES (APP 3) || OPTIONS (APP 6) load_edj_from_file(&core, &info, PSC_INFO_SCREEN_PATH, "information", REAL_WIDTH, REAL_HEIGHT); load_edj_from_file(&core, &menu[0], PSC_OPTION_MENU_PATH, "menu", REAL_WIDTH, REAL_HEIGHT); //OPTIONS load_edj_from_file(&core, &menu[1], PSC_SUB_MENU_PATH, "menu", REAL_WIDTH, REAL_HEIGHT); //SUB MENU main_layer = evas_object_rectangle_add(get_main_object(&core)); evas_object_resize(main_layer, REAL_WIDTH, REAL_HEIGHT); evas_object_color_set(main_layer, 0, 0, 0, 0); evas_object_show(main_layer); ecore_evas_object_associate(core.ee_core, main_layer, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); override_text(&info, "information_download", " "); draw_edj(&info, 0, 0); //----------------------------------------------------------------------------------------------------- dir_make(CACHE_PATH); if(file_exist(CACHE_PATH"/files.zip")) file_delete(CACHE_PATH"/files.zip"); { char url[20]; sprintf(url,"%s",MAINURL); // if(!ecore_file_download(url,CACHE_PATH"/files.zip", download_main_is_finished, download_main_func, NULL, NULL)) download_file(url,CACHE_PATH"/files.zip", download_main_func_curl, download_main_is_finished); if(get_download_status()==DOWNLOAD_FAILED) goto end; } LoadStrings(PSC_MAIN_MENU_LANG_PATH, Categories_Names, 6); { string XML_files[5]; LoadMainStringsFromXML(CACHE_PATH"/files.xml",XML_files); for(int i=0;i<5;i++){ char tmp_char[250]; sprintf(tmp_char,"%s/%s",CACHE_PATH,XML_files[i].c_str()); LoadStringsFromXML(tmp_char,&Apps[i]); Applications[i].Image = new EFL_Image [Apps[i].n_elem]; Applications[i].x = new int [Apps[i].n_elem]; Applications[i].y = new int [Apps[i].n_elem]; for(int j=0, k=0, h=0;j<Apps[i].n_elem;j++,(k>1) ? h=!h : h=h,(k>1) ? k=0 : k++ ){ sprintf(tmp_char,"%s/%s",CACHE_PATH,Apps[i].img_file[j].c_str()); create_image_obj(&core, &Applications[i].Image[j], tmp_char, REAL_WIDTH*0.25, REAL_HEIGHT*0.246); Applications[i].x[j] = Cursor_X[k]; Applications[i].y[j] = Cursor_Y[h]; draw_image(&Applications[i].Image[j], Applications[i].x[j], Applications[i].y[j]); hide_obj(Applications[i].Image[j].obj); } } } //----------------------------------------------------------------------------------------------------- load_edj_from_file(&core, &menu[2], PSC_MAIN_MENU_PATH, "menu", REAL_WIDTH, REAL_HEIGHT); //MAIN MENU load_edj_from_file(&core, &bar, PSC_MAIN_MENU_BAR_PATH, "main_menu_bar", REAL_WIDTH*0.25, REAL_HEIGHT*0.246); //(Main/Sub) Menu bar load_edj_from_file(&core, &download, PSC_DOWNLOAD_MASK_PATH, "download_mask", REAL_WIDTH*0.3125, REAL_HEIGHT*0.3055); //DOWNLOAD MENU override_text(&menu[2], "error_text", ""); down = evas_object_rectangle_add(get_main_object(&core)); evas_object_move(down, (REAL_WIDTH-(REAL_WIDTH*0.3125))/2 +REAL_WIDTH*0.03125,REAL_HEIGHT*0.08861 +(REAL_HEIGHT-(REAL_HEIGHT*0.3055))/2); Bar_X_Val = REAL_WIDTH*0.25; Bar_Y_Val = REAL_HEIGHT*0.058; evas_object_resize(down, 1, Bar_Y_Val); evas_object_color_set(down, 0, 0, 255, 255); //blue hide_obj(down); load_edj_from_file(&core, &download_perc, PSC_DOWNLOADPERC_MASK_PATH, "download_perc", REAL_WIDTH*0.3125, REAL_HEIGHT*0.3055); //DOWNLOAD MENU load_edj_from_file(&core, &download_ask, PSC_DOWNLOAD_MASK_PATH, "download_mask_ask", REAL_WIDTH*0.3125, REAL_HEIGHT*0.3055); //DOWNLOAD MENU ASK XMB ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, on_exit_handler, NULL); information_timer = ecore_timer_add(PSC_INFO_SCREEN_TIMER, delete_info, NULL); enable_callback(&core, main_layer, EVAS_CALLBACK_KEY_DOWN , user_menu_handler); override_text(&menu[0], "ps3_version_edit", get_ps3_version()); char space [100]; if(get_ps3_free_space()>1000000000) sprintf(space,"%ld/%ld Gigabytes",get_ps3_free_space()/1000000000,get_ps3_total_space()/1000000000); else if(get_ps3_free_space()>1000000) sprintf(space,"%ld/%ld Megabytes",get_ps3_free_space()/1000000,get_ps3_total_space()/1000000); else if(get_ps3_free_space()>1000) sprintf(space,"%ld/%ld Kilobytes",get_ps3_free_space()/1000,get_ps3_total_space()/1000); else sprintf(space,"%ld/%ld Bytes",get_ps3_free_space(),get_ps3_total_space()); override_text(&menu[0], "ps3_hdd_free_space_edit", space); #ifdef PSCHANNEL_VERSION sprintf(space,"%f",PSCHANNEL_VERSION); override_text(&menu[0], "software_version", space); #else override_text(&menu[0], "software_version", " "); #endif if(sysModuleIsLoaded(SYSMODULE_NET)) override_text(&menu[2], "error_text", "SYSMODULE_NET NOT LOADED!!"); start_core_loop(); disable_callback(main_layer,EVAS_CALLBACK_KEY_DOWN, user_menu_handler); end: dir_recursive_delete(CACHE_PATH); for(int i=0;i<3;i++) delete_edj(&menu[i]); for(int i=0;i<5;i++) for(int j=0;j<Apps[i].n_elem;j++) delete_obj(Applications[i].Image[j].obj); delete_edj(&bar); delete_edj(&download); delete_edj(&download_perc); delete_obj(down); edje_stop(); stop_core_file(); ecore_psl1ght_shutdown(); // stop_core(&core); not needed on ps3. if(pkg_is_installed) reboot_sys(); return 0; }
INT CommandExpand (LPTSTR param) { /*cmd is the command that was given, in this case it will always be "expand" param is whatever is given after the command*/ LPTSTR *arg = NULL; INT args; INT i; INT nEvalArgs = 0; /* nunber of evaluated arguments */ DWORD dwFlags = 0; DWORD dwAttrFlags = 0; DWORD dwFiles = 0; LONG ch; TCHAR szOrginalArg[MAX_PATH]; /*checks the first two chars of param to see if it is /? this however allows the following command to not show help "expand frog.cab /?" */ if (!StringsLoaded) { LoadStrings(); } if (!_tcsncmp (param, _T("/?"), 2)) { //ConOutResPaging(TRUE,STRING_DEL_HELP1); return 0; } nErrorLevel = 0; arg = split (param, &args, FALSE); if (args == 0) { /* only command given */ error_req_param_missing (); freep (arg); return 1; } /* check for options anywhere in command line */ for (i = 0; i < args; i++) { if (*arg[i] == _T('-')) { /*found a command, but check to make sure it has something after it*/ if (_tcslen (arg[i]) >= 2) { ch = _totupper (arg[i][1]); if (ch == _T('R')) { dwFlags |= EXPAND_RENAME; } else if (ch == _T('D')) { dwFlags |= EXPAND_DISPLAY; } else if (ch == _T('F')) { dwFlags |= EXPAND_FILES; } else if (ch == _T('Y')) { dwFlags |= EXPAND_YES; } } nEvalArgs++; } } /* there are only options on the command line --> error!!! there is the same number of args as there is flags, so none of the args were filenames*/ if (args == nEvalArgs) { error_req_param_missing (); freep (arg); return 1; } /* check for filenames anywhere in command line */ for (i = 0; i < args && !(dwFiles & 0x80000000); i++) { /*this checks to see if it isnt a flag, if it isnt, we assume it is a file name*/ if((*arg[i] == _T('/')) || (*arg[i] == _T('-'))) continue; /* We want to make a copies of the argument */ freep (arg); /*Based on MS cmd, we only tell what files are being deleted when /S is used */ if (dwFlags & DEL_TOTAL) { dwFiles &= 0x7fffffff; if (dwFiles < 2) { ConOutResPrintf(STRING_DEL_HELP3, dwFiles); } else { ConOutResPrintf(STRING_DEL_HELP4, dwFiles); } } return 0; }
bool EngineApp::InitInstance( SDL_Window* window, int screenWidth, int screenHeight ) { /*auto test = std::vector< Vec2 >( { Vec2( 1.0f, 1.0f ), Vec2( 5.0f, 5.0f ), Vec2( 4.0f, 4.0f ), Vec2( 1.0f, -3.0f ) } );*/ //auto test = std::vector< Vec2 >( { Vec2( 0.0f, 2.0f ), Vec2( 1.0f, 4.0f ), Vec2( 2.0f, 0.0f ), Vec2( 3.0f, 1.0f ), Vec2( 4.0f, 3.0f ) } ); //Triangulation( test ); // Check for existing instance of the same window // Not sure if this feature is working normally.... #ifndef _DEBUG // Note - it can be really useful to debug network code to have // more than one instance of the game up at one time - so // feel free to comment these lines in or out as you wish! if (!IsOnlyInstance( VGetGameTitle() ) ) { return false; } #endif //--------------------------------- // Check system requirements //--------------------------------- bool resourceCheck = false; while (!resourceCheck) { const DWORDLONG physicalRAM = 512 * MEGABYTE; const DWORDLONG virtualRAM = 1024 * MEGABYTE; const DWORDLONG diskSpace = 10 * MEGABYTE; if ( !CheckStorage(diskSpace) ) { return false; } const DWORD minCpuSpeed = 1300; // 1.3Ghz DWORD thisCPU = ReadCPUSpeed(); if ( thisCPU < minCpuSpeed ) { ENG_ERROR("GetCPUSpeed reports CPU is too slow for this game."); return false; } resourceCheck = true; } //--------------------------------- // Check system requirements //--------------------------------- //--------------------------------- // Initialize ResCache, all assets are within a zip file //--------------------------------- IResourceFile *pFile = NULL; if( m_EngineOptions.GetIsUsingDevDirectory() ) { pFile = ENG_NEW DevResourceFile( DevResourceFile::Editor ); } else { pFile = ENG_NEW ResourceZipFile( L"Assets.zip" ); } m_pResCache = ENG_NEW ResourceCache( 50, pFile ); if ( !m_pResCache->Init() ) { ENG_ERROR("Failed to initialize resource cache! Are your paths set up correctly?"); return false; } // extern shared_ptr<IResourceLoader> CreateWAVResourceLoader(); m_pResCache->RegisterLoader< XmlResourceLoader >(); m_pResCache->RegisterLoader< MeshResourceLoader >(); m_pResCache->RegisterLoader< TextureResourceLoader >(); m_pResCache->RegisterLoader< ScriptResourceLoader >(); if( !LoadStrings("English") ) { ENG_ERROR("Failed to load strings"); return false; } //--------------------------------- // Initialize ResCache //--------------------------------- //--------------------------------- // Initialize Lua scripting //--------------------------------- // Rez up the Lua State manager now, and run the initial script - discussed in Chapter 5, page 144. if( !LuaStateManager::GetSingleton().VInit() ) { ENG_ERROR( "Failed to initialize Lua" ); return false; } ScriptExports::Register(); Resource resource( m_EngineOptions.GetPreInitScriptFile() ); shared_ptr<ResHandle> pResourceHandle = m_pResCache->GetHandle( resource ); ENG_ASSERT( pResourceHandle ); RegisterScriptClass< AnimationClipNode, IAnimationNode >(); RegisterScriptClass< AnimationLerpNode, IAnimationNode >(); RegisterScriptClass< AnimationState >(); //--------------------------------- // Initialize Lua scripting //--------------------------------- //--------------------------------- // Initialize EventManager //--------------------------------- // Set as global EventManager m_pEventManager = ENG_NEW EventManager( "Engine Event Manager", true ); if ( !m_pEventManager ) { ENG_ERROR( "Failed to create EventManager." ); return false; } //--------------------------------- // Initialize EventManager //--------------------------------- //--------------------------------- // Initiate window & SDL, glew //--------------------------------- if ( SDL_Init(SDL_INIT_EVERYTHING) != 0 ) { ENG_ERROR( SDL_GetError() ); return false; } CHAR charTitle[100]; if( GenericToAnsiCch( charTitle, VGetGameTitle(), strlen( charTitle ) ) != S_OK ) { ENG_ERROR( "Game title translation failed" ); } if( !window ) { m_pWindow = SDL_CreateWindow( charTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screenWidth,screenHeight, SDL_WINDOW_OPENGL ); if ( !m_pWindow ) { ENG_ERROR( SDL_GetError() ); return false; } } else { m_pWindow = window; } // Only if execute under editor can engine allow file drop if( m_EngineOptions.GetEngineEnvironment() == Environment_Editor ) { SDL_EventState( SDL_DROPFILE, SDL_ENABLE ); } if( m_EngineOptions.GetShowMouseCursor() ) { SDL_ShowCursor( SDL_ENABLE ); } else { SDL_ShowCursor( SDL_DISABLE ); } SDL_WarpMouseInWindow( g_pApp->GetWindow(), g_pApp->GetScreenSize().GetX() / 2, g_pApp->GetScreenSize().GetY() / 2 ); // setup opengl rendering context SDL_GLContext glContext = SDL_GL_CreateContext( m_pWindow ); if( !glContext ) { ENG_ERROR( SDL_GetError() ); } // Needed for core profile glewExperimental = true; GLenum error = glewInit(); if( error != GLEW_OK ) { ENG_ERROR( reinterpret_cast<const char *>( gluErrorString( error ) ) ); } // set two buffer for rendering SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); m_ShutDownEventType = RegisterEvent( 1 ); //--------------------------------- // Initiate window & SDL, glew //--------------------------------- //--------------------------------- // SDL_Image //--------------------------------- int initFlags= IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_TIF; int initted = IMG_Init( initFlags ); if( ( initted & initFlags ) != initFlags ) { ENG_ERROR( IMG_GetError() ); } //--------------------------------- // SDL_Image //--------------------------------- //--------------------------------- // Set Renderer //--------------------------------- if( GetRendererImpl() == Renderer_OpenGL ) { m_pRenderer = shared_ptr<IRenderer>( ENG_NEW OpenGLRenderer() ); } else { ENG_ERROR( "Not supported renderer type" ); } m_pRenderer->VSetBackgroundColor( g_Black ); // Enable depth test glEnable( GL_DEPTH_TEST ); // Accept fragment if it closer to the camera than the former one glDepthFunc( GL_LESS ); // Cull triangles which normal is not towards the camera glEnable( GL_CULL_FACE ); m_pRenderer->VOnRestore(); //--------------------------------- // Set Renderer //--------------------------------- // Start global timer GetGlobalTimer()->Reset(); // initialize the directory location you can store save game files _tcscpy_s( m_saveGameDirectory, GetSaveGameDirectory( GetHwnd(), VGetGameAppDirectory() ) ); //--------------------------------- // Create game & view //--------------------------------- m_pEngineLogic = VCreateLogic(); if (!m_pEngineLogic) { return false; } //--------------------------------- // Create game & view //--------------------------------- m_bIsRunning = true; return true; }
void language::load(const string& Path, const string& Language, int CountNeed) { SCOPED_ACTION(GuardLastError); auto Data = m_Data->create(); const auto LangFileData = OpenLangFile(Path, LangFileMask, Language); const auto& LangFile = std::get<0>(LangFileData); const auto LangFileCodePage = std::get<2>(LangFileData); if (!LangFile) { throw MAKE_EXCEPTION(exception, L"Cannot find language data"sv); } Data->m_FileName = LangFile.GetName(); if (CountNeed != -1) { Data->reserve(CountNeed); } std::unordered_map<string, size_t> id_map; string label, text; for (const auto& i: enum_file_lines(LangFile, LangFileCodePage)) { bool have_text; parse_lng_line(trim(i.Str), label, text, have_text); if (have_text) { auto idx = Data->size(); Data->add(ConvertString(text)); if (!label.empty()) { id_map[label] = idx; label.clear(); } } } // Проведем проверку на количество строк в LNG-файлах if (CountNeed != -1 && CountNeed != static_cast<int>(Data->size())) { throw MAKE_EXCEPTION(exception, Data->m_FileName + L": language data is incorrect or damaged"sv); } // try to load Far<LNG>.lng.custom file(s) // if (!id_map.empty()) { const auto& LoadStrings = [&](const string& FileName) { const os::fs::file CustomFile(FileName, FILE_READ_DATA, FILE_SHARE_READ, nullptr, OPEN_EXISTING); if (!CustomFile) return; const auto CustomFileCodepage = GetFileCodepage(CustomFile, encoding::codepage::oem(), nullptr, false); label.clear(); for (const auto& i: enum_file_lines(CustomFile, CustomFileCodepage)) { bool have_text; parse_lng_line(trim(i.Str), label, text, have_text); if (have_text && !label.empty()) { const auto found = id_map.find(label); if (found != id_map.end()) { Data->set_at(found->second, ConvertString(text)); } label.clear(); } } }; const auto CustomLngInSameDir = Data->m_FileName + L".custom"sv; const auto CustomLngInProfileDir = concat(Global->Opt->ProfilePath, L'\\', ExtractFileName(CustomLngInSameDir)); LoadStrings(CustomLngInSameDir); LoadStrings(CustomLngInProfileDir); } m_Data = std::move(Data); }