2010-09-11 08:35:25 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
#include "QF/qendian.h"
|
2010-09-11 08:35:25 +00:00
|
|
|
#include "QF/quakeio.h"
|
|
|
|
#include "QF/sys.h"
|
2010-09-12 10:47:44 +00:00
|
|
|
#include "QF/wadfile.h"
|
2010-09-28 12:40:11 +00:00
|
|
|
#include "QF/va.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-09 11:46:38 +00:00
|
|
|
#include "TexturePalette.h"
|
2010-09-11 08:35:25 +00:00
|
|
|
#include "Preferences.h"
|
2010-10-10 07:37:43 +00:00
|
|
|
#include "Project.h"
|
2010-09-11 08:35:25 +00:00
|
|
|
#include "Map.h"
|
|
|
|
#include "Entity.h"
|
|
|
|
#include "QuakeEd.h"
|
|
|
|
#include "SetBrush.h"
|
|
|
|
|
|
|
|
#include "Storage.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
id texturepalette_i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
int tex_count;
|
|
|
|
qtexture_t qtextures[MAX_TEXTURES];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
typedef struct {
|
2010-09-11 10:03:41 +00:00
|
|
|
char name[16];
|
|
|
|
unsigned width, height;
|
2010-09-29 20:09:11 +00:00
|
|
|
unsigned offsets[4]; // four mip maps stored
|
2003-03-18 19:48:24 +00:00
|
|
|
} miptex_t;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
unsigned tex_palette[256];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
unsigned badtex_d[] = {
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
2010-09-29 20:09:11 +00:00
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2010-09-11 10:03:41 +00:00
|
|
|
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
|
2003-03-18 19:48:24 +00:00
|
|
|
};
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
qtexture_t badtex = {"notexture", 16, 16, NULL, badtex_d, {{0, 0, 255, 255}}};
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-27 11:53:52 +00:00
|
|
|
void
|
|
|
|
CleanupName (const char *in, char *out)
|
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
2010-09-27 11:53:52 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
if (!in[i])
|
|
|
|
break;
|
|
|
|
out[i] = toupper (in[i]);
|
|
|
|
}
|
|
|
|
for ( ; i < 16; i++)
|
|
|
|
out[i] = 0;
|
|
|
|
}
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
/*
|
|
|
|
==============
|
|
|
|
TEX_InitPalette
|
|
|
|
==============
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
2010-09-12 10:47:44 +00:00
|
|
|
TEX_InitPalette (wad_t *wad, lumpinfo_t *pallump)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
byte *pal, *opal;
|
|
|
|
int r, g, b, v;
|
|
|
|
int i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-12 10:47:44 +00:00
|
|
|
opal = pal = malloc (pallump->size);
|
|
|
|
Qseek (wad->handle, pallump->filepos, SEEK_SET);
|
|
|
|
Qread (wad->handle, pal, pallump->size);
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < 256; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
r = pal[0];
|
|
|
|
g = pal[1];
|
|
|
|
b = pal[2];
|
|
|
|
pal += 3;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
v = (r << 24) + (g << 16) + (b << 8) + 255;
|
2003-03-18 19:48:24 +00:00
|
|
|
v = BigLong (v);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
tex_palette[i] = v;
|
|
|
|
}
|
2010-09-12 10:47:44 +00:00
|
|
|
free (opal);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
TEX_ImageFromMiptex
|
|
|
|
=================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
2010-09-12 10:47:44 +00:00
|
|
|
TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump)
|
2010-09-11 10:03:41 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
miptex_t *qtex;
|
|
|
|
NSBitmapImageRep *bm;
|
|
|
|
byte *source;
|
|
|
|
unsigned *dest;
|
|
|
|
int width, height, i, count;
|
|
|
|
qtexture_t *q;
|
|
|
|
int tr, tg, tb;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 10:47:44 +00:00
|
|
|
qtex = malloc (qtexlump->size);
|
|
|
|
Qseek (wad->handle, qtexlump->filepos, SEEK_SET);
|
|
|
|
Qread (wad->handle, qtex, qtexlump->size);
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
width = LittleLong (qtex->width);
|
|
|
|
height = LittleLong (qtex->height);
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
bm = [[NSBitmapImageRep alloc]
|
|
|
|
initWithBitmapDataPlanes: NULL
|
|
|
|
pixelsWide: width
|
|
|
|
pixelsHigh: height
|
|
|
|
bitsPerSample: 8
|
|
|
|
samplesPerPixel: 3
|
|
|
|
hasAlpha: NO
|
|
|
|
isPlanar: NO
|
|
|
|
colorSpaceName: NSCalibratedRGBColorSpace
|
|
|
|
bytesPerRow: width * 4
|
|
|
|
bitsPerPixel: 32];
|
|
|
|
|
|
|
|
dest = (unsigned *) [bm bitmapData];
|
2010-09-11 10:03:41 +00:00
|
|
|
count = width * height;
|
|
|
|
source = (byte *) qtex + LittleLong (qtex->offsets[0]);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
q = &qtextures[tex_count];
|
|
|
|
tex_count++;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
q->width = width;
|
|
|
|
q->height = height;
|
2010-10-10 10:20:20 +00:00
|
|
|
if (q->rep)
|
|
|
|
[q->rep release];
|
2003-03-18 19:48:24 +00:00
|
|
|
q->rep = bm;
|
|
|
|
q->data = dest;
|
|
|
|
|
|
|
|
tr = tg = tb = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
dest[i] = tex_palette[source[i]];
|
2010-09-29 20:09:11 +00:00
|
|
|
tr += ((pixel32_t *) &dest[i])->chan[0];
|
|
|
|
tg += ((pixel32_t *) &dest[i])->chan[1];
|
|
|
|
tb += ((pixel32_t *) &dest[i])->chan[2];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
q->flatcolor.chan[0] = tr / count;
|
|
|
|
q->flatcolor.chan[1] = tg / count;
|
|
|
|
q->flatcolor.chan[2] = tb / count;
|
2010-09-11 10:03:41 +00:00
|
|
|
q->flatcolor.chan[3] = 0xff;
|
2010-09-12 10:47:44 +00:00
|
|
|
free (qtex);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// =============================================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
TEX_InitFromWad
|
|
|
|
=================
|
|
|
|
*/
|
2010-09-28 13:17:07 +00:00
|
|
|
int
|
2010-09-27 15:29:16 +00:00
|
|
|
TEX_InitFromWad (const char *path)
|
2010-09-11 10:03:41 +00:00
|
|
|
{
|
|
|
|
int i;
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *newpath;
|
2010-09-11 10:03:41 +00:00
|
|
|
float start, stop;
|
2010-09-29 20:09:11 +00:00
|
|
|
wad_t *wad;
|
|
|
|
lumpinfo_t *lumpinfo;
|
2010-10-10 10:20:20 +00:00
|
|
|
NSString *errmsg;
|
|
|
|
int old_tex_count;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-11 23:43:55 +00:00
|
|
|
start = Sys_DoubleTime ();
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-10 07:37:43 +00:00
|
|
|
newpath = [[project_i baseDirectoryPath] cString];
|
2010-10-10 06:24:35 +00:00
|
|
|
newpath = va ("%s%s%s", newpath, (newpath[0] ? "/" : ""), path);
|
2010-10-10 10:20:20 +00:00
|
|
|
errmsg = [NSString stringWithFormat: @"Failed to open '%s'", newpath];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-10-10 06:24:35 +00:00
|
|
|
Sys_Printf ("TEX_InitFromWad: loading %s\n", newpath);
|
2010-09-28 13:17:07 +00:00
|
|
|
wad = wad_open (newpath);
|
|
|
|
if (!wad) {
|
2010-10-10 10:20:20 +00:00
|
|
|
Sys_Printf ("TEX_InitFromWad: wad_open(%s) failed\n", path);
|
|
|
|
goto cleanup;
|
2010-09-28 13:17:07 +00:00
|
|
|
}
|
2010-09-12 10:47:44 +00:00
|
|
|
|
|
|
|
lumpinfo = wad->lumps;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-10 10:20:20 +00:00
|
|
|
if (strcasecmp (lumpinfo->name, "PALETTE")) {
|
2010-10-09 12:57:18 +00:00
|
|
|
lumpinfo_t tlump;
|
|
|
|
|
2010-10-10 05:51:22 +00:00
|
|
|
Sys_Printf ("TEX_InitFromWad: %s doesn't have palette at index 0\n", path);
|
2010-10-09 12:57:18 +00:00
|
|
|
lumpinfo = wad_find_lump (wad, "PALETTE");
|
2010-10-10 10:20:20 +00:00
|
|
|
if (!lumpinfo) {
|
|
|
|
Sys_Printf ("TEX_InitFromWad: %s doesn't have a palette\n", path);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2010-10-09 12:57:18 +00:00
|
|
|
|
|
|
|
// move the palette lump to the first entry
|
|
|
|
tlump = *lumpinfo;
|
|
|
|
*lumpinfo = wad->lumps[0];
|
|
|
|
wad->lumps[0] = tlump;
|
|
|
|
lumpinfo = wad->lumps;
|
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-12 10:47:44 +00:00
|
|
|
TEX_InitPalette (wad, lumpinfo);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-10 10:20:20 +00:00
|
|
|
old_tex_count = tex_count;
|
|
|
|
tex_count = 0;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
lumpinfo++;
|
2010-09-12 10:47:44 +00:00
|
|
|
for (i = 1; i < wad->numlumps; i++, lumpinfo++) {
|
2010-10-10 10:20:20 +00:00
|
|
|
if (lumpinfo->type != TYP_MIPTEX) {
|
|
|
|
Sys_Printf ("TEX_InitFromWad: %s is not a miptex!\n", lumpinfo->name);
|
|
|
|
continue;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
CleanupName (lumpinfo->name, qtextures[tex_count].name);
|
2010-09-12 10:47:44 +00:00
|
|
|
TEX_ImageFromMiptex (wad, lumpinfo);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-10-10 10:20:20 +00:00
|
|
|
if (tex_count) {
|
|
|
|
for (i = tex_count; i < old_tex_count; i++) {
|
|
|
|
[qtextures[i].rep release];
|
|
|
|
qtextures[i].rep = nil;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-12 10:47:44 +00:00
|
|
|
wad_close (wad);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 23:43:55 +00:00
|
|
|
stop = Sys_DoubleTime ();
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-10 10:20:20 +00:00
|
|
|
Sys_Printf ("loaded %s (%.3f seconds)\n", newpath, stop - start);
|
2010-09-28 13:17:07 +00:00
|
|
|
return 1;
|
2010-10-10 10:20:20 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (wad)
|
|
|
|
wad_close (wad);
|
|
|
|
|
|
|
|
NSRunAlertPanel (@"Wad Error", errmsg, @"OK", nil, nil);
|
|
|
|
|
|
|
|
return 0;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
TEX_NumForName
|
|
|
|
=================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
qtexture_t *
|
2010-09-28 09:41:38 +00:00
|
|
|
TEX_ForName (const char *name)
|
2010-09-11 10:03:41 +00:00
|
|
|
{
|
2010-09-27 11:53:52 +00:00
|
|
|
char newname[16];
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
2010-09-29 20:09:11 +00:00
|
|
|
qtexture_t *q;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-27 11:53:52 +00:00
|
|
|
CleanupName (name, newname);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0, q = qtextures; i < tex_count; i++, q++) {
|
2010-09-27 11:53:52 +00:00
|
|
|
if (!strcmp (newname, q->name))
|
2003-03-18 19:48:24 +00:00
|
|
|
return q;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return &badtex;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// ===========================================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
@implementation TexturePalette
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) init
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
[super init];
|
|
|
|
texturepalette_i = self;
|
|
|
|
selectedTexture = -1;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) display
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
[[textureView_i superview] display];
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) currentWad
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return currentwad;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) initPaletteFromWadfile: (const char *)wf
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
|
|
|
texpal_t t;
|
2010-09-29 20:09:11 +00:00
|
|
|
qtexture_t *q;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
strcpy (currentwad, wf);
|
2010-09-29 20:09:11 +00:00
|
|
|
[map_i makeGlobalPerform: @selector (flushTextures)];
|
2003-03-18 19:48:24 +00:00
|
|
|
selectedTexture = -1;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// Init textures WAD
|
2010-09-28 13:17:07 +00:00
|
|
|
if (!TEX_InitFromWad (wf))
|
|
|
|
return self;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// Create STORAGE
|
2010-09-29 20:09:11 +00:00
|
|
|
if (textureList_i) {
|
2003-03-18 19:48:24 +00:00
|
|
|
[textureList_i empty];
|
2010-09-29 20:09:11 +00:00
|
|
|
} else {
|
|
|
|
textureList_i = [[Storage alloc] initCount: 0
|
|
|
|
elementSize: sizeof (texpal_t)
|
|
|
|
description: NULL];
|
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
// Init STORAGE
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0, q = qtextures; i < tex_count; i++, q++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
t.image = q->rep;
|
2010-09-29 20:09:11 +00:00
|
|
|
t.r.size.width = [t.image pixelsWide];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (t.r.size.width < 64)
|
|
|
|
t.r.size.width = 64;
|
2010-09-29 20:09:11 +00:00
|
|
|
t.r.size.height = [t.image pixelsHigh] + TEX_SPACING;
|
2003-03-18 19:48:24 +00:00
|
|
|
t.name = q->name;
|
|
|
|
t.index = i;
|
|
|
|
t.display = 1;
|
2010-09-29 20:09:11 +00:00
|
|
|
[textureList_i addElement: &t];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate size of TextureView
|
|
|
|
[self alphabetize];
|
|
|
|
[self computeTextureViewSize];
|
2010-09-29 20:09:11 +00:00
|
|
|
[textureView_i setParent: self];
|
|
|
|
[self setSelectedTexture: 0];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return texture STORAGE list
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) getList
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return textureList_i;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Alphabetize texture list - reverse order!
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) alphabetize
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
|
|
|
int max;
|
2010-09-29 20:09:11 +00:00
|
|
|
texpal_t *t1p;
|
|
|
|
texpal_t *t2p;
|
2010-09-11 10:03:41 +00:00
|
|
|
texpal_t t1;
|
|
|
|
texpal_t t2;
|
|
|
|
int found;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
max = [textureList_i count];
|
2003-03-18 19:48:24 +00:00
|
|
|
found = 1;
|
2010-09-11 10:03:41 +00:00
|
|
|
while (found) {
|
2003-03-18 19:48:24 +00:00
|
|
|
found = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < max - 1; i++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
t1p = [textureList_i elementAt: i];
|
|
|
|
t2p = [textureList_i elementAt: i + 1];
|
2010-09-11 10:03:41 +00:00
|
|
|
if (strcmp (t1p->name, t2p->name) < 0) {
|
2003-03-18 19:48:24 +00:00
|
|
|
t1 = *t1p;
|
|
|
|
t2 = *t2p;
|
2010-09-29 20:09:11 +00:00
|
|
|
[textureList_i replaceElementAt: i with: &t2];
|
|
|
|
[textureList_i replaceElementAt: i + 1 with: &t1];
|
2003-03-18 19:48:24 +00:00
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) computeTextureViewSize
|
2010-09-11 10:03:41 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int max;
|
|
|
|
int x;
|
2010-09-29 20:09:11 +00:00
|
|
|
texpal_t *t;
|
2010-09-11 10:03:41 +00:00
|
|
|
int y;
|
|
|
|
id view;
|
|
|
|
NSRect b;
|
|
|
|
int maxwidth;
|
|
|
|
int maxheight;
|
|
|
|
NSPoint pt;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
max = [textureList_i count];
|
2003-03-18 19:48:24 +00:00
|
|
|
y = 0;
|
|
|
|
maxheight = 0;
|
|
|
|
x = TEX_INDENT;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
view = [textureView_i superview];
|
|
|
|
b = [view bounds];
|
2003-03-18 19:48:24 +00:00
|
|
|
maxwidth = b.size.width;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < max; i++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
t = [textureList_i elementAt: i];
|
2010-09-11 10:03:41 +00:00
|
|
|
if (x + t->r.size.width + TEX_INDENT > maxwidth) {
|
2003-03-18 19:48:24 +00:00
|
|
|
x = TEX_INDENT;
|
|
|
|
y += maxheight;
|
|
|
|
maxheight = 0;
|
|
|
|
}
|
|
|
|
if (t->r.size.height > maxheight)
|
|
|
|
maxheight = t->r.size.height;
|
|
|
|
t->r.origin.x = x;
|
|
|
|
t->r.origin.y = y;
|
|
|
|
x += t->r.size.width + TEX_INDENT;
|
|
|
|
if (i == max - 1)
|
|
|
|
y += t->r.size.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
viewWidth = maxwidth;
|
|
|
|
viewHeight = y + TEX_SPACING;
|
2010-09-29 20:09:11 +00:00
|
|
|
[textureView_i setFrameSize: NSMakeSize (viewWidth, viewHeight)];
|
2003-03-18 19:48:24 +00:00
|
|
|
pt.x = pt.y = 0;
|
2010-09-29 20:09:11 +00:00
|
|
|
[textureView_i scrollPoint: pt];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) windowResized
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
[self computeTextureViewSize];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) texturedefChanged: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([map_i numSelected]) {
|
|
|
|
if ([[map_i currentEntity] modifiable]) {
|
2010-09-29 20:09:11 +00:00
|
|
|
[map_i makeSelectedPerform: @selector
|
2010-09-11 10:03:41 +00:00
|
|
|
(takeCurrentTexture)];
|
2003-03-18 19:48:24 +00:00
|
|
|
[quakeed_i updateAll];
|
2010-09-29 20:09:11 +00:00
|
|
|
} else {
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("can't modify spawned entities\n");
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
[quakeed_i makeFirstResponder: quakeed_i];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) clearTexinfo: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[field_Xshift_i setFloatValue: 0];
|
|
|
|
[field_Yshift_i setFloatValue: 0];
|
|
|
|
[field_Xscale_i setFloatValue: 1];
|
|
|
|
[field_Yscale_i setFloatValue: 1];
|
|
|
|
[field_Rotate_i setFloatValue: 0];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Set the selected texture
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) setSelectedTexture: (int)which
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
texpal_t *t;
|
2010-09-11 10:03:41 +00:00
|
|
|
NSRect r;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-10-11 12:11:33 +00:00
|
|
|
// wipe the fields
|
2010-09-29 20:09:11 +00:00
|
|
|
[self clearTexinfo: self];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (which != selectedTexture) {
|
2003-03-18 19:48:24 +00:00
|
|
|
[textureView_i deselect];
|
|
|
|
selectedTexture = which;
|
2010-09-29 20:09:11 +00:00
|
|
|
t = [textureList_i elementAt: which];
|
2003-03-18 19:48:24 +00:00
|
|
|
r = t->r;
|
2010-09-11 10:03:41 +00:00
|
|
|
r.size.width += TEX_INDENT * 2;
|
|
|
|
r.size.height += TEX_INDENT * 2;
|
2003-03-18 19:48:24 +00:00
|
|
|
r.origin.x -= TEX_INDENT;
|
|
|
|
r.origin.y -= TEX_INDENT;
|
2010-09-29 20:09:11 +00:00
|
|
|
[textureView_i scrollRectToVisible: r];
|
2003-03-18 19:48:24 +00:00
|
|
|
[textureView_i display];
|
2010-09-28 12:40:11 +00:00
|
|
|
[sizeField_i setStringValue:
|
2010-09-29 20:09:11 +00:00
|
|
|
[NSString stringWithFormat: @"%d x %d",
|
|
|
|
(int) t->r.size.width,
|
|
|
|
(int) t->r.size.height - TEX_SPACING]];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the selected texture index
|
2010-09-29 20:09:11 +00:00
|
|
|
- (int) getSelectedTexture
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return selectedTexture;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the original tex_ index of the selected texture
|
|
|
|
// so the texture info can be indexed from tex_images, etc.
|
2010-09-29 20:09:11 +00:00
|
|
|
- (int) getSelectedTexIndex
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
texpal_t *t;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (selectedTexture == -1)
|
|
|
|
return -1;
|
2010-09-29 20:09:11 +00:00
|
|
|
t = [textureList_i elementAt: selectedTexture];
|
2003-03-18 19:48:24 +00:00
|
|
|
return t->index;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the name of the selected texture
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getSelTextureName
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
texpal_t *t;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (selectedTexture == -1)
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
t = [textureList_i elementAt: selectedTexture];
|
2003-03-18 19:48:24 +00:00
|
|
|
return t->name;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Set selected texture by texture name
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) setTextureByName: (const char *)name
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
texpal_t *t;
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
|
|
|
int max;
|
2010-09-29 20:09:11 +00:00
|
|
|
char *nm = strdup (name);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
max = [textureList_i count];
|
|
|
|
CleanupName (nm, nm);
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < max; i++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
t = [textureList_i elementAt: i];
|
2010-09-28 09:41:38 +00:00
|
|
|
if (!strcmp (t->name, nm)) {
|
|
|
|
free (nm);
|
2010-09-29 20:09:11 +00:00
|
|
|
[self setSelectedTexture: i];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
2010-09-28 09:41:38 +00:00
|
|
|
free (nm);
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// ===================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Action methods
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
// ===================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Search for texture named in searchField
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) searchForTexture: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
|
|
|
int max;
|
|
|
|
int len;
|
|
|
|
NSMutableString *strname;
|
|
|
|
const char *name;
|
|
|
|
texpal_t *t;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (selectedTexture == -1)
|
|
|
|
return self;
|
|
|
|
|
2010-09-28 12:40:11 +00:00
|
|
|
max = [textureList_i count];
|
|
|
|
strname = [[sender stringValue] mutableCopy];
|
|
|
|
[strname uppercaseString];
|
|
|
|
[sender setStringValue: strname];
|
|
|
|
name = [strname cString];
|
2010-09-11 10:03:41 +00:00
|
|
|
len = strlen (name);
|
|
|
|
|
|
|
|
for (i = selectedTexture - 1; i >= 0; i--) {
|
2010-09-29 20:09:11 +00:00
|
|
|
t = [textureList_i elementAt: i];
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!strncmp (t->name, name, len)) {
|
2010-09-29 20:09:11 +00:00
|
|
|
[self setTextureByName: t->name];
|
|
|
|
[sender selectText: sender];
|
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = max - 1; i >= selectedTexture; i--) {
|
2010-09-29 20:09:11 +00:00
|
|
|
t = [textureList_i elementAt: i];
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!strncmp (t->name, name, len)) {
|
2010-09-29 20:09:11 +00:00
|
|
|
[self setTextureByName: t->name];
|
|
|
|
[sender selectText: sender];
|
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Set texture def from outside TexturePalette
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) setTextureDef: (texturedef_t *)td
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[self setTextureByName: td->texture];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[field_Xshift_i setFloatValue: td->shift[0]];
|
|
|
|
[field_Yshift_i setFloatValue: td->shift[1]];
|
|
|
|
[field_Xscale_i setFloatValue: td->scale[0]];
|
|
|
|
[field_Yscale_i setFloatValue: td->scale[1]];
|
|
|
|
[field_Rotate_i setFloatValue: td->rotate];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self texturedefChanged: self];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the current texture def to passed *
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) getTextureDef: (texturedef_t *)td
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
if (selectedTexture == -1) {
|
|
|
|
memset (td, 0, sizeof (*td));
|
2003-03-18 19:48:24 +00:00
|
|
|
strcpy (td->texture, "notexture");
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
strncpy (td->texture, [self getSelTextureName], 16);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
td->shift[0] = [field_Xshift_i floatValue];
|
|
|
|
td->shift[1] = [field_Yshift_i floatValue];
|
|
|
|
td->scale[0] = [field_Xscale_i floatValue];
|
|
|
|
td->scale[1] = [field_Yscale_i floatValue];
|
|
|
|
td->rotate = [field_Rotate_i floatValue];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// ============================================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Change value in a field
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) changeField: (id)
|
|
|
|
field by: (int)amount
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int val;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
val = [field intValue];
|
2003-03-18 19:48:24 +00:00
|
|
|
val += amount;
|
2010-09-29 20:09:11 +00:00
|
|
|
[field setIntValue: val];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Inc/Dec the XShift field
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) incXShift: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[self changeField: field_Xshift_i by: 8];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) decXShift: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[self changeField: field_Xshift_i by: -8];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Inc/Dec the YShift field
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) incYShift: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[self changeField: field_Yshift_i by: 8];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) decYShift: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[self changeField: field_Yshift_i by: -8];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Inc/Dec the Rotate field
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) incRotate: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[self changeField: field_Rotate_i by: 90];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) decRotate: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[self changeField: field_Rotate_i by: -90];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Inc/Dec the Xscale field
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) incXScale: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[field_Xscale_i setIntValue: 1];
|
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) decXScale: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[field_Xscale_i setIntValue: -1];
|
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Inc/Dec the Yscale field
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) incYScale: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[field_Yscale_i setIntValue: 1];
|
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) decYScale: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[field_Yscale_i setIntValue: -1];
|
|
|
|
[self texturedefChanged: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// ============================================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Search for texture in entire palette
|
|
|
|
// Return index of texturedef, or -1 if unsuccessful
|
2010-09-29 20:09:11 +00:00
|
|
|
- (int) searchForTextureInPalette: (const char *)texture
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
|
|
|
int max;
|
2010-09-29 20:09:11 +00:00
|
|
|
texpal_t *t;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (selectedTexture == -1)
|
|
|
|
return -1;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
max = [textureList_i count];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < max; i++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
t = [textureList_i elementAt: i];
|
2010-09-28 12:40:11 +00:00
|
|
|
if (!strcmp (t->name, texture))
|
2003-03-18 19:48:24 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
// Scan thru map & display only textures that are in map
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) onlyShowMapTextures: sender
|
2010-09-11 10:03:41 +00:00
|
|
|
{
|
|
|
|
int max;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
id brushes;
|
2010-09-29 20:09:11 +00:00
|
|
|
SetBrush *b;
|
2010-09-11 10:03:41 +00:00
|
|
|
int numfaces;
|
2010-09-29 20:09:11 +00:00
|
|
|
face_t *f;
|
2010-09-11 10:03:41 +00:00
|
|
|
int index;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
// Turn 'em off
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([sender intValue]) {
|
2010-09-29 20:09:11 +00:00
|
|
|
max = [textureList_i count];
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < max; i++)
|
2010-09-29 20:09:11 +00:00
|
|
|
[self setDisplayFlag: i to: 0];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
brushes = [map_i objectAtIndex: 0];
|
|
|
|
max = [brushes count];
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < max; i++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
b = (SetBrush *) [brushes objectAtIndex: i];
|
|
|
|
numfaces = [b getNumBrushFaces];
|
2010-09-11 10:03:41 +00:00
|
|
|
for (j = 0; j < numfaces; j++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
f = [b getBrushFace: j];
|
|
|
|
index = [self searchForTextureInPalette: f->texture.
|
|
|
|
texture];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (index >= 0)
|
2010-09-29 20:09:11 +00:00
|
|
|
[self setDisplayFlag: index to: 1];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Turn 'em on
|
2010-09-11 10:03:41 +00:00
|
|
|
else {
|
2010-09-29 20:09:11 +00:00
|
|
|
max = [textureList_i count];
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < max; i++)
|
2010-09-29 20:09:11 +00:00
|
|
|
[self setDisplayFlag: i to: 1];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[textureView_i display];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) setDisplayFlag: (int)
|
|
|
|
index to: (int)value
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
texpal_t *tp;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
tp = [textureList_i elementAt: index];
|
2003-03-18 19:48:24 +00:00
|
|
|
tp->display = value;
|
|
|
|
return self;
|
|
|
|
};
|
|
|
|
|
|
|
|
@end
|