QUOTE(fatimid08 @ Nov 20 2006, 09:54 AM)
1. The two first questions relate to SFmpqapi:
- How does priority in archives work?
If two archives have the same file in them (StarDat.mpq and BrooDat.mpq for example) and one has 0 priority, and the other 1 priority (As opened by SFileOpenArchive), when I specify the filename of that particular file and the SFILE_SEARCH_ALL_OPEN flag, it takes the file in the 1 priority archive right? (I'm working on a map editor, and I want to be able to load a mod and load the files it replaces in the StarDat and BrooDat mpqs if they exist, so it becomes possible to load modded .dat files, grps, terrain files, and any other thing I might implement)
Yeah, that's how it works. You can also just pass no archive handle (NULL) to the function instead or use SFileOpenFile.
QUOTE
- Now about listfiles:
If I open an archive that doesn't have a listfile with the MOAU_MAINTAIN_LISTFILE flag, and I add one right after, does it maintain the listfile I just added when I do modifications or not? Does it check if all the files are represented in the file?
Hmm, I think it probably should work to do that. You will need to test it out yourself to be sure, though.
QUOTE
2. Now the GRPapi question:
I don't get how to use the custom drawing functions, if I want to replace every pixel that refers to the index 8 in the color palette by another one, which of the GetPixel/SetPixel function does that, and how exactly do the arguments to those functions work? (how the integer for color is set up for example)
The GetPixel function is only used by GRPapi when you specify the alpha blending flag when calling DrawGrp. In my own programs when I use a custom SetPixel to write to a buffer instead of the screen I often use a custom GetPixel function anyway for reading from the buffer that the custom SetPixel function would write to, just to make it easier and give it a more consistent look in the code. (although, I might not actually set it in GRPapi with SetFunctionGetPixel if I'm not using alpha blending) I'll give an example at the end of this post.
QUOTE
To tell GRPapi to use the custom function, I have to pass a function pointer to the SetFunctionGetPixel/SetFunctionSetPixel functions right?
[right][snapback]592099[/snapback][/right]
Yes, that is how it works.
Here is an example of custom GetPixel and SetPixel functions which read from and write to a buffer. I'll leave out the parts for opening files and just include the drawing part.
CODE
struct BUFFERINFO {
WORD nWidth;
WORD nHeight;
signed short *pBuffer;
WORD nFrame;
};
// This won't get called in this example, it is just for a sample reading function
COLORREF WINAPI ReadPixelFromBuffer(BUFFERINFO *pBI, int X, int Y)
{
return pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X];
}
void WINAPI WritePixelToBuffer(BUFFERINFO *pBI, int X, int Y, COLORREF clrColor)
{
pBI->pBuffer[(pBI->nFrame * pBI->nWidth * pBI->nHeight) + (Y * pBI->nWidth) + X] = (signed short)clrColor;
}
// For this example, I'll assume the caller has already set up everything in lpBuffer
void MyDrawingFunction(HANDLE hGrp, BUFFERINFO lpBuffer, DWORD *dwPalette)
{
int x, y;
// Prefill buffer with some non-color value to distinguish transparent pixels
for (y = 0; y < lpBuffer->nHeight; y++) {
for (x = 0; x < lpBuffer->nWidth; x++) {
WritePixelToBuffer(lpBuffer, x, y, (COLORREF)-1);
}
}
SetFunctionGetPixel((GETPIXELPROC)ReadPixelFromBuffer);
SetFunctionSetPixel((SETPIXELPROC)WritePixelToBuffer);
DrawGrp(hGrp, (HDC)lpBuffer, 0, 0, lpBuffer->nFrame, dwPalette, USE_INDEX, 0);
}
If you want/need an example that just draws to the screen, I'll post that later.