void Start() { ConfigScript config = (ConfigScript)Object.FindObjectOfType(typeof(ConfigScript)); ppu = config.pixelsPerUnit; driving = GetComponent <DrivingScript>(); headlights = new GameObject[] { AddHeadlight(true), AddHeadlight(false), }; foreach (GameObject light in headlights) { light.SetActive(startOn); } }
public static LevelLayerData getLayoutLinearSH(int curActiveLayout) { int layoutAddr = ConfigScript.getLayoutAddr(curActiveLayout); int width = ConfigScript.getLevelWidth(curActiveLayout); int height = ConfigScript.getLevelHeight(curActiveLayout); int[] layer = new int[width * height]; for (int i = 0; i < width * height; i++) { var scrNo = Globals.romdata[layoutAddr + i]; if (scrNo > 0) //not change zero values (for easy view) { layer[i] = (scrNo + 1) % 256; } } return(new LevelLayerData(width, height, layer, null, null)); }
public void setBigBlocksTT(int bigTileIndex, BigBlock[] bigBlockIndexes) { var bigBlocksAddr = ConfigScript.getBigTilesAddr(0, bigTileIndex); for (int v = 0; v < bigBlockIndexes.Length; v++) { var bb = bigBlockIndexes[v] as BigBlockWithPal; var i0 = bb.indexes[0]; var i1 = bb.indexes[1]; var i2 = bb.indexes[2]; var i3 = bb.indexes[3]; Globals.romdata[bigBlocksAddr + v * 4 + 0] = (byte)i0; Globals.romdata[bigBlocksAddr + v * 4 + 1] = (byte)i2; Globals.romdata[bigBlocksAddr + v * 4 + 2] = (byte)i1; Globals.romdata[bigBlocksAddr + v * 4 + 3] = (byte)i3; } }
public MapInfo[] makeMapsInfo() { var mapsInfo = new MapInfo[getScreensOffset().recCount]; int scrSize = getScreensOffset().width *getScreensOffset().height *ConfigScript.getWordLen(); int attrSize = 64; for (int i = 0; i < mapsInfo.Length; i++) { int da = getScreensOffset().beginAddr + scrSize * i; int aa = getPalBytesAddr() + attrSize * i; mapsInfo[i] = new MapInfo() { dataAddr = da, palAddr = ConfigScript.palOffset.beginAddr, videoNo = 0, attribsAddr = aa }; } return(mapsInfo); }
public Bitmap[] makeObjects(int videoPageId, int tilesId, int palId, MapViewType drawType, int constantSubpal = -1) { byte[] videoChunk = ConfigScript.getVideoChunk(videoPageId); ObjRec[] objects = ConfigScript.getBlocks(tilesId); byte[] palette = ConfigScript.getPal(palId); var range256 = Enumerable.Range(0, 256); var objStrip1 = range256.Select(i => makeImage(i, videoChunk, palette, 0)).ToArray(); var objStrip2 = range256.Select(i => makeImage(i, videoChunk, palette, 1)).ToArray(); var objStrip3 = range256.Select(i => makeImage(i, videoChunk, palette, 2)).ToArray(); var objStrip4 = range256.Select(i => makeImage(i, videoChunk, palette, 3)).ToArray(); var objStrips = new[] { objStrip1, objStrip2, objStrip3, objStrip4 }; var bitmaps = makeObjects(objects, objStrips, drawType, constantSubpal); return(bitmaps); }
private void bttExportPic_Click(object sender, EventArgs e) { int[][] screens, screens2; loadScreens(out screens, out screens2); SaveScreensCount.ExportMode = true; SaveScreensCount.Filename = "exportedScreens.png"; var f = new SaveScreensCount(); f.Text = "Export picture"; formMain.subeditorOpen(f, (ToolStripItem)sender, true); if (SaveScreensCount.Result) { if (SaveScreensCount.Count <= 0) { MessageBox.Show("Screens count value must be greater than 0", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int saveLastIndex = SaveScreensCount.First + SaveScreensCount.Count; if (saveLastIndex > screens.Length) { MessageBox.Show(string.Format("First screen + Screens Count value ({0}) must be less than Total Screen Count in the game ({1}", saveLastIndex, screens.Length), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int first = SaveScreensCount.First; int WIDTH = ConfigScript.getScreenWidth(formMain.LevelNoForScreens); int HEIGHT = ConfigScript.getScreenHeight(formMain.LevelNoForScreens); float curScale = formMain.CurScale; var probeIm = MapEditor.ScreenToImage(formMain.BigBlocks, formMain.Layers, formMain.ScreenNo, curScale, false, 0, 0, WIDTH, HEIGHT); int screenCount = SaveScreensCount.Count; var resultImage = new Bitmap(probeIm.Width * screenCount, probeIm.Height); using (var g = Graphics.FromImage(resultImage)) { for (int i = 0; i < screenCount; i++) { var im = MapEditor.ScreenToImage(formMain.BigBlocks, formMain.Layers, first + i, curScale, false, 0, 0, WIDTH, HEIGHT); g.DrawImage(im, new Point(i * im.Width, 0)); } } resultImage.Save(SaveScreensCount.Filename); } }
public LevelLayerData dwdGetLayout(int curActiveLayout) { if (curActiveLayout < 6) { return(Utils.getLayoutLinear(curActiveLayout)); } int layoutAddr = ConfigScript.getLayoutAddr(curActiveLayout); int width = ConfigScript.getLevelWidth(curActiveLayout); int height = ConfigScript.getLevelHeight(curActiveLayout); int[] layer = new int[width * height]; for (int i = 0; i < width * height; i++) { layer[i] = Globals.romdata[layoutAddr + i] + 256; } return(new LevelLayerData(width, height, layer, null, null)); }
public static void setBlocks(int tileId, ObjRec[] blocksData) { int addr = ConfigScript.getTilesAddr(tileId); int count = ConfigScript.getBlocksCount(); var palAddr = addr + count * 4; for (int i = 0; i < count; i++) { var obj = blocksData[i]; Globals.romdata[addr + i] = (byte)obj.indexes[0]; Globals.romdata[addr + count * 1 + i] = (byte)obj.indexes[1]; Globals.romdata[addr + count * 2 + i] = (byte)obj.indexes[2]; Globals.romdata[addr + count * 3 + i] = (byte)obj.indexes[3]; int t = Globals.romdata[palAddr + i]; t = t & 0x3F | (blocksData[i].palBytes[0] << 6); Globals.romdata[palAddr + i] = (byte)t; //save only pal bits, not physics } }
public IList <LevelRec> getLevelRecs() { var groups = ConfigScript.getGroups(); return(new List <LevelRec>() { new LevelRec(0x167D5, 48, 1, 1, 0x0, "Jungle By Day", groups[0]), new LevelRec(0x18815, 45, 1, 1, 0x0, "Great Tree", groups[1]), new LevelRec(0x173F6, 67, 1, 1, 0x0, "Dawn Patrol", groups[2]), new LevelRec(0x14B7A, 89, 1, 1, 0x0, "River", groups[3]), new LevelRec(0x1550E, 67, 1, 1, 0x0, "Baloo and River", groups[4]), new LevelRec(0x194D3, 51, 1, 1, 0x0, "Tree Village", groups[5]), new LevelRec(0x128D6, 60, 1, 1, 0x0, "Ruins", groups[6]), new LevelRec(0x13642, 111, 1, 1, 0x0, "Falling Ruins", groups[7]), new LevelRec(0x17E04, 65, 1, 1, 0x0, "Jungle By Night", groups[8]), //new LevelRec(0x10912, 74, 1, 1, 0x0, "Wastelands", groups[9]), }); }
public void setBlocks(int blockIndex, ObjRec[] blocksData) { int addr = ConfigScript.getTilesAddr(blockIndex); int count = getBlocksCount(); var romdata = Globals.romdata; for (int i = 0; i < count; i++) { var obj = blocksData[i]; romdata[addr + i] = (byte)obj.indexes[0]; romdata[addr + count * 1 + i] = (byte)obj.indexes[1]; romdata[addr + count * 2 + i] = (byte)obj.indexes[2]; romdata[addr + count * 3 + i] = (byte)obj.indexes[3]; var mask = 0x0F & romdata[addr + count * 4 + i]; romdata[addr + count * 4 + i] = (byte)(mask | obj.palBytes[0] << 4); } }
void Start() { ConfigScript config = (ConfigScript)Object.FindObjectOfType(typeof(ConfigScript)); ppu = config.pixelsPerUnit; Vector3 frontWheelPos = frontWheelOffset.localPosition; Vector3 backWheelPos = backWheelOffset.localPosition; wheels = new Wheel[] { AddWheel(frontWheelPos.x, frontWheelPos.y, frontWheelDrive, true, false), AddWheel(-frontWheelPos.x, frontWheelPos.y, frontWheelDrive, true, false), AddWheel(backWheelPos.x, backWheelPos.y, !frontWheelDrive, false, true), AddWheel(-backWheelPos.x, backWheelPos.y, !frontWheelDrive, false, true), }; body = GetComponent <Rigidbody2D>(); ai = GetComponent <DrivingAIScript>(); }
private void bttnLoadScript_Click(object sender, RoutedEventArgs e) { try { var script = new ConfigScript(); script.Load(txtScriptFile.Text); script.Analyze(script.TrainingFile); UpdateButtons(); lblPopFile.Content = script.PopulationFile; lblEvaluateFilesIn.Content = "Input: " + script.EvaluationFile; lblEvaluateFilesOut.Content = "Output: " + script.EvaluationFile; ApplicationSingleton.Instance.Config = script; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().Name); } }
public IList <LevelRec> getLevelRecsCad() { var groups = ConfigScript.getGroups(); return(new List <LevelRec>() { new LevelRec(0x10388, 76, getLayoutWidth(0), getLayoutHeight(0), getLayoutAddr(0), groups[0].name, groups[0]), //broke first boss after save? new LevelRec(0x10456, 31, getLayoutWidth(1), getLayoutHeight(1), getLayoutAddr(1), groups[1].name, groups[1]), new LevelRec(0x105A1, 73, getLayoutWidth(2), getLayoutHeight(2), getLayoutAddr(2), groups[2].name, groups[2]), new LevelRec(0x106D1, 57, getLayoutWidth(3), getLayoutHeight(3), getLayoutAddr(3), groups[3].name, groups[3]), new LevelRec(0x10890, 97, getLayoutWidth(4), getLayoutHeight(4), getLayoutAddr(4), groups[4].name, groups[4]), new LevelRec(0x10A1D, 74, getLayoutWidth(5), getLayoutHeight(5), getLayoutAddr(5), groups[5].name, groups[5]), new LevelRec(0x10B0E, 41, getLayoutWidth(6), getLayoutHeight(6), getLayoutAddr(6), groups[6].name, groups[6]), new LevelRec(0x10C88, 83, getLayoutWidth(7), getLayoutHeight(7), getLayoutAddr(7), groups[7].name, groups[7]), new LevelRec(0x10DB3, 53, getLayoutWidth(8), getLayoutHeight(8), getLayoutAddr(8), groups[8].name, groups[8]), new LevelRec(0x10EA1, 45, getLayoutWidth(9), getLayoutHeight(9), getLayoutAddr(9), groups[9].name, groups[9]), new LevelRec(0x10FED, 71, getLayoutWidth(10), getLayoutHeight(10), getLayoutAddr(10), groups[10].name, groups[10]), }); }
public static void setBlocks(int tileId, ObjRec[] blocks) { int bc = ConfigScript.getBlocksCount(tileId); int palAddr = getPalBytesAddr(); byte[] blocksData = new byte[blocks.Length * 4]; for (int i = 0; i < blocks.Length; i++) { blocksData[i * 4 + 0] = (byte)blocks[i].indexes[0]; blocksData[i * 4 + 1] = (byte)blocks[i].indexes[1]; blocksData[i * 4 + 2] = (byte)blocks[i].indexes[2]; blocksData[i * 4 + 3] = (byte)blocks[i].indexes[3]; } Utils.writeDataToUnalignedArrays(blocksData, Globals.romdata, blockAddr1, blockAddr2, blockAddr3, blockAddr4, bc); for (int i = 0; i < blocks.Length; i++) { Globals.romdata[palAddr + i] = (byte)blocks[i].palBytes[0]; } }
//---------------------------------------------------------------------------- public ObjRec[] getBlocks(int tileId) { var blocks = Utils.readBlocksFromAlignedArrays(Globals.romdata, ConfigScript.getTilesAddr(tileId), ConfigScript.getBlocksCount(tileId), false); //decode palByte int palInfoCount = ConfigScript.getBlocksCount(tileId) / 4; var palInfo = new byte[palInfoCount]; for (int i = 0; i < palInfoCount; i++) { palInfo[i] = Globals.romdata[ConfigScript.getPalBytesAddr(tileId) + i]; } for (int i = 0; i < blocks.Length; i++) { var palInfoByte = palInfo[i / 4]; int parByteNo = i % 4; blocks[i].palBytes[0] = (byte)((palInfoByte >> parByteNo * 2) & 3); } return(blocks); }
private int[] prepareLayerData() { int layoutNo = cbLayout.SelectedIndex; var layout = ConfigScript.getLayout(layoutNo); int scrNo = findNonZeroScrNo(layout); int width = formMain.screens[scrNo].width; int height = formMain.screens[scrNo].height; int layerWidth = layout.width * width; int layerHeight = layout.height * height; int[] layerData = new int[layerWidth * layerHeight]; for (int sy = 0; sy < layout.height; sy++) { for (int sx = 0; sx < layout.width; sx++) { int scrIndex = sy * layout.width + sx; scrNo = calcScrNo(layout, scrIndex); if (scrNo >= 0 && scrNo < formMain.screens.Length) { var curScreen = formMain.screens[scrNo]; var curScreenData = curScreen.layers[0].data; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int index = y * width + x; int tileNo = ConfigScript.getBigTileNoFromScreen(curScreenData, index); int lx = sx * width + x; int ly = sy * height + y; layerData[ly * layerWidth + lx] = tileNo + 1; //Tiled indexes start from 1, not 0 } } } } } return(layerData); }
private void bttExportJson_Click(object sender, EventArgs e) { int[][] screens, screens2; loadScreens(out screens, out screens2); SaveScreensCount.ExportMode = true; SaveScreensCount.Filename = "exportedScreens.json"; var f = new SaveScreensCount(); f.Text = "Export json"; formMain.subeditorOpen(f, (ToolStripItem)sender, true); if (SaveScreensCount.Result) { if (SaveScreensCount.Count <= 0) { MessageBox.Show("Screens count value must be greater than 0", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int saveLastIndex = SaveScreensCount.First + SaveScreensCount.Count; if (saveLastIndex > screens.Length) { MessageBox.Show(string.Format("First screen + Screens Count value ({0}) must be less than Total Screen Count in the game ({1}", saveLastIndex, screens.Length), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int first = SaveScreensCount.First; int WIDTH = ConfigScript.getScreenWidth(formMain.LevelNoForScreens); int HEIGHT = ConfigScript.getScreenHeight(formMain.LevelNoForScreens); int screenCount = SaveScreensCount.Count; var screenParams = new { Width = WIDTH, Height = HEIGHT, Screens = new int[screenCount][] }; using (TextWriter tw = new StreamWriter(SaveScreensCount.Filename)) { for (int i = 0; i < screenCount; i++) { screenParams.Screens[i] = screens[first + i]; } tw.WriteLine(JsonConvert.SerializeObject(screenParams)); } } }
public List <ObjectList> getObjectsDt2(int levelNo) { LevelRec lr = ConfigScript.getLevelRec(levelNo); int objCount = lr.objCount, addr = lr.objectsBeginAddr; var objects = new List <ObjectRec>(); int objectsReaded = 0; int currentHeight = 0; while (objectsReaded < objCount) { byte command = Globals.romdata[addr]; if (command == 0xFF) { currentHeight = Globals.romdata[addr + 1]; if (currentHeight == 0xFF) { break; } addr += 2; } else { byte v = Globals.romdata[addr + 2]; byte xbyte = Globals.romdata[addr + 0]; byte ybyte = Globals.romdata[addr + 1]; byte sx = (byte)(xbyte >> 5); byte x = (byte)((xbyte & 0x1F) << 3); byte sy = (byte)currentHeight; byte y = ybyte; var obj = new ObjectRec(v, sx, sy, x, y); objects.Add(obj); objectsReaded++; addr += 3; } } return(new List <ObjectList> { new ObjectList { objects = objects, name = "Objects" } }); }
public static void setBigBlocks(int bigTileIndex, BigBlock[] bigBlockIndexes) { var bigBlocksAddr = ConfigScript.getBigTilesAddr(0, bigTileIndex); var data = Utils.linearizeBigBlocks(bigBlockIndexes); int size = data.Length; int addr = ConfigScript.getBigTilesAddr(0, bigTileIndex); for (int i = 0; i < size; i++) { Globals.romdata[addr + i] = data[i]; } //save pal bytes for (int i = 0; i < bigBlockIndexes.Length; i++) { var bb = bigBlockIndexes[i] as BigBlockWithPal; int palByte = bb.palBytes[0] | bb.palBytes[1] << 2 | bb.palBytes[2] << 4 | bb.palBytes[3] << 6; Globals.romdata[ConfigScript.getPalBytesAddr(bigTileIndex) + i] = (byte)palByte; } }
public void GeneratesGenericConstructors() { // Given Dictionary <string, string> memberNames = new Dictionary <string, string>(); string expected = $@" public static Wyam.Core.Tests.Configuration.ConfigScriptTests.GenericModule<T> GenericModule<T>(T input) {{ return new Wyam.Core.Tests.Configuration.ConfigScriptTests.GenericModule<T>(input); }} public static Wyam.Core.Tests.Configuration.ConfigScriptTests.GenericModule<T> GenericModule<T>(System.Action<T> input) {{ return new Wyam.Core.Tests.Configuration.ConfigScriptTests.GenericModule<T>(input); }}"; // When string generated = ConfigScript.GenerateModuleConstructorMethods(typeof(GenericModule <>), memberNames); // Then Assert.AreEqual(expected, generated); }
public bool setPrizesCad2(int levelNo, List <ObjectList> objLists) { LevelRec lr = ConfigScript.getLevelRec(levelNo); int addrBase = lr.objectsBeginAddr; int objCount = lr.objCount; var objects = objLists[0].objects; for (int i = 0; i < objects.Count; i++) { var obj = objects[i]; Globals.romdata[addrBase + i * 2 + 0] = (byte)((obj.x / 32) | (obj.sx << 4)); Globals.romdata[addrBase + i * 2 + 1] = (byte)((obj.y / 32) | (obj.type << 4)); } for (int i = objects.Count; i < objCount; i++) { Globals.romdata[addrBase + i * 2 + 0] = 0xFF; Globals.romdata[addrBase + i * 2 + 1] = 0xFF; } return(true); }
public static void setBigBlocksTT(int bigTileIndex, BigBlock[] bigBlockIndexes) { var bigBlocksAddr = ConfigScript.getBigTilesAddr(0, bigTileIndex); for (int v = 0; v < bigBlockIndexes.Length; v++) { var bb = bigBlockIndexes[v] as BigBlockWithPal; var i0 = bb.indexes[0]; var i1 = bb.indexes[1]; var i2 = bb.indexes[2]; var i3 = bb.indexes[3]; Globals.romdata[bigBlocksAddr + v * 4 + 0] = (byte)i0; Globals.romdata[bigBlocksAddr + v * 4 + 1] = (byte)i2; Globals.romdata[bigBlocksAddr + v * 4 + 2] = (byte)i1; Globals.romdata[bigBlocksAddr + v * 4 + 3] = (byte)i3; int palByte = bb.palBytes[0] | bb.palBytes[1] << 2 | bb.palBytes[2] << 4 | bb.palBytes[3] << 6; setTTSmallBlocksColorByte(v, (byte)palByte); } }
public static List <ObjectList> getObjectsNemo(int levelNo) { LevelRec lr = ConfigScript.getLevelRec(levelNo); int objCount = lr.objCount, addr = lr.objectsBeginAddr; var objects = new List <ObjectRec>(); var objScreenAddr = ConfigScript.getPalBytesAddr(); //not palBytes, but object sx/sy decode int screenIndex = 0; for (int i = 0; i < objCount; i++) { //read, how many objects at current screen while (true) { int curIndex = Globals.romdata[objScreenAddr]; int nextIndex = Globals.romdata[objScreenAddr + 1]; if (i < nextIndex) { break; } objScreenAddr++; screenIndex++; } int sx = screenIndex % lr.width; int sy = screenIndex / lr.width; // int v = Globals.romdata[addr + i * 2 + 0]; int xy = Globals.romdata[addr + i * 2 + 1]; int x = (xy >> 4) * 16; int y = (xy & 0x0F) * 16; var obj = new ObjectRec(v, sx, sy, x, y); objects.Add(obj); //hack for .NET optimizer(?). It fails to forever loop, if no this string var a = i.ToString(); } return(new List <ObjectList> { new ObjectList { objects = objects, name = "Objects" } }); }
public void GeneratesCorrectScript(string input, string output) { // Given HashSet <Type> moduleTypes = new HashSet <Type> { typeof(Content) }; string[] namespaces = Array.Empty <string>(); string expected = $@" public class ConfigScript : ConfigScriptBase {{ public ConfigScript(IEngine engine) : base(engine) {{ }} public override void Run() {{ {output} }} public static Wyam.Core.Modules.Contents.Content Content(object content) {{ return new Wyam.Core.Modules.Contents.Content(content); }} public static Wyam.Core.Modules.Contents.Content Content(Wyam.Common.Configuration.ContextConfig content) {{ return new Wyam.Core.Modules.Contents.Content(content); }} public static Wyam.Core.Modules.Contents.Content Content(Wyam.Common.Configuration.DocumentConfig content) {{ return new Wyam.Core.Modules.Contents.Content(content); }} public static Wyam.Core.Modules.Contents.Content Content(params Wyam.Common.Modules.IModule[] modules) {{ return new Wyam.Core.Modules.Contents.Content(modules); }}}}"; // When string actual = ConfigScript.Generate(null, input, moduleTypes, namespaces); // Then Assert.AreEqual(expected, actual); }
//make capcom screen image public Bitmap makeScreen(int scrNo, int levelNo, int videoNo, int bigBlockNo, int blockNo, int palleteNo, bool withBorders = true) { if (scrNo < 0) { return(VideoHelper.emptyScreen((int)(ConfigScript.getScreenWidth(levelNo) * 32), (int)(ConfigScript.getScreenHeight(levelNo) * 32))); } var bigBlocks = makeBigBlocks(videoNo, bigBlockNo, blockNo, palleteNo, MapViewType.Tiles, MapViewType.Tiles); //var bigBlocks = makeBigBlocks(videoNo, bigBlockNo, blockNo, palleteNo, MapViewType.ObjType,MapViewType.Tiles, withBorders); int[] indexes = Globals.getScreen(ConfigScript.screensOffset[levelNo], scrNo); int scrW = ConfigScript.getScreenWidth(0); //zero as screenNoForLevel int scrH = ConfigScript.getScreenHeight(0); //capcom hardcode var blockLayer1 = new BlockLayer() { screens = new int[1][] { indexes }, showLayer = true, blockWidth = 32, blockHeight = 32 }; return(new Bitmap(MapEditor.ScreenToImage(bigBlocks, new BlockLayer[] { blockLayer1 }, 0, 2.0f, false, 0, 0, scrW, scrH))); }
//blocks are intersects. public static ObjRec[] getBlocksLinear4x2withoutAttribT(int blockIndex) { var singleBlocks = Utils.readBlocksLinear(Globals.romdata, ConfigScript.getTilesAddr(blockIndex), 2, 2, ConfigScript.getBlocksCount(blockIndex) + 1, false, true); var newBlocks = new ObjRec[ConfigScript.getBlocksCount(blockIndex)]; for (int i = 0; i < newBlocks.Length; i++) { var indexes = new int[8]; var palBytes = new int[2]; indexes[0] = singleBlocks[i].indexes[0]; indexes[1] = singleBlocks[i].indexes[1]; indexes[2] = singleBlocks[i + 1].indexes[0]; indexes[3] = singleBlocks[i + 1].indexes[1]; indexes[4] = singleBlocks[i].indexes[2]; indexes[5] = singleBlocks[i].indexes[3]; indexes[6] = singleBlocks[i + 1].indexes[2]; indexes[7] = singleBlocks[i + 1].indexes[3]; newBlocks[i] = new ObjRec(4, 2, 0, indexes, palBytes); } return(newBlocks); }
public static void setBlocks(int tileId, ObjRec[] blocksData) { int addr = ConfigScript.getTilesAddr(tileId); int count = ConfigScript.getBlocksCount(tileId); var palAddr = ConfigScript.getPalBytesAddr(tileId); Utils.writeBlocksLinear(blocksData, Globals.romdata, addr, count, false, false); int palInfoCount = ConfigScript.getBlocksCount(tileId) / 4; for (int i = 0; i < palInfoCount; i++) { var palInfoByte = (blocksData[i * 4 + 3].palBytes[0] << 0) | (blocksData[i * 4 + 2].palBytes[0] << 2) | (blocksData[i * 4 + 1].palBytes[0] << 4) | (blocksData[i * 4 + 0].palBytes[0] << 6); Globals.romdata[palAddr + i] = (byte)palInfoByte; } }
private void bttExportJson_Click(object sender, EventArgs e) { var screens = ConfigScript.loadScreens(); SaveScreensCount.exportMode = true; SaveScreensCount.filename = "exportedScreens.json"; var f = new SaveScreensCount(); f.Text = "Export json"; formMain.subeditorOpen(f, (ToolStripItem)sender, true); if (SaveScreensCount.result) { if (SaveScreensCount.count <= 0) { MessageBox.Show("Screens count value must be greater than 0", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int saveLastIndex = SaveScreensCount.first + SaveScreensCount.count; int screensCount = screens.Length; if (saveLastIndex > screensCount) { MessageBox.Show(string.Format("First screen + Screens Count value ({0}) must be less than Total Screen Count in the game ({1}", saveLastIndex, screensCount), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int first = SaveScreensCount.first; int screenCount = SaveScreensCount.count; var screenParams = new { Screens = new CadEditor.Screen[screenCount] }; using (TextWriter tw = new StreamWriter(SaveScreensCount.filename)) { for (int i = 0; i < screenCount; i++) { screenParams.Screens[i] = screens[first + i]; } tw.WriteLine(JsonConvert.SerializeObject(screenParams)); } } }
private void btExport_Click(object sender, EventArgs e) { try { if (sfSave.ShowDialog() != DialogResult.OK) { return; } var imName = Path.ChangeExtension(sfSave.FileName, "png"); var bigBlockImage = prepareImage(imName); var base64LayerData = toZippedBase64String(prepareLayerData()); int layoutNo = cbLayout.SelectedIndex; var layout = ConfigScript.getLayout(layoutNo); int scrNo = findNonZeroScrNo(layout); int width = formMain.screens[scrNo].width; int height = formMain.screens[scrNo].height; var bigBlocksImages = formMain.bigBlocks; int blockWidth = bigBlocksImages[0].Width; int blockHeight = bigBlocksImages[0].Height; int layerWidth = layout.width * width; int layerHeight = layout.height * height; using (var f = File.CreateText(sfSave.FileName)) { f.Write(tmxTemplate(layerWidth, layerHeight, blockWidth, blockHeight, imName, bigBlockImage.Width, bigBlockImage.Height, base64LayerData)); } MessageBox.Show("Export done!"); Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
public BigBlock[] getBigBlocks(int bigTileIndex) { int count = ConfigScript.getBigBlocksCount(0, bigTileIndex); var bigBlocks = new BigBlockWithPal[count]; var bigBlocksAddr = ConfigScript.getBigTilesAddr(0, bigTileIndex); for (int i = 0; i < count; i++) { var bb = new BigBlockWithPal(2, 2); bb.indexes[0] = Globals.romdata[bigBlocksAddr + i * 5 + 0] & 0x3f; bb.indexes[2] = Globals.romdata[bigBlocksAddr + i * 5 + 1] & 0x3f; bb.indexes[1] = Globals.romdata[bigBlocksAddr + i * 5 + 2] & 0x3f; bb.indexes[3] = Globals.romdata[bigBlocksAddr + i * 5 + 3] & 0x3f; int palByte = Globals.romdata[bigBlocksAddr + i * 5 + 4]; bb.palBytes[0] = palByte >> 0 & 0x3; bb.palBytes[1] = palByte >> 2 & 0x3; bb.palBytes[2] = palByte >> 4 & 0x3; bb.palBytes[3] = palByte >> 6 & 0x3; bigBlocks[i] = bb; } return(bigBlocks); }