public ViewModel() { List <Venta> Ventas = new List <Venta>(); TraerDatosCharts(); palette = PaletteLoader.LoadPalette("#25a966", "#F13D45", "#45B6F1", "#F7EC42", "#975ba5", "#f45a4e"); }
public override ColorPalette Load(string filePath, params object[] param) { var pal = PaletteLoader.FromResFile(filePath); if (pal == null) { Logger.TraceEvent(TraceEventType.Error, 0, $"Failed to load palette: {filePath}"); } this.GameObject = pal; return(pal); }
public void ReadAnimData(int auxPalIndex) { int[] AnimX = new int[390]; int[] AnimY = new int[390]; int[] AnimXY = new int[776];//For UW2 int[] UW2_X = { 35, 36, 37, -1, 39, 40, 41, 42, -1, 44, 45, 46, -1, 48, 49, 50, 51, -1, -1, -1, -1, -1, 57, 58, 59, -1, -1, 62, 63, 64, -1, 132, 133, 134, -1, 136, 137, 138, 139, -1, 141, 142, 143, -1, 145, 146, 147, 148, -1, -1, -1, -1, -1, 154, 155, 156, -1, -1, 159, 160, 161, -1, 229, 230, 231, -1, 233, 234, 235, 236, -1, 238, 239, 240, -1, 242, 243, 244, 245, -1, -1, -1, -1, -1, 251, 252, 253, -1, -1, 256, 257, 258, -1, -1, -1, -1, -1, 330, 331, 332, -1, -1, 335, -1, 337, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 423, 424, 425, -1, 427, 428, 429, 430, -1, 432, 433, 434, -1, 436, 437, 438, 439, -1, -1, -1, -1, -1, 446, 447, 448, -1, -1, -1, 450, 451, 452, 520, 521, 522, -1, 524, 525, 526, 527, -1, 529, 530, 531, -1, 533, 534, 535, 536, -1, -1, -1, -1, -1, 542, 543, 544, -1, -1, 547, 548, 549, -1, 617, 618, 619, -1, 621, 622, 623, 624, -1, 626, 627, 628, -1, 630, 631, 632, 633, -1, -1, -1, -1, -1, 639, 640, 641, -1, -1, 644, 645, 646, -1, -1, -1, -1, -1, 718, 719, 720, -1, 723, -1, 725, -1, -1 }; int[] UW2_Y = { 66, 67, 68, -1, 70, 71, 72, 73, -1, 75, 76, 77, -1, 79, 80, 81, 82, -1, -1, -1, -1, -1, 88, 89, 90, -1, -1, 93, 94, 95, -1, 163, 164, 165, -1, 167, 168, 169, 170, -1, 172, 173, 174, -1, 176, 177, 178, 179, -1, -1, -1, -1, -1, 185, 186, 187, -1, -1, 190, 191, 192, -1, 260, 261, 262, -1, 264, 265, 266, 267, -1, 269, 270, 271, -1, 273, 274, 275, 276, -1, -1, -1, -1, -1, 282, 283, 284, -1, -1, 287, 288, 289, -1, -1, -1, -1, -1, 361, 362, 363, -1, -1, 366, -1, 368, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 454, 455, 456, -1, 458, 459, 460, 461, -1, 463, 464, 465, -1, 467, 468, 469, 470, -1, -1, -1, -1, -1, 476, 477, 478, -1, -1, -1, 481, 482, 483, 551, 552, 553, -1, 555, 556, 557, 558, -1, 560, 561, 562, -1, 564, 565, 566, 567, -1, -1, -1, -1, -1, 573, 574, 575, -1, -1, 578, 579, 580, -1, 648, 649, 650, -1, 652, 653, 654, 655, -1, 657, 658, 659, -1, 661, 662, 663, 664, -1, -1, -1, -1, -1, 670, 671, 672, -1, -1, 675, 676, 677, -1, -1, -1, -1, -1, 749, 750, 751, -1, 754, -1, 756, -1, -1 }; string datfile = "DATA" + sep + "WEAPONS.DAT"; string cmfile = "DATA" + sep + "WEAPONS.CM"; string grfile = "DATA" + sep + "WEAPONS.GR"; if (_RES == GAME_UW2) { datfile = "DATA" + sep + "WEAP.DAT"; cmfile = "DATA" + sep + "WEAP.CM"; grfile = "DATA" + sep + "WEAP.GR"; } char[] AnimData; char[] textureFile; int offset = 0; int GroupSize = 28; //28 for uw1 int MaxHeight = 112; int MaxWidth = 172; if (_RES == GAME_UW2) { MaxHeight = 128; MaxWidth = 208; } int add_ptr = 0; int alpha = 0; DataLoader.ReadStreamFile(BasePath + datfile, out AnimData); DataLoader.ReadStreamFile(BasePath + grfile, out textureFile); if (_RES != GAME_UW2) { GroupSize = 28; for (int i = 0; i < 8; i++) { for (int j = 0; j < GroupSize; j++) { AnimX[j + offset] = (int)DataLoader.getValAtAddress(AnimData, add_ptr++, 8); } for (int j = 0; j < GroupSize; j++) { AnimY[j + offset] = (int)DataLoader.getValAtAddress(AnimData, add_ptr++, 8); } offset = offset + GroupSize; } } else { //In UW2 I just read the values into one array for (int i = 0; i <= AnimData.GetUpperBound(0); i++) { AnimXY[i] = (int)DataLoader.getValAtAddress(AnimData, add_ptr++, 8); } } add_ptr = 0; int NoOfTextures = textureFile[2] << 8 | textureFile[1]; if (_RES == GAME_UW2) { NoOfTextures = 230; } ImageCache = new Texture2D[NoOfTextures + 1]; for (int i = 0; i < NoOfTextures; i++) { long textureOffset = DataLoader.getValAtAddress(textureFile, (i * 4) + 3, 32); int BitMapWidth = (int)DataLoader.getValAtAddress(textureFile, textureOffset + 1, 8); int BitMapHeight = (int)DataLoader.getValAtAddress(textureFile, textureOffset + 2, 8); int datalen; Palette auxpal = PaletteLoader.LoadAuxilaryPal(Loader.BasePath + cmfile, GameWorldController.instance.palLoader.Palettes[PaletteNo], auxPalIndex); char[] imgNibbles; char[] outputImg; char[] srcImg; datalen = (int)DataLoader.getValAtAddress(textureFile, textureOffset + 4, 16); imgNibbles = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, datalen * 2)]; textureOffset = textureOffset + 6; //Start of raw data. copyNibbles(textureFile, ref imgNibbles, datalen, textureOffset); //LoadAuxilaryPal(auxPalPath, auxpal, pal, auxPalIndex); srcImg = new char[BitMapWidth * BitMapHeight]; outputImg = new char[MaxWidth * MaxHeight]; //Debug.Log("i= " + i + " datalen= " + datalen); if (datalen >= 6) { srcImg = DecodeRLEBitmap(imgNibbles, datalen, BitMapWidth, BitMapHeight, 4); } //Paste source image into output image. int ColCounter = 0; int RowCounter = 0; int cornerX; // = AnimX[i]; int cornerY; // = AnimY[i]; if (_RES != GAME_UW2) { cornerX = AnimX[i]; cornerY = AnimY[i]; } else { //Read from XY if (UW2_X[i] != -1) { cornerX = AnimXY[UW2_X[i]]; cornerY = AnimXY[UW2_Y[i]]; } else { cornerX = 0; cornerY = BitMapHeight; } } if ((_RES == GAME_UW1) || ((_RES == GAME_UW2) && (UW2_X[i] != -1))) //Only create if UW1 image or a valid uw2 one { bool ImgStarted = false; for (int y = 0; y < MaxHeight; y++) { for (int x = 0; x < MaxWidth; x++) { if ((cornerX + ColCounter == x) && (MaxHeight - cornerY + RowCounter == y) && (ColCounter < BitMapWidth) && (RowCounter < BitMapHeight)) { //the pixel from the source image is here ImgStarted = true; outputImg[x + (y * MaxWidth)] = srcImg[ColCounter + (RowCounter * BitMapWidth)]; ColCounter++; } else { alpha = 0; //0 outputImg[x + (y * MaxWidth)] = (char)alpha; } } if (ImgStarted == true) { //New Row on the src image RowCounter++; ColCounter = 0; } } ImageCache[i] = Image(outputImg, 0, MaxWidth, MaxHeight, "name_goes_here", auxpal, true); } } }
public override Texture2D LoadImageAt(int index, bool Alpha) { if (ImageFileDataLoaded == false) { if (!LoadImageFile()) { return(base.LoadImageAt(index)); } } else { if (ImageCache[index] != null) { return(ImageCache[index]); } } long imageOffset = DataLoader.getValAtAddress(ImageFileData, (index * 4) + 3, 32); if (imageOffset >= ImageFileData.GetUpperBound(0)) { //Image out of range return(base.LoadImageAt(index)); } int BitMapWidth = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 1, 8); int BitMapHeight = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 2, 8); int datalen; Palette auxpal; int auxPalIndex; char[] imgNibbles; char[] outputImg; switch (DataLoader.getValAtAddress(ImageFileData, imageOffset, 8)) //File type { case 0x4: //8 bit uncompressed { imageOffset = imageOffset + 5; ImageCache[index] = Image(ImageFileData, imageOffset, BitMapWidth, BitMapHeight, "name_goes_here", GameWorldController.instance.palLoader.Palettes[PaletteNo], Alpha); return(ImageCache[index]); } case 0x8: //4 bit run-length { if (!useOverrideAuxPalIndex) { auxPalIndex = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 3, 8); } else { auxPalIndex = OverrideAuxPalIndex; } datalen = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 4, 16); imgNibbles = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, (datalen + 5) * 2)]; imageOffset = imageOffset + 6; //Start of raw data. copyNibbles(ImageFileData, ref imgNibbles, datalen, imageOffset); auxpal = PaletteLoader.LoadAuxilaryPal(Loader.BasePath + AuxPalPath, GameWorldController.instance.palLoader.Palettes[PaletteNo], auxPalIndex); outputImg = DecodeRLEBitmap(imgNibbles, datalen, BitMapWidth, BitMapHeight, 4); //rawOut.texture= Image(outputImg,0, BitMapWidth, BitMapHeight,"name_goes_here",auxpal,true); ImageCache[index] = Image(outputImg, 0, BitMapWidth, BitMapHeight, "name_goes_here", auxpal, Alpha); return(ImageCache[index]); } case 0xA: //4 bit uncompressed//Same as above??? { if (!useOverrideAuxPalIndex) { auxPalIndex = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 3, 8); } else { auxPalIndex = OverrideAuxPalIndex; } datalen = (int)DataLoader.getValAtAddress(ImageFileData, imageOffset + 4, 16); imgNibbles = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, (5 + datalen) * 2)]; imageOffset = imageOffset + 6; //Start of raw data. copyNibbles(ImageFileData, ref imgNibbles, datalen, imageOffset); auxpal = PaletteLoader.LoadAuxilaryPal(BasePath + AuxPalPath, GameWorldController.instance.palLoader.Palettes[PaletteNo], auxPalIndex); ImageCache[index] = Image(imgNibbles, 0, BitMapWidth, BitMapHeight, "name_goes_here", auxpal, Alpha); return(ImageCache[index]); } //break; default: //Check to see if the file is panels.gr if (pathGR[FileToLoad].ToUpper().EndsWith("PANELS.GR")) { BitMapWidth = 83; //getValAtAddress(textureFile, textureOffset + 1, 8); BitMapHeight = 114; // getValAtAddress(textureFile, textureOffset + 2, 8); if (_RES == "UW2") { BitMapWidth = 79; BitMapHeight = 112; } imageOffset = DataLoader.getValAtAddress(ImageFileData, (index * 4) + 3, 32); ImageCache[index] = Image(ImageFileData, imageOffset, BitMapWidth, BitMapHeight, "name_goes_here", GameWorldController.instance.palLoader.Palettes[PaletteNo], Alpha); return(ImageCache[index]); } break; } return(new Texture2D(2, 2)); }
public void RunArtLoaderGR() { if (grBufferLoaded == false) { if (!DataLoader.ReadStreamFile(pathGR, out grBuffer)) { return; } else { grBufferLoaded = true; } } long imageOffset = DataLoader.getValAtAddress(grBuffer, (grIndex * 4) + 3, 32); int BitMapWidth = (int)DataLoader.getValAtAddress(grBuffer, imageOffset + 1, 8); int BitMapHeight = (int)DataLoader.getValAtAddress(grBuffer, imageOffset + 2, 8); int datalen; Palette auxpal; int auxPalIndex; char[] imgNibbles; char[] outputImg; switch (DataLoader.getValAtAddress(grBuffer, imageOffset, 8)) //File type { case 0x4: //8 bit uncompressed { imageOffset = imageOffset + 5; sprt.sprite = Sprite.Create(Image(grBuffer, imageOffset, BitMapWidth, BitMapHeight, "name_goes_here", palLoader.Palettes[pal], true), new Rect(0f, 0f, BitMapWidth, BitMapHeight), new Vector2(0.5f, 0.5f)); break; } case 0x8: //4 bit run-length { auxPalIndex = (int)DataLoader.getValAtAddress(grBuffer, imageOffset + 3, 8); datalen = (int)DataLoader.getValAtAddress(grBuffer, imageOffset + 4, 16); imgNibbles = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, datalen * 2)]; imageOffset = imageOffset + 6; //Start of raw data. copyNibbles(grBuffer, ref imgNibbles, datalen, imageOffset); auxpal = PaletteLoader.LoadAuxilaryPal(auxPalPath, palLoader.Palettes[pal], auxPalIndex); outputImg = DecodeRLEBitmap(imgNibbles, datalen, BitMapWidth, BitMapHeight, 4); //rawOut.texture= Image(outputImg,0, BitMapWidth, BitMapHeight,"name_goes_here",auxpal,true); sprt.sprite = Sprite.Create(Image(outputImg, 0, BitMapWidth, BitMapHeight, "name_goes_here", auxpal, true), new Rect(0f, 0f, BitMapWidth, BitMapHeight), new Vector2(0.5f, 0.5f)); break; } case 0xA: //4 bit uncompressed//Same as above??? { auxPalIndex = (int)DataLoader.getValAtAddress(grBuffer, imageOffset + 3, 8); datalen = (int)DataLoader.getValAtAddress(grBuffer, imageOffset + 4, 16); imgNibbles = new char[Mathf.Max(BitMapWidth * BitMapHeight * 2, datalen * 2)]; imageOffset = imageOffset + 6; //Start of raw data. copyNibbles(grBuffer, ref imgNibbles, datalen, imageOffset); auxpal = PaletteLoader.LoadAuxilaryPal(auxPalPath, palLoader.Palettes[pal], auxPalIndex); sprt.sprite = Sprite.Create(Image(imgNibbles, 0, BitMapWidth, BitMapHeight, "name_goes_here", auxpal, true), new Rect(0f, 0f, BitMapWidth, BitMapHeight), new Vector2(0.5f, 0.5f)); break; } break; default: //Check to see if the file is panels.gr if (pathGR.ToUpper().EndsWith("PANELS.GR")) { BitMapWidth = 83; //getValAtAddress(textureFile, textureOffset + 1, 8); BitMapHeight = 114; // getValAtAddress(textureFile, textureOffset + 2, 8); //if ( _RES== UW2) // { // BitMapWidth=79; // BitMapHeight = 112; // } imageOffset = DataLoader.getValAtAddress(grBuffer, (grIndex * 4) + 3, 32); sprt.sprite = Sprite.Create(Image(grBuffer, imageOffset, BitMapWidth, BitMapHeight, "name_goes_here", palLoader.Palettes[pal], true), new Rect(0f, 0f, BitMapWidth, BitMapHeight), new Vector2(0.5f, 0.5f)); } return; } }
private static _Palettes generatePaletteSet(int size, Palette.Kind type) { PaletteLoader.generatePalettes(type, size); return(new _Palettes(PaletteLoader.palettes.ToArray(), type, size)); }