AzerEnergoAtom Дата: Среда, 15.12.10, 20:36 | Сообщение # 1
[ Администратор ]
Сообщений: 475
Зарегистрирован: 28.12.08
Пользователь #: 119
Модуль главного окна и сердце программы (без заголовочного файла).
Code
//--------------------------------------------------------------------------- // MainForm //--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) { // Defining PRM paths // GlPRMPath contains a basic independed data, that can`t be defined from PRM`s configuration. GlPRMPath = ExtractFilePath(Application->ExeName); // Don`t use GetCurrentDir() cause this function returns System CurrentDir value (environment variable)! // Other PRM`s paths GlPRMCFGPath = GlPRMPath + "cfg\\"; GlPRMCrashRepPath = GlPRMPath + "crashreports\\"; GlPRMCursorsPath = GlPRMPath + "cur\\"; GlPRMHelpPath = GlPRMPath + "help\\"; GlPRMIconsPath = GlPRMPath + "ico\\"; GlPRMTrayAnimIconPath = GlPRMIconsPath + "tray\\"; // Same as 'GlPRMPath + "ico\\tray\\";' GlPRMImgPath = GlPRMPath + "img\\"; GlPRMImgBtnPath = GlPRMImgPath + "btn\\"; // Same as 'GlPRMPath + "img\\btn\\";' GlPRMImgRatingPath = GlPRMImgPath + "rating\\"; // Same as 'GlPRMPath + "img\\rating\\";' GlPRMLangPath = GlPRMPath + "lang\\"; GlPRMMusicPath = GlPRMPath + "music\\"; GlPRMHWMusicPath = GlPRMMusicPath + "hw\\"; // Same as 'GlPRMPath + "music\\hw\\";' GlPRMRepPath = GlPRMPath + "reports\\"; GlPRMSoundsPath = GlPRMPath + "sounds\\"; GlPRMUpdatesPath = GlPRMPath + "updates\\"; // Other constants of PRM`s paths and files (filenames) GlReportFile = GlPRMRepPath + FormatDateTime("yyyy-mm-dd_hh-nn-ss_", Now()) + ChangeFileExt(ExtractFileName(Application->ExeName), "") + "_prm1.n++"; // Full filename of report file for current program run. GlUpdateHistoryFile = GlPRMUpdatesPath + "history.uhf"; // Loading data from configuration files // Prefixes for configuration variables are composed from upper case letters from the configuration`s names of sections by default. // Initialization 1, File: mainsetts.ini (Main settings) TIniFile *mainsetts; mainsetts = new TIniFile(GlPRMPath + "mainsetts.ini"); // [External] CFG_PRM1Filename = mainsetts->ReadString("External", "PRM1Filename", "prm1.exe"); // PRM1Filename CFG_PRM1Starter = mainsetts->ReadString("External", "PRM1Starter", "prm1starter1.exe"); // PRM1Starter CFG_PRM1StarterBakup = mainsetts->ReadString("External", "PRM1StarterBakup", "bprms.store"); // PRM1StarterBakup CFG_PRM1Path = mainsetts->ReadString("External", "PRM1Path", "*") + "\\"; // PRM1Path CFG_PRoutePath = mainsetts->ReadString("External", "PRoutePath", "*"); // PRoutePath CFG_PRM1LangFile = mainsetts->ReadString("External", "PRM1LangFile", "eng.lng"); // PRM1LangFile CFG_PRM1GUICfgMainFile = mainsetts->ReadString("External", "PRM1GUICfgMainFile", "guicfg") + ".ini"; //PRM1GUICfgMainFile CFG_PRM1StdColor = mainsetts->ReadString("External", "PRM1StdColor", "$00FFFFFF"); // PRM1StdColor // [Info] CFG_PRouteDirName = mainsetts->ReadString("Info", "PRouteDirName", "*"); // PRouteDirName CFG_PRouteID = mainsetts->ReadString("Info", "PRouteID", "*"); // PRouteID CFG_PRouteName = mainsetts->ReadString("Info", "PRouteName", "*"); // PRouteName CFG_PRouteDescription = mainsetts->ReadString("Info", "PRouteDescription", "*"); // PRouteDescription CFG_PRouteFilename = mainsetts->ReadString("Info", "PRouteFilename", "*"); // PRouteFilename CFG_PRouteElectrified = mainsetts->ReadString("Info", "PRouteElectrified", "*"); // PRouteElectrified CFG_PRouteDMountains = mainsetts->ReadString("Info", "PRouteDMountains", "*"); // PRouteDMountains CFG_PRouteSpeedLimit = mainsetts->ReadString("Info", "PRouteSpeedLimit", "*"); // PRouteSpeedLimit CFG_PRouteRestrictedSpeedLimit = mainsetts->ReadString("Info", "PRouteRestrictedSpeedLimit", "*"); // PRouteRestrictedSpeedLimit CFG_PRouteVoltage = mainsetts->ReadString("Info", "PRouteVoltage", "*"); // PRouteVoltage CFG_PRouteVersion = mainsetts->ReadString("Info", "PRouteVersion", "*"); // PRouteVersion CFG_PRouteType = mainsetts->ReadString("Info", "PRouteType", "*"); // PRouteType CFG_PRouteLength = mainsetts->ReadString("Info", "PRouteLength", "*"); // PRouteLength CFG_PRouteFullLenght = mainsetts->ReadString("Info", "PRouteFullLenght", "*"); // PRouteFullLenght CFG_PRouteTrackLength = mainsetts->ReadString("Info", "PRouteTrackLength", "*"); // PRouteTrackLength CFG_PRouteSeasonsAvailable = mainsetts->ReadString("Info", "PRouteSeasonsAvailable", "*"); // PRouteSeasonsAvailable CFG_PRouteDeveloper = mainsetts->ReadString("Info", "PRouteDeveloper", "Unknown"); // PRouteDeveloper CFG_PRouteBuildDay = mainsetts->ReadString("Info", "PRouteBuildDay", "*"); // PRouteBuildDay CFG_PRouteBuildMonth = mainsetts->ReadString("Info", "PRouteBuildMonth", "*"); // PRouteBuildMonth CFG_PRouteBuildYear = mainsetts->ReadString("Info", "PRouteBuildYear", "*"); // PRouteBuildYear CFG_PRoutePublisher = mainsetts->ReadString("Info", "PRoutePublisher", "*"); // PRoutePublisher CFG_PRouteWebSite = mainsetts->ReadString("Info", "PRouteWebSite", "*"); // PRouteWebSite CFG_PRouteDownloadableLink = mainsetts->ReadString("Info", "PRouteDownloadableLink", "*"); // PRouteDownloadableLink CFG_PRouteCopyright = mainsetts->ReadString("Info", "PRouteCopyright", "*"); // PRouteCopyright CFG_PRouteRFCFTS2Rating = mainsetts->ReadInteger("Info", "PRouteRFCFTS2Rating", 0); // PRouteRFCFTS2Rating CFG_PStructName = mainsetts->ReadString("Info", "PStructName", "*"); // PStructName CFG_PStructVersion = mainsetts->ReadString("Info", "PStructVersion", "*"); // PStructVersion CFG_PStructDeveloper = mainsetts->ReadString("Info", "PStructDeveloper", "*"); // PStructDeveloper CFG_PStructDate = mainsetts->ReadString("Info", "PStructDate", "*"); // PStructDate CFG_PStructCopyright = mainsetts->ReadString("Info", "PStructCopyright", "*"); // PStructCopyright CFG_PStructWebSite = mainsetts->ReadString("Info", "PStructWebSite", "*"); // PStructWebSite CFG_PStructUpdateLink = mainsetts->ReadString("Info", "PStructUpdateLink", "*"); // PStructUpdateLink // [PRMConfiguration] // ........................ delete mainsetts; // ...................... // Незавершенная область // GlPRMImgRatingPath // Checking PRM`s path defined in External->PRM1Path if(GlPRMPath!=CFG_PRM1Path && CFG_PRM1Path!="*" && CFG_PRM1Path!="") // Comparing GlPRMPath value with PRM`s path defined by PStruct developer (or Installation program). { // Also remember that this code defining PRM`s path for program configuration, so PStruct developer may leave External->PRoutePath property void (or use "*" in value). mainsetts->WriteString("External", "PRM1Path", GlPRMPath); } // Defining route paths GlPRPath = ExtractFileDir(GlPRMPath) + "\\"; GlPRWorldPath = GlPRPath + "WORLD\\"; GlPRActsPath = GlPRPath + "ACTIVITIES\\"; GlPREnvPath = GlPRPath + "ENVFILES\\"; GlPREnvTexPath = GlPRPath + "ENVFILES\\TEXTURES\\"; GlPRShapesPath = GlPRPath + "SHAPES\\"; GlPRSoundsPath = GlPRPath + "SOUNDS\\"; GlPRWorldPath = GlPRPath + "WORLD\\"; GlPRTerrTexPath = GlPRPath + "TERRTEX\\"; GlPRTerrTexSnowPath = GlPRPath + "TERRTEX\\SNOW\\"; GlPRTexturesPath = GlPRPath + "TEXTURES\\"; GlPRTexturesAutPath = GlPRPath + "TEXTURES\\AUTUMN\\"; GlPRTexturesAutSnowPath = GlPRPath + "TEXTURES\\AUTUMNSNOW\\"; GlPRTexturesNightPath = GlPRPath + "TEXTURES\\NIGHT\\"; GlPRTexturesSnowPath = GlPRPath + "TEXTURES\\SNOW\\"; GlPRTexturesSprPath = GlPRPath + "TEXTURES\\SPRING\\"; GlPRTexturesSprSnowPath = GlPRPath + "TEXTURES\\SPRINGSNOW\\"; GlPRTexturesWinPath = GlPRPath + "TEXTURES\\WINTER\\"; GlPRTexturesWinSnowPath = GlPRPath + "TEXTURES\\WINTERSNOW\\"; GlPRTilesPath = GlPRPath + "TILES\\"; // Global constant values from configuration files // GlPRM1StdColor <mainsetts.ini> // Global error indicators (variables) GlFColorCorrectorErr = false; // Create ReportFile and write first entries... FILE *ReportFile = fopen(GlReportFile, "at"); // Creating ReportFile... // Writing first entries into ReportFile. fprintf(ReportFile, FWriteEntry("PRM1 started.")); fprintf(ReportFile, FWriteEntry("Started Reporting.")); fprintf(ReportFile, FWriteEntry("File: " + GlReportFile + ".")); fprintf(ReportFile, FWriteEntry("Starting PRM1...")); fclose(ReportFile); // Closing the stream } //--------------------------------------------------------------------------- void __fastcall TMainForm::ExitSpeedButtonClick(TObject *Sender) { FExitPRM(0); } //---------------------------------------------------------------------------
Грубо говоря середина этого сообщения - это программные инструкции по загрузке настроек из файлов конфигурации. Полный текст в прикрепленном файле, открывать любым текстовым редактором.
_______________________You're never really done for, as long as you've got a good story and someone to tell it to. My ASRailRoad is my story...
Offline