public void updateUI(EquipItem item) { txtName.Text = item.Name; txtEquipCodes.Text = item.ToString(); cboEquipLevel.SelectedIndex = item.Level; cboEquipExt.SelectedIndex = item.Ext; chkEquipJN.Checked = item.JN; chkEquipXY.Checked = item.XY; chkEquipZY1.Checked = item.ZY1; chkEquipZY2.Checked = item.ZY2; chkEquipZY3.Checked = item.ZY3; chkEquipZY4.Checked = item.ZY4; chkEquipZY5.Checked = item.ZY5; chkEquipZY6.Checked = item.ZY6; txtSerial.Text = item.Serial.ToString(); //chkEquipSet.Checked = item.Set; int set = item.Set; if (set == 0) chkEquipSet.Checked = false; else { chkEquipSet.Checked = true; txtSet.Text = set.ToString(); } txtDurability.Text = Convert.ToString(item.Durability); GetSocketVal(item.Socket1, ref comboSock1, ref numericSock1); GetSocketVal(item.Socket2, ref comboSock2, ref numericSock2); GetSocketVal(item.Socket3, ref comboSock3, ref numericSock3); GetSocketVal(item.Socket4, ref comboSock4, ref numericSock4); GetSocketVal(item.Socket5, ref comboSock5, ref numericSock5); //comboHarmony.SelectedIndex = (item.Harmony & 0xF0) >> 4; }
protected static EquipItem createUnknownItem() { EquipItem item = new EquipItem(); item.Name = EquipItem.UNKNOW_ITEM; item.hand = 1; item.profs = 0xFF; ResourceManager rmgr = new ResourceManager("TitanEditor.Properties.Resources", Assembly.GetExecutingAssembly()); item.Img = (Image)rmgr.GetObject(UNKNOW_ITEM); return item; }
public void updateData(EquipItem item) { item.Level = (byte)(cboEquipLevel.SelectedIndex); item.Ext = cboEquipExt.SelectedIndex; item.JN = chkEquipJN.Checked; item.XY = chkEquipXY.Checked; item.ZY1 = chkEquipZY1.Checked; item.ZY2 = chkEquipZY2.Checked; item.ZY3 = chkEquipZY3.Checked; item.ZY4 = chkEquipZY4.Checked; item.ZY5 = chkEquipZY5.Checked; item.ZY6 = chkEquipZY6.Checked; item.Serial = Convert.ToInt64(txtSerial.Text); //item.Set = chkEquipSet.Checked; if (chkEquipSet.Checked == false) item.Set = 0; else { item.Set = Convert.ToByte(txtSet.Text); } item.Durability = Convert.ToByte(txtDurability.Text); item.Socket1 = GetSocketNum(comboSock1, numericSock1.Value); item.Socket2 = GetSocketNum(comboSock2, numericSock2.Value); item.Socket3 = GetSocketNum(comboSock3, numericSock3.Value); item.Socket4 = GetSocketNum(comboSock4, numericSock4.Value); item.Socket5 = GetSocketNum(comboSock5, numericSock5.Value); item.Harmony = 0; if (comboHarmony.SelectedItem != null) { if (comboHarmony.SelectedIndex > 0) { item.Harmony |= Convert.ToByte((comboHarmony.SelectedIndex) << 4); item.Harmony |= Convert.ToByte(item.Level & 0x0F); } } }
public void updateUI(EquipItem item) { cboEquipLevel.SelectedIndex = item.Level; cboEquipExt.SelectedIndex = item.Ext; chkEquipJN.Checked = item.JN; chkEquipXY.Checked = item.XY; chkEquipZY1.Checked = item.ZY1; chkEquipZY2.Checked = item.ZY2; chkEquipZY3.Checked = item.ZY3; chkEquipZY4.Checked = item.ZY4; chkEquipZY5.Checked = item.ZY5; chkEquipZY6.Checked = item.ZY6; //chkEquipSet.Checked = item.Set; int set = item.Set; if (set == 0) { chkEquipSet.Checked = false; } else { chkEquipSet.Checked = true; txtSet.Text = set.ToString(); } GetSocketVal(item.Socket1, ref comboSock1, ref numericSock1); GetSocketVal(item.Socket2, ref comboSock2, ref numericSock2); GetSocketVal(item.Socket3, ref comboSock3, ref numericSock3); GetSocketVal(item.Socket4, ref comboSock4, ref numericSock4); GetSocketVal(item.Socket5, ref comboSock5, ref numericSock5); //comboHarmony.SelectedIndex = (item.Harmony & 0xF0) >> 4; txtDurability.Text = Convert.ToString(item.Durability); txtSerial.Text = Convert.ToString(item.Serial); }
public EquipItem getItem(string name) { EquipItem item = null; if ((item = (EquipItem)cache[name]) == null) { lock (cache) { if ((item = (EquipItem)cache[name]) == null) { string sql = string.Format("select UniQue, Name, Hand, Type, Wide, High, DW, DK, ELF, MG, DL, SU, RF, Pic from MuItem where Name = '{0}'", name); item = getItemFromDb(sql); if (item == null) { item = EquipItem.UnknownItem; } cache[name] = item; cache[item.CodeType] = item; } } } return(item); }
public void assign(DrawingUnit unit) { x = unit.X; y = unit.Y; item = unit.Item; }
private void btnOK_Click(object sender, EventArgs e) { if (null != item) updateData(item); item = null; this.Close(); }
public DrawingUnit(EquipItem item, int x, int y) { this.item = item; this.x = x; this.y = y; }
private void EquipPanel_Paint(object sender, PaintEventArgs e) { if (units == null) { return; } // Graphics g = e.Graphics; DrawingUnit unit = null; EquipItem item = null; int x = 0, y = 0; for (int i = 0; i < xnum; i++) { for (int j = 0; j < ynum; j++) { if ((unit = units[i, j]) != null && unit.Item != null) { drawUnit(g, units[i, j]); } } } if (null != selectedUnit && null != selectedUnit.Item) { Brush brush = new SolidBrush(Color.FromArgb(60, 128, 128, 128)); g.FillRectangle(brush, selectedUnit.X * pixels, selectedUnit.Y * pixels, selectedUnit.Item.Width * pixels, selectedUnit.Item.Height * pixels); } if (null != activeUnit && null != activeUnit.Item) { item = activeUnit.Item; x = activeUnit.X; y = activeUnit.Y; g.DrawImage(item.Img, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); if (canPutItem(activeUnit)) { g.DrawRectangle(Pens.Blue, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } else { g.DrawRectangle(Pens.Red, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } } if (coveredUnit != null && coveredUnit.Item != null) { item = coveredUnit.Item; x = coveredUnit.X; y = coveredUnit.Y; g.DrawRectangle(Pens.Blue, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } if (activeUnit == null && coveredUnit == null && selectedUnit == null && curUnit != null && curUnit.Item != null) { item = curUnit.Item; x = curUnit.X; y = curUnit.Y; g.DrawImage(item.Img, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); if (canPutItem(curUnit)) { g.DrawRectangle(Pens.Blue, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } else { g.DrawRectangle(Pens.Red, x * pixels, y * pixels, item.Width * pixels, item.Height * pixels); } } }
public EquipItem assign(EquipItem other) { other.codes.CopyTo(this.codes, 0); this.xnum = other.xnum; this.ynum = other.ynum; this.name = other.name; this.hand = other.hand; this.profs = other.profs; // 1 2 3 4 5 6 7 this.img = other.img; return this; }
public EquipItem(EquipItem baseItem, byte[] codes) { this.xnum = baseItem.xnum; this.ynum = baseItem.ynum; this.name = baseItem.name; this.hand = baseItem.hand; this.profs = baseItem.profs; // 1234 5678 1234 5678 1234 5678 1234 // this.img = baseItem.img; codes.CopyTo(this.codes, 0); }
public EquipProperty(EquipItem item) { InitializeComponent(); this.item = item; }
private void btnCancel_Click(object sender, EventArgs e) { item = null; }
private void cboEquipName_TextChanged(object sender, EventArgs e) { string itemName = cboEquipName.Text; if (null == itemName || "" == itemName.Trim()) { return; } EquipItem item = EquipImageCache.Instance.getItem(cboEquipName.Text); if (null != item) { if (editItem == null) editItem = new EquipItem(); editItem.assign(item); } }
public EquipItem getItemByCodeType(string codeType) { EquipItem item = null; if ((item = (EquipItem)cache[codeType]) == null) { lock (cache) { if ((item = (EquipItem)cache[codeType]) == null) { try { string sql = string.Format("select UniQue, Name, Hand, Type, Wide, High, DW, DK, ELF, MG, DL, SU, RF, Pic from MuItem where UniQue = {0} and Type = {1}", EquipItem.getItemCode(codeType), EquipItem.getItemType(codeType)); item = getItemFromDb(sql); if (item == null) { item = item = EquipItem.UnknownItem; } cache[codeType] = item; cache[item.Name] = item; } catch (Exception) { MessageBox.Show("Item: [" + EquipItem.getItemType(codeType) + ", " + EquipItem.getItemCode(codeType) + "]. Doesnt exist in DB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } return(item); }
public bool putItems(EquipItem[] items) { bool isPut = true; if (canPutItems(items)) { for (int i = 0; i < items.Length ; i ++) { if (null == items[i]) continue; isPut = isPut && putItem (items[i], true); } return isPut; } return false; }
public EquipItem(EquipItem baseItem) { this.xnum = baseItem.xnum; this.ynum = baseItem.ynum; this.name = baseItem.name; this.hand = baseItem.hand; this.profs = baseItem.profs; // 1234 5678 1234 5678 1234 5678 1234 // this.img = baseItem.img; }
public bool canPutItems(EquipItem[] items) { bool[,] curflags = (bool[,])flags.Clone(); foreach (EquipItem item in items) { if (null == item) continue; for (int j = 0; j < ynum; j++) { for (int i = 0; i < xnum; i++) { if (!curflags[i, j] && canPutItem (item, i, j, curflags ) && tryPutItem(item, i, j, curflags)) { goto NextItem; } } } return false; NextItem: ; } return true; }
public EquipItem(EquipItem baseItem, byte[] codes, int offset, int len) { this.xnum = baseItem.xnum; this.ynum = baseItem.ynum; this.name = baseItem.name; this.hand = baseItem.hand; this.profs = baseItem.profs; // 1234 5678 1234 5678 1234 5678 1234 // this.img = baseItem.img; Array.Copy(codes, offset, this.codes, 0, len); }
public bool putItem(EquipItem item, bool add) { DrawingUnit unit = null; if (add) { unit = new DrawingUnit(new EquipItem(), 0, 0); unit.Item.assign(item); } else { unit = new DrawingUnit(item, 0, 0); } for (int j = 0; j < ynum; j++) { for (int i = 0; i < xnum; i++) { if (!flags[i, j]) { unit.X = i; unit.Y = j; if (canPutItem(unit)) { return putItem(unit, false); } } } } return false; }
public bool canPutItem(EquipItem item, int x, int y) { if (item.Width + x > xnum || item.Height + y > ynum || x < 0 || y < 0) return false; if (flags[x, y]) return false; for (int i = 0; i < item.Width; i++) { for (int j = 0; j < item.Height; j++) { if (flags[i + x, j + y]) return false; } } return true; }
public DrawingUnit(EquipItem item) { this.item = item; }
protected EquipItem getItemFromDb(string sql) { MemoryStream stream = null; Image img = null; EquipItem item = null; try { DBLite.mdb.Read(sql); DBLite.mdb.Fetch(); // int profs = DBLite.mdb.GetAsInteger("DW") + DBLite.mdb.GetAsInteger("DK") << 1 + DBLite.mdb.GetAsInteger("ELF") << 2 + DBLite.mdb.GetAsInteger("MG") << 3 + DBLite.mdb.GetAsInteger("DL") << 4 + DBLite.mdb.GetAsInteger("SU") << 5 + DBLite.mdb.GetAsInteger("RF") << 6; item = new EquipItem (DBLite.mdb.GetAsInteger("UniQue"), DBLite.mdb.GetAsString("Name"), DBLite.mdb.GetAsInteger("Hand"), DBLite.mdb.GetAsInteger("Type"), DBLite.mdb.GetAsInteger("Wide"), DBLite.mdb.GetAsInteger("High"), profs); Byte[] data = DBLite.mdb.GetAsBinary("Pic"); if (data != null) { stream = new MemoryStream(data); img = Image.FromStream(stream); stream.Close(); item.Img = img; } else { ResourceManager rmgr = new ResourceManager("TitanEditor.Properties.Resources", Assembly.GetExecutingAssembly()); item.Img = (Image)rmgr.GetObject("unknownItem"); } DBLite.mdb.Close(); } catch(Exception ex) { MessageBox.Show("MDB Query:" + sql + "\nError:" + ex.Message + "\nSource:" + ex.Source + "\nTrace:" + ex.StackTrace); } return item; }