private void Raise_CraftAdded(ModCraft thecraft) { if (this.CraftAdded != null) { this.CraftAdded(this, new ModCraftEventArgs(thecraft)); } }
private void LockButton_Click(object sender, RoutedEventArgs e) { ModCraft m = (ModCraft)((Button)sender).Tag; m.IsLocked = !m.IsLocked; ((Image)((Button)sender).Content).Source = m.IsLocked ? Icons.Lock : Icons.Unlock; ((Button)sender).Background = m.IsLocked ? Brushes.Red : Brushes.Green; ItemEdited?.Invoke(this, EventArgs.Empty); }
//accurate when called from a mod's ToString(), but repeating lots of live translations is slow public static string TranslateModCraft(ModCraft mod, int modquality) { IList <ModRoll> statscopy = new List <ModRoll>(mod.Stats); IList <string> lines = new List <string>(); while (statscopy.Count > 0) { string id = statscopy[0].ID; if (!Data.ContainsKey(id)) { Debug.WriteLine("skipping stat translation for " + id); statscopy.RemoveAt(0); continue; } StatLocalization chunk = Data[id]; IList <int> rolls = new List <int>(); for (int i = 0; i < chunk.ids.Count; i++) //copy out roll and remove handled stats from statcopy { int found = -1; for (int j = 0; j < statscopy.Count; j++) { if (statscopy[j].ID == chunk.ids[i]) { found = j; rolls.Add(statscopy[j].Roll * (100 + modquality) / 100); break; } } if (found < 0) { rolls.Add(0); } else { statscopy.RemoveAt(found); } } if (chunk.hidden) { continue; } LocalizationDefinition def = null; foreach (LocalizationDefinition d in chunk.definitions) //find matching definition { if (MeetsCondition(rolls, d.condition)) { def = d; break; } } string linetext = BuildText(def.text, rolls, def.format, def.index_handlers); lines.Add(linetext); } return(string.Join("\n", lines)); }
public ModCraft GetCopy() { List <refItem> CopyInputs = new List <refItem>(); List <refItem> CopyOutputs = new List <refItem>(); //copy the inputs and output foreach (refItem ri in this.Inputs) { CopyInputs.Add(ri.GetCopy()); } foreach (refItem ri in this.Outputs) { CopyOutputs.Add(ri.GetCopy()); } ModCraft copy = new ModCraft(this.Recipe.GetCopy(), CopyInputs.ToArray(), CopyOutputs.ToArray(), this.IsMadeInFurnace); return(copy); }
public oMod(string filepath) { ////load the archive octar1Archive arch = octar1ArchiveSaver.LoadArchive(filepath); ////load the mod properties written in rootf\\modinfo ctar1File ctfModInfo = arch.GetFileFromPath("rootf\\modinfo"); //create the memory stream to read the file MemoryStream wwwms = new MemoryStream(ctfModInfo.Content); //read the content of the file while (true) { byte IndicationByte = (byte)(wwwms.ReadByte()); //if end of the file if (IndicationByte == 255) { break; } //0x01 is mod name if (IndicationByte == 1) { byte[] byteModName = MemVoid.ReadByteUntilByte(wwwms, 0); this.ModName = System.Text.Encoding.UTF8.GetString(byteModName); } } //we have finished reading the mod info file wwwms.Dispose(); ////load the items ctar1Folder FolderItem = arch.GetFolderFromPath("rootf\\Items"); //get the folder of the items foreach (ctar1File f in FolderItem.listSubFile) { //we create the variable to get the properties values. string strItemName = ""; string strItemModName = ""; Bitmap img = null; bool boolIsBelt = true; //create the memory stream used to read the content of the file MemoryStream ms = new MemoryStream(f.Content); //read the content while (true) { /* * * * bytes who describe what property is comming: * -0x01 item name string * -0x02 mod name string * -0x03 is belt bool * -0x04 image file name string * * -0xff end of the file, we must stop reading, nothing else is comming after. * */ //the first byte of each block indicate what's comming next. byte IndicationByte = (byte)(ms.ReadByte()); //255 is the end of the file if (IndicationByte == 255) { break; } //item name if (IndicationByte == 1) { //get the data as byte[] and then convert it to a string byte[] byteStr = MemVoid.ReadByteUntilByte(ms, 0); strItemName = System.Text.Encoding.UTF8.GetString(byteStr); //Program.wdebug(strItemName + " : " + strItemName.Length.ToString()); } //mod name if (IndicationByte == 2) { //get the data as byte[] and then convert it to a string byte[] byteStr = MemVoid.ReadByteUntilByte(ms, 0); strItemModName = System.Text.Encoding.UTF8.GetString(byteStr); } //IsBelt if (IndicationByte == 3) { byte byteValue = (byte)(ms.ReadByte()); boolIsBelt = byteValue == 1; //read the null byte that end the bool value ms.ReadByte(); } //image file name if (IndicationByte == 4) { //get the data as byte[] and then convert it to a string byte[] byteStr = MemVoid.ReadByteUntilByte(ms, 0); string strImageFileName = System.Text.Encoding.UTF8.GetString(byteStr); //get the file of the image ctar1File FileImage = arch.GetFileFromPath("rootf\\Items\\Images\\" + strImageFileName); //creates a memory stream for the constructor MemoryStream msimage = new MemoryStream(FileImage.Content); img = new Bitmap(msimage); msimage.Dispose(); } } //we have finished to read the content ms.Dispose(); //create the ModItem ModItem newmi = new ModItem(strItemName, strItemModName, img); newmi.IsBelt = boolIsBelt; this.listItems.Add(newmi); } ////load the crafts ctar1Folder FolderCraft = arch.GetFolderFromPath("rootf\\Crafts"); //get the folder of the crafts foreach (ctar1File f in FolderCraft.listSubFile) { //these variables will be defined during the reading process refItem riRecipe = new refItem("", ""); List <refItem> listInputs = new List <refItem>(); //inputs and outputs will be added during the reading process List <refItem> listOutputs = new List <refItem>(); bool ismadeinfurnace = false; //create the memory stream used to read the content MemoryStream ms = new MemoryStream(f.Content); //read the file while (true) { /* * * the beginning byte for every type of "block" : * -0x01 recipe string string * -0x02 input string string * -0x03 output string string * -0x04 is made in furnace bool * */ byte IndicationByte = (byte)(ms.ReadByte()); //if end of the file if (IndicationByte == 255) { break; } //if recipe if (IndicationByte == 1) { //read the recipe name byte[] byteItemName = MemVoid.ReadByteUntilByte(ms, 0); //read until null caracter 0 riRecipe.ItemName = System.Text.Encoding.UTF8.GetString(byteItemName); //read the recipe mod name byte[] byteModName = MemVoid.ReadByteUntilByte(ms, 0); riRecipe.ModName = System.Text.Encoding.UTF8.GetString(byteModName); } //if an input if (IndicationByte == 2) { byte[] byteItemName = MemVoid.ReadByteUntilByte(ms, 0); byte[] byteModName = MemVoid.ReadByteUntilByte(ms, 0); refItem newinput = new refItem(); newinput.ItemName = System.Text.Encoding.UTF8.GetString(byteItemName); newinput.ModName = System.Text.Encoding.UTF8.GetString(byteModName); //add the new input to the list listInputs.Add(newinput); } //if an output if (IndicationByte == 3) { byte[] byteItemName = MemVoid.ReadByteUntilByte(ms, 0); byte[] byteModName = MemVoid.ReadByteUntilByte(ms, 0); refItem newoutput = new refItem(); newoutput.ItemName = System.Text.Encoding.UTF8.GetString(byteItemName); newoutput.ModName = System.Text.Encoding.UTF8.GetString(byteModName); //add the new output to the list listOutputs.Add(newoutput); } //if is made in furnace if (IndicationByte == 4) { byte byteValue = (byte)(ms.ReadByte()); ismadeinfurnace = byteValue == 1; //read the null byte that end the bool ms.ReadByte(); } } //we have finished to read the content ms.Dispose(); //create the ModCraft ModCraft newcraft = new ModCraft(riRecipe, listInputs.ToArray(), listOutputs.ToArray(), ismadeinfurnace); this.listCrafts.Add(newcraft); } }
public void AddCraft(ModCraft newcraft) { //add it and raise the event this.listCrafts.Add(newcraft); this.Raise_CraftAdded(newcraft); }
private static void ParsePropMods(ModCraft m, IDictionary <string, int> mods) { foreach (ModRoll s in m.Stats) { switch (s.ID) { case "local_physical_damage_reduction_rating_+%": mods["arp"] += s.Roll; break; case "local_evasion_rating_+%": mods["evp"] += s.Roll; break; case "local_energy_shield_+%": mods["esp"] += s.Roll; break; case "local_armour_and_evasion_+%": mods["arp"] += s.Roll; mods["evp"] += s.Roll; break; case "local_armour_and_energy_shield_+%": mods["arp"] += s.Roll; mods["esp"] += s.Roll; break; case "local_evasion_and_energy_shield_+%": mods["evp"] += s.Roll; mods["esp"] += s.Roll; break; case "local_armour_and_evasion_and_energy_shield_+%": mods["arp"] += s.Roll; mods["evp"] += s.Roll; mods["esp"] += s.Roll; break; case "local_base_physical_damage_reduction_rating": mods["arf"] += s.Roll; break; case "local_base_evasion_rating": mods["evf"] += s.Roll; break; case "local_energy_shield": mods["esf"] += s.Roll; break; case "local_additional_block_chance_%": mods["blf"] += s.Roll; break; case "local_physical_damage_+%": mods["dp"] += s.Roll; break; case "local_minimum_added_physical_damage": mods["mindf"] += s.Roll; break; case "local_maximum_added_physical_damage": mods["maxdf"] += s.Roll; break; case "local_critical_strike_chance_+%": mods["crp"] += s.Roll; break; case "local_attack_speed_+%": mods["asp"] += s.Roll; break; case "local_item_quality_+": mods["qf"] += s.Roll; break; default: break; } } }