public Warning ( String message ) : void | ||
message | String | The message to explain the warning |
return | void |
// Replacement for individual raf reading and individual filetype searching // Provide the directory of RADS\projects\lol_game_client\filearchives or the equivalent private bool ReadRAFs(DirectoryInfo dir, Logger logger) { try { RAFMasterFileList rafFiles = new RAFMasterFileList(dir.FullName); logger.Event("Opening the 'filearchives' directory: " + dir.FullName); foreach (RAFMasterFileList.RAFSearchResult result in rafFiles.SearchFileEntries(new string[] { ".dds", ".skn", ".skl", ".inibin", "animations.list", ".anm" }, RAFMasterFileList.RAFSearchType.All)) { RAFFileListEntry e = result.value; // Split off the actual file name from the full path String name = e.FileName.Substring(e.FileName.LastIndexOf('/') + 1).ToLower(); switch (result.searchPhrase) { case ".dds": // Try to parse out unwanted textures. if (!e.FileName.ToLower().Contains("loadscreen") && !e.FileName.ToLower().Contains("circle") && !e.FileName.ToLower().Contains("square") && e.FileName.ToLower().Contains("data") && e.FileName.ToLower().Contains("characters")) { // Check that the file isn't already in the dictionary if (!textures.ContainsKey(name)) { textures.Add(name, e); } else { logger.Warning("Duplicate texture " + name + ": " + e.FileName); } } break; case ".skn": if (!skns.ContainsKey(name)) { skns.Add(name, e); } else { logger.Warning("Duplicate skn " + name + ": " + e.FileName); } break; case ".skl": if (!skls.ContainsKey(name)) { skls.Add(name, e); } else { logger.Warning("Duplicate skn " + name + ": " + e.FileName); } break; case ".inibin": // Try to only read champion inibins if (e.FileName.ToLower().Contains("data") && e.FileName.ToLower().Contains("characters")) { inibins.Add(e); } else { logger.Warning("Excluding inibin " + name + ": " + e.FileName); } break; case "animations.list": // Riot changed their directory structure for some skins. // Originally, champion Animation.list files were stored in a directory structure like // "*/ChampionName/Animation.list". Now, some are stored like // "*/ChampionName/Skins/Skin01/Animation.list". if (e.FileName.ToLower().Contains("skin") == false && e.FileName.ToLower().Contains("base") == false) { // Original Case. // Remove the file name. name = e.FileName.Remove(e.FileName.LastIndexOf('/')); // Remove proceeding directories to get the parent directory name = name.Substring(name.LastIndexOf('/') + 1).ToLower(); } else { // Newer Case. string path = e.FileName.ToString(); string[] splitPath = path.Split('/'); // Sanity if (splitPath.Length > 3) { name = splitPath[splitPath.Length - 4].ToLower(); } } // Store. if (!animationLists.ContainsKey(name)) { animationLists.Add(name, e); } else { logger.Warning("Duplicate animation list " + name + ": " + e.FileName); } break; case ".anm": // Remove the .anm extension. name = name.Remove(name.Length - 4); if (!animations.ContainsKey(name)) { animations.Add(name, e); } else { logger.Warning("Duplicate anm " + name + ": " + e.FileName); } break; } } } catch (Exception e) { // Something went wrong. Most likely the RAF read failed due to a bad directory. logger.Error("Failed to open RAFs"); logger.Error(e.Message); return false; } return true; }
public MainWindow() { logger = new Logger(DEFAULT_LOG_FILE); // Not checking result. logger.Event("Program Start."); isGLLoaded = false; timer = new Stopwatch(); camera = new GLCamera(); camera.SetViewParameters(new Vector3(0.0f, 0.0f, 2.0f), Vector3.Zero); renderer = new GLRenderer(); // Set up the reader and initialize its root to the value in 'lolviewer.dat' if // the file exists. { reader = new LOLDirectoryReader(); bool isFileOpen = false; FileStream file = null; try { FileInfo fileInfo = new FileInfo(DEFAULT_DATA_FILE); if (fileInfo.Exists == true) { file = new FileStream(fileInfo.FullName, FileMode.Open); isFileOpen = true; } else { logger.Warning("Failed to locate " + DEFAULT_DATA_FILE + "."); } } catch { logger.Warning("Failed to open " + DEFAULT_DATA_FILE + "."); } if (isFileOpen == true) { BinaryReader fileReader = null; if (file != null) { try { logger.Event("Reading " + DEFAULT_DATA_FILE + "."); fileReader = new BinaryReader(file); reader.Root = fileReader.ReadString(); fileReader.Close(); } catch { logger.Warning("Failed to read " + DEFAULT_DATA_FILE + "."); file.Close(); } } } } InitializeComponent(); mainWindowProgressBar.Style = ProgressBarStyle.Marquee; mainWindowProgressBar.Value = 100; lastSearch = String.Empty; currentSearchSubset = new List<String>(); // Main window Callbacks this.Shown += new EventHandler(OnMainWindowShown); // GLControl Callbacks glControlMain.Load += new EventHandler(GLControlMainOnLoad); glControlMain.Resize += new EventHandler(GLControlMainOnResize); glControlMain.Paint += new PaintEventHandler(GLControlMainOnPaint); glControlMain.Disposed += new EventHandler(GLControlMainOnDispose); // Set mouse events glControlMain.MouseDown += new MouseEventHandler(GLControlOnMouseDown); glControlMain.MouseUp += new MouseEventHandler(GLControlOnMouseUp); glControlMain.MouseWheel += new MouseEventHandler(GLControlOnMouseWheel); glControlMain.MouseMove += new MouseEventHandler(GLControlOnMouseMove); // Set keyboard events glControlMain.KeyDown += new KeyEventHandler(GLControlMainOnKeyDown); glControlMain.KeyUp += new KeyEventHandler(GLControlMainOnKeyUp); // Menu Callbacks exitToolStripMenuItem.Click += new EventHandler(OnExit); aboutToolStripMenuItem.Click += new EventHandler(OnAbout); readDirectoryMainMenuStripItem.Click += new EventHandler(OnReadModels); readMainMenuStripItem.Click += new EventHandler(OnSetDirectory); // Model View Callbacks modelListBox.DoubleClick += new EventHandler(OnModelListDoubleClick); modelListBox.KeyPress += new KeyPressEventHandler(OnModelListKeyPress); // Buttons resetCameraButton.Click += new EventHandler(OnResetCameraButtonClick); backgroundColorButton.Click += new EventHandler(OnBackgroundColorButtonClick); fullscreenButton.Click += new EventHandler(OnFullscreenButtonClick); // // Animation Controller // // TODO: Pass the references and callbacks into constructor instead of doing them out here. // Kind of ugly code. :( animationController = new AnimationController(); // Set references animationController.enableAnimationButton = enableAnimationButton; animationController.currentAnimationComboBox = currentAnimationComboBox; animationController.playAnimationButton = playAnimationButton; animationController.glControlMain = glControlMain; animationController.timelineTrackBar = timelineTrackBar; animationController.mainWindowStatusLabel = mainWindowStatusLabel; animationController.renderer = renderer; // Set callbacks. enableAnimationButton.Click += new EventHandler(animationController.OnEnableAnimationButtonClick); playAnimationButton.Click += new EventHandler(animationController.OnPlayAnimationButtonClick); currentAnimationComboBox.SelectedIndexChanged += new EventHandler(animationController.OnCurrentAnimationComboBoxSelectedIndexChanged); timelineTrackBar.Scroll += new EventHandler(animationController.OnTimelineTrackBar); animationController.DisableAnimation(); // // End Animation Controller // // Search Box modelSearchBox.TextChanged += new EventHandler(OnModelSearchBoxTextChanged); modelSearchBox.KeyPress += new KeyPressEventHandler(OnModelSearchBoxKeyPress); modelSearchBox.KeyDown += new KeyEventHandler(OnModelSearchBoxKeyDown); }
private void GenerateModelDefinitions(Logger logger) { foreach (RAFFileListEntry f in inibins) { InibinFile iniFile = new InibinFile(); bool readResult = InibinReader.Read(f, ref iniFile, logger); if (readResult == true) { // Add the models from this .inibin file List<ModelDefinition> modelDefs = iniFile.GetModelStrings(); for (int j = 0; j < modelDefs.Count; ++j) { // Name the model after the parent directory // of the .inibin plus the name from the .inibin. // Some things overlap without both. string path = f.FileName; string[] splitPath = path.Split('/'); string directoryName = splitPath[splitPath.Length - 2]; if (directoryName.Contains("Base") == true || directoryName.Contains("Skin") == true) { // The directory structure for this case will be something like // "*/ChampionName/Skins/Base/". // We just want the "ChampionName". directoryName = splitPath[splitPath.Length - 4]; } // Sometimes the name from the .inibin file is "". // So, just name it after the directory String name = modelDefs[j].name; if (name == "") { name = directoryName + "/" + directoryName; } else { name = directoryName + "/" + name; } try { LOLModel model; bool storeResult = StoreModel(modelDefs[j], out model, logger); if (storeResult == true) { // Try to store animations for model as well storeResult = StoreAnimations(ref model, logger); } if (storeResult == true) { if (models.ContainsKey(name) == false) { logger.Event("Adding model definition: " + name); models.Add(name, model); } else { logger.Warning("Duplicate model definition: " + name); } } } catch (Exception e) { logger.Error("Unable to store model definition: " + name); logger.Error(e.Message); } } } } }