mirror of
https://github.com/jeremysrand/md2teach.git
synced 2025-04-27 23:40:33 +00:00
Implement some changes based on feedback from Kelvin:
- Add the window position resource first. That way, if the style resource needs to grow, the window position resource will not need to be re-written. - Do not dispose of a handle passed to the resource manager through AddResource. The resource is owned by the resource manager after that. - No need to make the resource as changed when adding a resource. It is implied. Also, rename the disk image from Distribution to md2teach.
This commit is contained in:
parent
f1fd4a7bd3
commit
ff039e5ee0
Binary file not shown.
@ -177,13 +177,6 @@ static int writeResources(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddResource(styleHandle(), resChanged, rStyleBlock, STYLE_BLOCK_NUM);
|
|
||||||
if (toolerror()) {
|
|
||||||
fprintf(stderr, "%s: Unable to add style resource to file %s, toolerror=0x%x\n", commandName, outputFileName.text, toolerror());
|
|
||||||
result = 1;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
windowPosHandle = NewHandle(sizeof(windowPos), userid(), attrNoPurge, NULL);
|
windowPosHandle = NewHandle(sizeof(windowPos), userid(), attrNoPurge, NULL);
|
||||||
if (toolerror()) {
|
if (toolerror()) {
|
||||||
fprintf(stderr, "%s: Unable to allocate memory for window resource for file %s, toolerror=0x%x\n", commandName, outputFileName.text, toolerror());
|
fprintf(stderr, "%s: Unable to allocate memory for window resource for file %s, toolerror=0x%x\n", commandName, outputFileName.text, toolerror());
|
||||||
@ -193,13 +186,19 @@ static int writeResources(void)
|
|||||||
HLock(windowPosHandle);
|
HLock(windowPosHandle);
|
||||||
PtrToHand((Pointer)windowPos, windowPosHandle, sizeof(windowPos));
|
PtrToHand((Pointer)windowPos, windowPosHandle, sizeof(windowPos));
|
||||||
|
|
||||||
AddResource(windowPosHandle, resChanged, R_WINDOW_POSITION, WINDOW_POSITION_NUM);
|
AddResource(windowPosHandle, 0, R_WINDOW_POSITION, WINDOW_POSITION_NUM);
|
||||||
if (toolerror()) {
|
if (toolerror()) {
|
||||||
fprintf(stderr, "%s: Unable to add window position resource to file %s, toolerror=0x%x\n", commandName, outputFileName.text, toolerror());
|
fprintf(stderr, "%s: Unable to add window position resource to file %s, toolerror=0x%x\n", commandName, outputFileName.text, toolerror());
|
||||||
result = 1;
|
result = 1;
|
||||||
|
DisposeHandle(windowPosHandle);
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposeHandle(windowPosHandle);
|
AddResource(styleHandle(), 0, rStyleBlock, STYLE_BLOCK_NUM);
|
||||||
|
if (toolerror()) {
|
||||||
|
fprintf(stderr, "%s: Unable to add style resource to file %s, toolerror=0x%x\n", commandName, outputFileName.text, toolerror());
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
CloseResourceFile(writeResId);
|
CloseResourceFile(writeResId);
|
||||||
@ -241,13 +240,12 @@ static int writeRez(void)
|
|||||||
" hex string;\n"
|
" hex string;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"resource rStyleBlock (%u) {\n"
|
"resource rWindowPosition (%u) {\n"
|
||||||
" $\"",
|
" $\"",
|
||||||
rStyleBlock, R_WINDOW_POSITION, STYLE_BLOCK_NUM
|
rStyleBlock, R_WINDOW_POSITION, WINDOW_POSITION_NUM);
|
||||||
);
|
|
||||||
|
|
||||||
ptr = stylePtr();
|
ptr = (uint8_t *)(&windowPos);
|
||||||
size = styleSize();
|
size = sizeof(windowPos);
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
if ((i > 0) &&
|
if ((i > 0) &&
|
||||||
((i % 32) == 0)) {
|
((i % 32) == 0)) {
|
||||||
@ -260,12 +258,13 @@ static int writeRez(void)
|
|||||||
fprintf(rezFile, "\"\n"
|
fprintf(rezFile, "\"\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n"
|
"\n"
|
||||||
"resource rWindowPosition (%u) {\n"
|
"resource rStyleBlock (%u) {\n"
|
||||||
" $\"",
|
" $\"",
|
||||||
WINDOW_POSITION_NUM);
|
STYLE_BLOCK_NUM
|
||||||
|
);
|
||||||
|
|
||||||
ptr = (uint8_t *)(&windowPos);
|
ptr = stylePtr();
|
||||||
size = sizeof(windowPos);
|
size = styleSize();
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
if ((i > 0) &&
|
if ((i > 0) &&
|
||||||
((i % 32) == 0)) {
|
((i % 32) == 0)) {
|
||||||
@ -274,6 +273,7 @@ static int writeRez(void)
|
|||||||
fprintf(rezFile, "%02x", (uint16_t)*ptr);
|
fprintf(rezFile, "%02x", (uint16_t)*ptr);
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(rezFile, "\"\n"
|
fprintf(rezFile, "\"\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"\n");
|
"\n");
|
||||||
|
@ -293,7 +293,9 @@ void closeStyle(void)
|
|||||||
|
|
||||||
Handle styleHandle(void)
|
Handle styleHandle(void)
|
||||||
{
|
{
|
||||||
return formatHandle;
|
Handle result = formatHandle;
|
||||||
|
formatHandle = NULL;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * stylePtr(void)
|
uint8_t * stylePtr(void)
|
||||||
@ -309,5 +311,6 @@ uint32_t styleSize(void)
|
|||||||
|
|
||||||
void styleShutdown(void)
|
void styleShutdown(void)
|
||||||
{
|
{
|
||||||
DisposeHandle(formatHandle);
|
if (formatHandle != NULL)
|
||||||
|
DisposeHandle(formatHandle);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user