public override void OnDataCellChanged(DataColumnChangeEventArgs e) { // grab col and change the image RecipeRow row = (RecipeRow)e.Row; string newName = e.ProposedValue == DBNull.Value || e.ProposedValue == null ? "" : (string)e.ProposedValue; Ingredient ingredient = row.GetOrAddIngredient(this.columnGroup); if (IsMaterial(newName)) { ingredient.Icon = recipesView.GetIcon(newName); } else { JsonFileData jsonFileData = (JsonFileData)ModuleDataManager.GetInstance().GetModuleFile(newName).FileData; ingredient.Icon = recipesView.GetIcon(jsonFileData); } if (newName == "") { ingredient.Amount = null; } else if (ingredient.Amount == null) { ingredient.Amount = 1; } }
private List <string> GetAutoCompleteStrings(string colName) { List <string> strings = new List <string>(); if (colName.StartsWith(IngredientColumnGroup.kIngr) && colName.EndsWith(IngredientColumnGroup.kName)) { strings.Add(""); // Add materials strings.AddRange(mMaterialImages.Keys); ModuleDataManager mdm = ModuleDataManager.GetInstance(); Dictionary <string, JsonFileData> itemJsons = mdm.GetJsonsByTerm("entity_data.stonehearth:net_worth"); foreach (KeyValuePair <string, JsonFileData> kv in itemJsons) { string modName = mdm.GetModNameFromAlias(kv.Key); bool shouldIncludeMod = mBaseModsOnly ? (modName == "stonehearth" || modName == "rayyas_children" || modName == "northern_alliance") : true; if (shouldIncludeMod) { strings.Add(kv.Key); } } } return(strings); }
public override void SaveCell(HashSet <JsonFileData> modifiedFiles, RecipeRow row, object value) { JsonFileData jsonFileData = row.Item; foreach (JsonFileData file in jsonFileData.OpenedFiles) { JObject json = file.Json; JValue nameToken = json.SelectToken("entity_data.stonehearth:catalog.display_name") as JValue; if (nameToken != null) { string locKey = nameToken.Value.ToString(); if (!locKey.Contains(":")) { nameToken.Value = (string)value; modifiedFiles.Add(jsonFileData); } else { int i18nLength = "i18n(".Length; locKey = locKey.Substring(i18nLength, locKey.Length - i18nLength - 1); ModuleDataManager.GetInstance().ChangeEnglishLocValue(locKey, (string)value); } } } }
// Load the material constants from the stonehearth mod. This needs to be done before the data columns // are populated,since they use this map to fill in data grid for material ingredients private void LoadMaterialImages() { Module sh = ModuleDataManager.GetInstance().GetMod("stonehearth"); if (sh != null) { ModuleFile resourceConstants = sh.GetAliasFile("data:resource_constants"); if (resourceConstants != null) { JsonFileData jsonFileData = resourceConstants.FileData as JsonFileData; JObject resourceConstantsJson = jsonFileData.Json; JObject resourceJson = resourceConstantsJson["resources"] as JObject; foreach (JProperty resource in resourceJson.Properties()) { string name = resource.Name; string iconLocation = resource.Value["icon"].ToString(); string path = JsonHelper.GetFileFromFileJson(iconLocation, jsonFileData.Directory); if (path != "" && System.IO.File.Exists(path)) { mMaterialImages.Add(name, path); } } } } }
public GetAllModulesResponse Get(GetAllModulesRequest request) { GetAllModulesResponse response = new GetAllModulesResponse(); try { //Get the UserId from the Header and update the request object //request.UserId = HttpContext.Current.Request.Headers.Get(_phytelUserIDToken); if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("ModuleDD:Get()::Unauthorized Access"); } response = ModuleDataManager.GetModuleList(request); response.Version = request.Version; } catch (Exception ex) { CommonFormatter.FormatExceptionResponse(response, base.Response, ex); string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Common.Helper.LogException(int.Parse(aseProcessID), ex); } return(response); }
public void GetModuleByID() { GetModuleRequest request = new GetModuleRequest { ModuleID = "5" }; GetModuleResponse response = ModuleDataManager.GetModuleByID(request); Assert.IsTrue(response.Module.Id == "Tony"); }
private string GetTranslatedName(string locKey) { if (locKey.Contains("i18n")) { return(ModuleDataManager.GetInstance().LocalizeString(locKey)); } else { return(locKey); } }
private void LoadIconics() { Dictionary <string, JsonFileData> iconicJsonFiles = ModuleDataManager.GetInstance().GetIconicJsons(mBaseModsOnly); foreach (KeyValuePair <string, JsonFileData> entry in iconicJsonFiles) { RecipeRow row = mDataTable.NewRecipeRow(); SetRowDataForItem(row, entry.Key, entry.Value); mDataTable.Rows.Add(row); } }
private void LoadEntities() { Dictionary <string, JsonFileData> entityJsonFiles = ModuleDataManager.GetInstance().GetJsonsOfType(JSONTYPE.ENTITY, mBaseModsOnly) .Where(kvp => kvp.Value.Json.SelectToken("components.stonehearth:ai") == null) .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); foreach (KeyValuePair <string, JsonFileData> entry in entityJsonFiles) { RecipeRow row = mDataTable.NewRecipeRow(); SetRowDataForItem(row, entry.Key, entry.Value); mDataTable.Rows.Add(row); } }
private void LoadAllRecipes() { foreach (Module module in ModuleDataManager.GetInstance().GetAllModules()) { bool shouldIncludeMod = mBaseModsOnly ? ModuleDataManager.IsBaseMod(module.Name) : true; if (shouldIncludeMod) { ModuleFile jobsIndex = module.GetAliasFile("jobs:index"); if (jobsIndex != null) { JObject jobIndexJson = (jobsIndex.FileData as JsonFileData).Json; JObject jobs = jobIndexJson["jobs"] as JObject; foreach (JProperty job in jobs.Properties()) { string jobAlias = job.Value["description"].ToString(); LoadRecipesForJob(jobAlias); } } } } }
public GetModuleResponse Get(GetModuleRequest request) { GetModuleResponse response = new GetModuleResponse(); try { if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("ModuleDD:Get()::Unauthorized Access"); } response = ModuleDataManager.GetModuleByID(request); response.Version = request.Version; } catch (Exception ex) { CommonFormatter.FormatExceptionResponse(response, base.Response, ex); string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Common.Helper.LogException(int.Parse(aseProcessID), ex); } return(response); }
private void LoadRecipesForJob(string jobAlias) { string modName = jobAlias.Split(':')[0]; int index = jobAlias.IndexOf(':'); string jobKey = jobAlias.Substring(index + 1); char sep = System.IO.Path.DirectorySeparatorChar; string recipeFileDataKey = modName + sep + "aliases" + sep + jobKey + sep + "recipes"; JsonFileData recipesIndex = ModuleDataManager.GetInstance().GetSelectedFileData(recipeFileDataKey) as JsonFileData; // Non-crafter jobs will not have recipes if (recipesIndex == null) { return; } Dictionary <string, FileData> recipeFileData = recipesIndex.LinkedFileData; foreach (KeyValuePair <string, FileData> recipe in recipeFileData) { JsonFileData jsonFileData = recipe.Value as JsonFileData; JObject recipeJson = jsonFileData.Json; JArray ingredientArray = recipeJson["ingredients"] as JArray; JArray productArray = recipeJson["produces"] as JArray; foreach (JToken product in productArray) { RecipeRow row = mDataTable.NewRecipeRow(); row.RecipeList = recipesIndex; row.Recipe = jsonFileData; JToken lvlReq = recipeJson["level_requirement"]; JToken effort = recipeJson["effort"]; JToken workUnits = recipeJson["work_units"]; JToken appeal = recipeJson.SelectToken("entity_data.stonehearth:appeal.appeal"); row.SetLevelRequired(lvlReq == null ? null : lvlReq.ToObject <int?>()); row.SetEffort(effort == null ? null : effort.ToObject <int?>()); row.SetWorkUnits(workUnits == null ? null : workUnits.ToObject <int?>()); row.SetCrafter(jobAlias); JToken item = product["item"]; if (item != null) { string alias = item.ToString(); // Check aliases linked by recipe file JsonFileData itemFileData = FindLinkedJsonMatchingAlias(jsonFileData, alias) ?? jsonFileData; SetRowDataForItem(row, alias, itemFileData); } foreach (JToken ingredient in ingredientArray) { JToken uri = ingredient["uri"]; JToken material = ingredient["material"]; JToken count = ingredient["count"]; Ingredient ingredientData = row.AddNewIngredient(); ingredientData.Amount = count.ToObject <int>(); if (material != null) { ingredientData.Name = material.ToString(); } else if (uri != null) { JsonFileData ingrJsonFileData = FindLinkedJsonMatchingAlias(jsonFileData, uri.ToString()); if (ingrJsonFileData == null) { MessageBox.Show("Could not find ingredient \"" + uri + "\" in the manifest for recipe \"" + jsonFileData.FileName + "\""); continue; } ingredientData.Name = ingrJsonFileData.GetModuleFile().FullAlias; } else { throw new Exception("Recipe " + jsonFileData.GetModuleFile().FullAlias + " has invalid ingredient with no uri/material field"); } } mDataTable.Rows.Add(row); } } }
protected override DataTable GetData() { var dt = ModuleDataManager.Search(oSearchFilter.SearchParameters, SessionVariables.RequestProfile); return(dt); }