//public ObservableCollection<TriggerItemBinding> TriggerItems = new ObservableCollection<TriggerItemBinding>(); private void TriggerSave() { TRIG.Clear(); for (int i = 0; i < Triggers.Count; i++) { RAWTRIGMBRF rAWTRIGMBRF = new RAWTRIGMBRF(Triggers[i]); TRIG.Add(rAWTRIGMBRF); } MBRF.Clear(); for (int i = 0; i < Brifings.Count; i++) { RAWTRIGMBRF rAWTRIGMBRF = new RAWTRIGMBRF(Brifings[i]); for (int c = 0; c < 16; c++) { rAWTRIGMBRF.conditions[c].condtype = 13; } MBRF.Add(rAWTRIGMBRF); } }
private bool Applychk(BinaryReader br) { CHKToken cHKToken = GetNextCHK(br); br.BaseStream.Position = cHKToken.start; //Byte로부터 에디터로 넣는 함수 switch (cHKToken.tokentype) { case TOKENTYPE.ENCD: SetEncoding(br.ReadInt32()); break; case TOKENTYPE.IOWN: IOWN = br.ReadBytes(12); break; case TOKENTYPE.OWNR: //넘기기 OWNR = br.ReadBytes(12); break; case TOKENTYPE.SIDE: SIDE = br.ReadBytes(12); break; case TOKENTYPE.ERA: ushort tile = br.ReadUInt16(); if (tile > 7) { throw new Exception(""); } TILETYPE = (TileType)tile; break; case TOKENTYPE.COLR: COLR = br.ReadBytes(8); for (int i = 0; i < 8; i++) { if (COLR[i] >= ColorName.Count()) { COLR[i] = 0; } CRGB[i] = new Microsoft.Xna.Framework.Color(0, 0, COLR[i]); } break; case TOKENTYPE.CRGB: for (int i = 0; i < 8; i++) { byte[] colors = br.ReadBytes(3); CRGB[i] = new Microsoft.Xna.Framework.Color(colors[0], colors[1], colors[2]); } CRGBIND = br.ReadBytes(8); break; case TOKENTYPE.UNIT: UNIT.Clear(); for (int i = 0; i < cHKToken.size / 36; i++) { CUNIT cUNIT = new CUNIT(br); cUNIT.SetMapEditor(mapEditor); UNIT.Add(cUNIT); } break; case TOKENTYPE.DIM: WIDTH = br.ReadUInt16(); HEIGHT = br.ReadUInt16(); break; case TOKENTYPE.TILE: TILE = new ushort[cHKToken.size / 2]; for (int i = 0; i < cHKToken.size / 2; i++) { TILE[i] = br.ReadUInt16(); } break; case TOKENTYPE.MTXM: MTXM = new ushort[cHKToken.size / 2]; for (int i = 0; i < cHKToken.size / 2; i++) { MTXM[i] = br.ReadUInt16(); } break; case TOKENTYPE.DD2: for (int i = 0; i < cHKToken.size / 8; i++) { CDD2 cDD2 = new CDD2(br, this); DD2.Add(cDD2); } break; case TOKENTYPE.THG2: for (int i = 0; i < cHKToken.size / 10; i++) { CTHG2 cTHG2 = new CTHG2(br); THG2.Add(cTHG2); } break; case TOKENTYPE.MASK: MASK = br.ReadBytes((int)cHKToken.size); break; case TOKENTYPE.STR: { long startpoint = br.BaseStream.Position; LOADSTR = new string[br.ReadUInt16()]; BYTESTR = new List <byte[]>(); ushort[] ptrs = new ushort[LOADSTR.Length]; for (int i = 0; i < ptrs.Length; i++) { ptrs[i] = br.ReadUInt16(); } for (int i = 0; i < ptrs.Length; i++) { br.BaseStream.Position = startpoint + ptrs[i]; List <byte> strs = new List <byte>(); byte readbyte = br.ReadByte(); if (readbyte != 0) { strs.Add(readbyte); while (true) { readbyte = br.ReadByte(); if (readbyte == 0) { break; } strs.Add(readbyte); } } BYTESTR.Add(strs.ToArray()); //LOADSTR[i] = System.Text.Encoding.GetEncoding(949).GetString(strs.ToArray()); } } break; case TOKENTYPE.STRx: { long startpoint = br.BaseStream.Position; LOADSTRx = new string[br.ReadUInt32()]; BYTESTRx = new List <byte[]>(); uint[] ptrs = new uint[LOADSTRx.Length]; for (int i = 0; i < ptrs.Length; i++) { ptrs[i] = br.ReadUInt32(); } for (int i = 0; i < ptrs.Length; i++) { br.BaseStream.Position = startpoint + ptrs[i]; List <byte> strs = new List <byte>(); byte readbyte = br.ReadByte(); if (readbyte != 0) { strs.Add(readbyte); while (true) { readbyte = br.ReadByte(); if (readbyte == 0) { break; } strs.Add(readbyte); } } BYTESTRx.Add(strs.ToArray()); //LOADSTRx[i] = System.Text.Encoding.UTF8.GetString(strs.ToArray()); } } break; case TOKENTYPE.SPRP: SCEARIONAME = new StringData(this, br.ReadUInt16()); SCEARIODES = new StringData(this, br.ReadUInt16()); break; case TOKENTYPE.FORC: FORCE = br.ReadBytes(8); FORCENAME = new StringData[4]; FORCENAME[0] = new StringData(this, br.ReadUInt16()); FORCENAME[1] = new StringData(this, br.ReadUInt16()); FORCENAME[2] = new StringData(this, br.ReadUInt16()); FORCENAME[3] = new StringData(this, br.ReadUInt16()); FORCEFLAG = br.ReadBytes(4); break; case TOKENTYPE.MRGN: LocationDatas.Clear(); LocationDatas.Add(new LocationData(mapEditor)); for (int i = 0; i < 255; i++) { LocationData locationData = new LocationData(mapEditor); locationData.INDEX = i + 1; locationData.L = br.ReadUInt32(); locationData.T = br.ReadUInt32(); locationData.R = br.ReadUInt32(); locationData.B = br.ReadUInt32(); locationData.STRING = new StringData(this, br.ReadUInt16()); locationData.FLAG = br.ReadUInt16(); if (locationData.L == 0 & locationData.T == 0 & locationData.L == 0 & locationData.T == 0 & locationData.STRING.LoadedIndex == -1 & locationData.FLAG == 0) { continue; } LocationDatas.Add(locationData); } //u32: Left(X1) coordinate of location, in pixels(usually 32 pt grid aligned) //u32: Top(Y1) coordinate of location, in pixels //u32: Right(X2) coordinate of location, in pixels //u32: Bottom(Y2) coordinate of location, in pixels //u16: String number of the name of this location //u16: Location elevation flags.If an elevation is disabled in the location, it's bit will be on (1) //Bit 0 - Low elevation //Bit 1 - Medium elevation //Bit 2 - High elevation //Bit 3 - Low air //Bit 4 - Medium air //Bit 5 - High air //Bit 6 - 15 - Unused break; case TOKENTYPE.UPRP: UPRP = new CUPRP[64]; for (int i = 0; i < 64; i++) { CUPRP cUPRP = new CUPRP(); cUPRP.STATUSVALID = br.ReadUInt16(); cUPRP.POINTVALID = br.ReadUInt16(); cUPRP.PLAYER = br.ReadByte(); cUPRP.HITPOINT = br.ReadByte(); cUPRP.SHIELDPOINT = br.ReadByte(); cUPRP.ENERGYPOINT = br.ReadByte(); cUPRP.RESOURCE = br.ReadUInt32(); cUPRP.HANGAR = br.ReadUInt16(); cUPRP.STATUSFLAG = br.ReadUInt16(); cUPRP.UNUSED = br.ReadUInt32(); UPRP[i] = cUPRP; } break; case TOKENTYPE.UPUS: UPUS = br.ReadBytes(64); break; case TOKENTYPE.WAV: WAV = new StringData[512]; for (int i = 0; i < 512; i++) { WAV[i] = new StringData(this, br.ReadInt32()); } break; case TOKENTYPE.SWNM: SWNM = new StringData[256]; for (int i = 0; i < 256; i++) { SWNM[i] = new StringData(this, br.ReadInt32()); } break; case TOKENTYPE.PUNI: PUNI = new CPUNI(); for (int i = 0; i < 12; i++) { PUNI.UNITENABLED[i] = br.ReadBytes(228); } PUNI.DEFAULT = br.ReadBytes(228); for (int i = 0; i < 12; i++) { PUNI.USEDEFAULT[i] = br.ReadBytes(228); } break; case TOKENTYPE.PUPx: PUPx = new CPUPx(); for (int i = 0; i < 12; i++) { PUPx.MAXLEVEL[i] = br.ReadBytes(61); } for (int i = 0; i < 12; i++) { PUPx.STARTLEVEL[i] = br.ReadBytes(61); } PUPx.DEFAULTMAXLEVEL = br.ReadBytes(61); PUPx.DEFAULTSTARTLEVEL = br.ReadBytes(61); for (int i = 0; i < 12; i++) { PUPx.USEDEFAULT[i] = br.ReadBytes(61); } break; case TOKENTYPE.PTEx: PTEx = new CPTEx(); for (int i = 0; i < 12; i++) { PTEx.MAXLEVEL[i] = br.ReadBytes(44); } for (int i = 0; i < 12; i++) { PTEx.STARTLEVEL[i] = br.ReadBytes(44); } PTEx.DEFAULTMAXLEVEL = br.ReadBytes(44); PTEx.DEFAULTSTARTLEVEL = br.ReadBytes(44); for (int i = 0; i < 12; i++) { PTEx.USEDEFAULT[i] = br.ReadBytes(44); } break; case TOKENTYPE.UNIx: UNIx = new CUNIx(); for (int i = 0; i < 228; i++) { UNIx.USEDEFAULT[i] = br.ReadByte(); } for (int i = 0; i < 228; i++) { UNIx.HIT[i] = br.ReadUInt32(); } for (int i = 0; i < 228; i++) { UNIx.SHIELD[i] = br.ReadUInt16(); } for (int i = 0; i < 228; i++) { UNIx.ARMOR[i] = br.ReadByte(); } for (int i = 0; i < 228; i++) { UNIx.BUILDTIME[i] = br.ReadUInt16(); } for (int i = 0; i < 228; i++) { UNIx.MIN[i] = br.ReadUInt16(); } for (int i = 0; i < 228; i++) { UNIx.GAS[i] = br.ReadUInt16(); } for (int i = 0; i < 228; i++) { UNIx.STRING[i] = new StringData(this, br.ReadUInt16()); } for (int i = 0; i < 130; i++) { UNIx.DMG[i] = br.ReadUInt16(); } for (int i = 0; i < 130; i++) { UNIx.BONUSDMG[i] = br.ReadUInt16(); } break; case TOKENTYPE.UPGx: UPGx = new CUPGx(); for (int i = 0; i < 61; i++) { UPGx.USEDEFAULT[i] = br.ReadByte(); } br.ReadByte(); for (int i = 0; i < 61; i++) { UPGx.BASEMIN[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BONUSMIN[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BASEGAS[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BONUSGAS[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BASETIME[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BONUSTIME[i] = br.ReadUInt16(); } break; case TOKENTYPE.TECx: TECx = new CTECx(); for (int i = 0; i < 44; i++) { TECx.USEDEFAULT[i] = br.ReadByte(); } for (int i = 0; i < 44; i++) { TECx.MIN[i] = br.ReadUInt16(); } for (int i = 0; i < 44; i++) { TECx.GAS[i] = br.ReadUInt16(); } for (int i = 0; i < 44; i++) { TECx.BASETIME[i] = br.ReadUInt16(); } for (int i = 0; i < 44; i++) { TECx.ENERGY[i] = br.ReadUInt16(); } break; case TOKENTYPE.TRIG: TRIG.Clear(); for (int i = 0; i < cHKToken.size / 2400; i++) { RAWTRIGMBRF trig = new RAWTRIGMBRF(br); TRIG.Add(trig); } break; case TOKENTYPE.MBRF: MBRF.Clear(); for (int i = 0; i < cHKToken.size / 2400; i++) { RAWTRIGMBRF mbrf = new RAWTRIGMBRF(br); MBRF.Add(mbrf); } break; } for (int i = 0; i < cHKTokens.Count; i++) { if (cHKTokens[i].code == cHKToken.code) { cHKTokens.RemoveAt(i); break; } } cHKTokens.Add(cHKToken); br.BaseStream.Position = cHKToken.end; return(true); }