Compare commits
4 Commits
832ba66295
...
r110
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ab94a1cb8 | |||
| a18368acd2 | |||
| c56cbd741b | |||
| ef80b0faba |
@@ -2,7 +2,7 @@
|
||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||
|
||||
#define MyAppName "KAvEAT"
|
||||
#define MyAppVersion "1.0.0"
|
||||
#define MyAppVersion "1.1.0"
|
||||
#define MyAppPublisher "bonkmaykr"
|
||||
#define MyAppURL "https://kangworlds.net/"
|
||||
#define MyAppUpdateURL "https://git.worlio.com/bonkmaykr/KAvEAT/releases"
|
||||
@@ -65,6 +65,7 @@ Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_webp_.dll"; De
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_xml_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_zip_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_zlib_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\mogrify.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
|
||||
[Icons]
|
||||
|
||||
68
main.c
68
main.c
@@ -3,6 +3,9 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <MagickWand/MagickWand.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
int isPowerOfTwo(int x) {return x && (!(x & (x - 1)));}
|
||||
|
||||
@@ -39,6 +42,7 @@ struct options {
|
||||
int l;
|
||||
int w;
|
||||
int h;
|
||||
int d;
|
||||
};
|
||||
|
||||
void printHelp() {
|
||||
@@ -48,6 +52,11 @@ void printHelp() {
|
||||
"A maximum of 360 different frames can be used for a single avatar.\n"
|
||||
"If the size of any frame does not match, it will be resized to match the first frame.\n"
|
||||
"\n"
|
||||
"When using KAvEAT to create environment textures, please keep in mind that Worlds has\n"
|
||||
"a limit of 9x9 tiles per CMP/MOV file due to the URL parser only reading single digits.\n"
|
||||
"This makes the practical maximum resolution of avatars 2048x2048. World textures can not\n"
|
||||
"have more than 9 frames but can bypass both limits by splitting walls into more pieces.\n"
|
||||
"\n"
|
||||
"Available options:\n"
|
||||
" -r # Maximum resolution, where # is a power of 2. For example, 256 pixels would be \"-r 8\"\n"
|
||||
" -s Stretch the image when non-pot or mismatched size, as opposed to fitting it within.\n"
|
||||
@@ -57,6 +66,8 @@ void printHelp() {
|
||||
" so using this setting with different image sizes will cause visible bars to appear\n"
|
||||
" unless you combine it with the -s option, which will always fill the canvas for each\n"
|
||||
" frame. The same is true for all imported frames which contain an alpha channel.\n"
|
||||
" -d Don't run COMPIMG, don't delete temporary files. Useful if COMPIMG is broken for some\n"
|
||||
" reason, or if you want to customize the command line options given to it.\n"
|
||||
// " -l Enable Lanczos filtering when scaling the image.\n" //point filter unimplemented
|
||||
//" -w Specify the number of subdivisions to make horizontally per frame.\n"
|
||||
//" Use this if you are importing a spritesheet. Each cut is perfectly even.\n"
|
||||
@@ -66,13 +77,24 @@ void printHelp() {
|
||||
//" -h Same as -w, but vertical. If used with -w, KAvEAT will create each chunk\n"
|
||||
//" from each row left-to-right first, not each column top-to-bottom.\n"
|
||||
);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
DWORD procIDs[2];
|
||||
DWORD maxCount = 2;
|
||||
if (GetConsoleProcessList((LPDWORD)procIDs, maxCount) == 1) {
|
||||
printf("\n\nTHIS PROGRAM IS DESIGNED FOR USE WITH A TERMINAL.\n"
|
||||
"Please run cmd.exe first! Then you can use the tool.\n");
|
||||
system("pause");
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void printNoFrames() { printf("You need to specify at least one frame to use, goober.\n"); }
|
||||
|
||||
int main(const int argc, char *argv[]) {
|
||||
printf(
|
||||
"Knowledge Adventure Worlds Easy Avatar Tool, version 1\n"
|
||||
"Knowledge Adventure Worlds Easy Avatar Tool, version 1.1\n"
|
||||
"Copyright (c) 2025 Brett \"bonkmaykr\" Bergstrom\n"
|
||||
"This program is free software under the MIT license.\n"
|
||||
"\n"
|
||||
@@ -96,17 +118,20 @@ int main(const int argc, char *argv[]) {
|
||||
opt.l = 0;
|
||||
opt.w = 0;
|
||||
opt.h = 0;
|
||||
opt.d = 0;
|
||||
uint16_t numFrames = 0;
|
||||
char* frames[360];
|
||||
|
||||
int i = 2;
|
||||
while (i < argc) {
|
||||
if (argv[i][0] == '+') {
|
||||
frames[numFrames] = (char*)malloc(strlen(argv[i]) + 1);
|
||||
memcpy(frames[numFrames], &argv[i][1], strlen(argv[i]) + 1);
|
||||
printf("Adding frame to search index: %s\n", frames[numFrames]);
|
||||
if (numFrames < 360) {
|
||||
frames[numFrames] = (char*)malloc(strlen(argv[i]) + 1);
|
||||
memcpy(frames[numFrames], &argv[i][1], strlen(argv[i]) + 1);
|
||||
printf("Adding frame to search index: %s\n", frames[numFrames]);
|
||||
|
||||
numFrames++;
|
||||
numFrames++;
|
||||
} else printf("REJECTING new frame as it exceeds the frame limit.\n");
|
||||
} else if (strcmp(argv[i], "-r") == 0) {
|
||||
if (i == argc-1) { printf("No parameter for option: -r\n"); return 0; }
|
||||
int r = pow(2, trunc(atof(argv[i+1])));
|
||||
@@ -125,6 +150,8 @@ int main(const int argc, char *argv[]) {
|
||||
if (c < 1 || c > 256) { printf("Invalid number of colors: %s\n", argv[i+1]); return 0; }
|
||||
opt.c = c - 1;
|
||||
i++;
|
||||
} else if (strcmp(argv[i], "-d") == 0) {
|
||||
opt.d = !opt.d;
|
||||
} else {
|
||||
printf("I don't know what \"%s\" means!\n", argv[i]);
|
||||
return 0;
|
||||
@@ -293,6 +320,11 @@ int main(const int argc, char *argv[]) {
|
||||
|
||||
MagickWriteImage(chunk, framename);
|
||||
|
||||
char* command = (char*)malloc(512); // lazy hack until magickwand is fixed
|
||||
sprintf(command, "mogrify -depth 8 -define bmp:format=bmp3 -type palette -compress none %s", framename);
|
||||
system(command);
|
||||
free(command);
|
||||
|
||||
iw++;
|
||||
}
|
||||
ih++;
|
||||
@@ -301,6 +333,7 @@ int main(const int argc, char *argv[]) {
|
||||
}
|
||||
fclose(partlist);
|
||||
|
||||
if (!opt.d) {
|
||||
// Pass on images to COMPIMG
|
||||
printf("Encoding texture file...\n");
|
||||
char* command = (char*)malloc((54 + 3 * abs(1-opt.o) + strlen(filename))*sizeof(char)); // MSVC
|
||||
@@ -312,9 +345,30 @@ int main(const int argc, char *argv[]) {
|
||||
sprintf(command, "./compimg.exe -ace -c%d -r0 -pt%s -emov -M%s +segments.txt", opt.c+1, argTransparent, filename);
|
||||
#endif
|
||||
printf("%s\n", command);
|
||||
if (system(command)) { printf("ERROR trying to run COMPIMG!\n"); return 0; }
|
||||
if (system(command)) { printf("ERROR trying to run COMPIMG!\nMake sure that COMPIMG.EXE is inside of the folder you are working in.\n"); }
|
||||
|
||||
printf("\n\n!!! DONE !!!\nYour avatar name is: %s%ds*%dh*%dv*.mov\n", filename, numFrames, piecesX, piecesY);
|
||||
printf("Cleaning up temporary files...\n");
|
||||
while (i < numFrames) {
|
||||
int ih = 0;
|
||||
while (ih < piecesY) {
|
||||
int iw = 0;
|
||||
while (iw < piecesX) {
|
||||
char* framename = (char*)malloc(12 * piecesX * piecesY * sizeof(char)); // MSVC
|
||||
sprintf(framename, "f%d%d%d.bmp", i, iw, ih);
|
||||
remove(framename);
|
||||
free(framename);
|
||||
|
||||
iw++;
|
||||
}
|
||||
ih++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n\n!!! DONE !!!\n");
|
||||
if (opt.d)
|
||||
printf("Your avatar name is: %s%ds*%dh*%dv*.mov\n", filename, numFrames, piecesX, piecesY);
|
||||
|
||||
if(mw) mw = DestroyMagickWand(mw);
|
||||
MagickWandTerminus();
|
||||
|
||||
Reference in New Issue
Block a user