Debian Codegraph @

editor/WorldTexturesDialog.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/editor/WorldTexturesDialog.cpp $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:40 $
23 * $Author: kevinb $
24 *
25 * Implementation funcs for textures dialog
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 61 4/21/99 12:23p Matt
30 * Added checkbox for breakable textures
31 *
32 * 60 4/12/99 3:04p Jason
33 * changes for low memory
34 *
35 * 59 4/09/99 7:04p Jason
36 * changed some texture defines
37 *
38 * 58 4/01/99 5:14p Matt
39 * Made ambient sound combo update when the sound is changed, and added a
40 * "select" button to bring up the Dallas sound selection dialog.
41 *
42 * 57 3/10/99 7:12p Jason
43 * added smooth specular shading for curved surfaces
44 *
45 * 56 2/20/99 2:17p Matt
46 * Added texture sounds
47 *
48 * 55 1/29/99 6:29p Jason
49 * first pass at adding bumpmaps
50 *
51 * 54 1/27/99 3:39p Mark
52 * fixed 256 problem
53 *
54 * 53 1/26/99 4:04p Jason
55 * added some more texture flags
56 *
57 * 52 1/22/99 3:59p Jason
58 * added 256x256 textures to help with terrain skies
59 *
60 * 51 12/23/98 4:59p Jason
61 * some new texture features added
62 *
63 * 50 12/18/98 5:25p Jason
64 * added specularity to mine walls
65 *
66 * 49 12/17/98 5:38p Jason
67 * added 4444 texture format support
68 *
69 * 48 11/11/98 12:29p Jason
70 * fixed texture panel redrawing
71 *
72 * 47 11/09/98 11:47a Jason
73 * working on multiple checkins
74 *
75 * 46 11/06/98 12:35p Jason
76 * more speedups for manage system
77 *
78 * 45 11/05/98 7:54p Jason
79 * changes for new manage system
80 *
81 * 44 10/29/98 6:01p Jason
82 * added multiple coronas
83 *
84 * 43 10/14/98 12:09p Jason
85 * fixed some long standing name problems
86 *
87 * 42 10/08/98 4:24p Kevin
88 * Changed code to comply with memory library usage. Always use mem_malloc
89 * , mem_free and mem_strdup
90 *
91 * 41 10/07/98 5:03p Jason
92 * more options for textures
93 *
94 * 40 8/24/98 5:20p Keneta
95 * fixed bug in assigning texture slot to a texture with a previously
96 * repeated name.
97 *
98 * 39 8/13/98 11:57a Jason
99 * added water procedurals
100 *
101 * 38 7/15/98 12:39p Jason
102 * fixed bug with new textures
103 *
104 * 37 7/07/98 4:13p Jason
105 * checkin for procedurals
106 *
107 * 36 7/06/98 12:55p Jason
108 * added first pass at procedurals
109 *
110 * 35 7/01/98 3:09p Luke
111 * added assert
112 *
113 * 34 7/01/98 2:42p Jason
114 * fixed bug with unused texture
115 *
116 * 33 6/23/98 2:43p Matt
117 * Changed calls to OutrageMessageBox() & Debug_MessageBox() to deal with
118 * int return value (instead of bool).
119 *
120 * 32 6/10/98 12:21p Matt
121 * Revamped system that controls what textures are displayed on the
122 * texture tab. Should work correctly now, and will now save the settings
123 * to the registry. Also, textures now default to no type set, not all
124 * types set.
125 *
126 * 31 6/03/98 3:46p Jason
127 * made megacell system more robust
128 *
129 * 30 6/02/98 6:04p Jason
130 * added specular lightmaps
131 *
132 * 29 5/26/98 5:08p Matt
133 * Don't put a '1' at the end of new texture names unless the name is
134 * already in use without the '1'.
135 *
136 * 28 5/20/98 5:44p Jason
137 * incremental checkin for bumpmapping
138 *
139 * 27 5/19/98 3:19p Jason
140 * cleaned up some texture flags
141 *
142 * 26 4/15/98 3:28p Jason
143 * changed glow stuff to work with new system
144 *
145 * 25 4/15/98 12:22p Jason
146 * lots of miscellaneous stuff pertaining to lighting and vis effects
147 *
148 * 24 4/06/98 4:42p Jason
149 * added texture alpha change
150 *
151 * 23 3/17/98 4:33p Jason
152 * Added size changing to bitmaps/textures
153 *
154 * 22 3/02/98 6:47p Jason
155 * added texture lighting swatch
156 *
157 * 21 2/23/98 1:00p Jason
158 * added saving of textures as tgas
159 *
160 * 20 2/19/98 1:52p Jason
161 * added emergency override to unlock function
162 *
163 * 19 2/10/98 11:20a Jason
164 * fixed a couple of strange bugs
165 *
166 * 18 2/09/98 3:38p Jason
167 * changed tex size problem in LoadBitmap function
168 *
169 * 17 2/03/98 3:15p Jason
170 * added the ability to specify saturation textures for models
171 *
172 * 16 1/13/98 3:09p Jason
173 * added glow effect for engines
174 *
175 * 15 12/02/97 5:31p Samir
176 * New file dialog interface implemented.
177 *
178 * 14 11/21/97 2:01p Jason
179 * made light textures on model render that model face fully bright
180 *
181 * 13 10/15/97 5:20p Jason
182 * did a HUGE overhaul of the bitmap system
183 *
184 * 12 9/26/97 12:09p Jason
185 * tweaked animation on destroyed texture
186 *
187 * 11 9/25/97 4:30p Jason
188 * got destroyable textures working
189 *
190 * 10 9/25/97 2:58p Jason
191 * fixed locker file bug
192 *
193 * 9 9/09/97 6:08p Matt
194 * Changes to texture dialog:
195 * Added done button
196 * Added 'change name' button & removed edit box
197 * Removed pass through checkbox
198 *
199 * 8 9/03/97 12:19p Jason
200 * made deletion ask for lock
201 *
202 * 7 8/19/97 1:57a Jason
203 * made rgb lighting take floats
204 *
205 * 6 8/12/97 1:10a Jason
206 * added code to support radiosity lighting
207 *
208 * 5 8/08/97 2:25p Matt
209 * Took out error messages which are now handled by mng_MakeLocker()
210 *
211 * 4 8/08/97 12:58p Jason
212 * got texture sliding and pingponging working
213 *
214 * 3 8/05/97 4:28p Chris
215 * Added the fly thru and fly back flags
216 *
217 * 2 8/04/97 3:28p Jason
218 * added alpha blending per texture
219 *
220 * 54 6/24/97 1:15p Jason
221 *
222 * 53 6/06/97 3:57p Jason
223 * implemented changes for small textures and automatic tmap2 recognition
224 *
225 * 52 6/03/97 5:26p Mark
226 *
227 * 52 6/03/97 5:17p Jeff
228 * Added Context Sensitive Help
229 * 51 5/30/97 5:46p Jason
230 * added colored light functionality on a vertex level
231 *
232 * 50 5/23/97 7:07p Matt
233 * Added code, data, & dialogs to keep track of what a texture is used for
234 * (mine, terrain, object) so we can display in the texture dialog only
235 * the ones we're interested in.
236 *
237 * $NoKeywords: $
238 */
239
240 #include <algorithm>
241
242 #include "mfc_compatibility.h"
243 #include "editor.h"
244 #include "WorldTexturesDialog.h"
245 #include "bitmap.h"
246 #include "gametexture.h"
247 #include "manage.h"
248 #include "texpage.h"
249 #include "pserror.h"
250 #include "mono.h"
251 #include "vclip.h"
252 #include "Macros.h"
253 #include "EditLineDialog.h"
254 #include "ddio.h"
255 #include "polymodel.h"
256 #include "bumpmap.h"
257 #include "ProceduralDialog.h"
258 #include "WaterProceduralDialog.h"
259 #include "mem.h"
260 #include "ManageCheckin.h"
261
262 #ifdef _DEBUG
263 #define new DEBUG_NEW
264 #undef THIS_FILE
265 static char THIS_FILE[] = __FILE__;
266 #endif
267
268 #define TEXTURES_PER_ROW 12
269
270 /////////////////////////////////////////////////////////////////////////////
271 // CWorldTexturesDialog dialog
272
273 CWorldTexturesDialog::CWorldTexturesDialog(CWnd *pParent /*=NULL*/) : CDialog(CWorldTexturesDialog::IDD, pParent) {
274 //{{AFX_DATA_INIT(CWorldTexturesDialog)
275 // NOTE: the ClassWizard will add member initialization here
276 //}}AFX_DATA_INIT
277
278 m_bumpmap = 0;
279 m_TexStart = 0;
280 m_TexListPos = 0;
281 m_RedrawListbox = 0;
282 m_TexPageLen = 0;
283 m_CheckForTextureList = 0;
284 m_CheckX = m_CheckY = 0;
285 }
286
287 void CWorldTexturesDialog::DoDataExchange(CDataExchange *pDX) {
288 CDialog::DoDataExchange(pDX);
289 //{{AFX_DATA_MAP(CWorldTexturesDialog)
290 DDX_Control(pDX, IDC_TEXTURE_AMBIENT_SOUND_PULLDOWN, m_ambient_sound_combo);
291 //}}AFX_DATA_MAP
292 }
293
294 BEGIN_MESSAGE_MAP(CWorldTexturesDialog, CDialog)
295 //{{AFX_MSG_MAP(CWorldTexturesDialog)
296 ON_BN_CLICKED(IDC_WTEXDLG_ADDNEW, OnWtexdlgAddnew)
297 ON_WM_PAINT()
298 ON_BN_CLICKED(IDC_NEXT, OnNext)
299 ON_BN_CLICKED(IDC_PREVIOUS, OnPrevious)
300 ON_CBN_SELENDOK(IDC_TEX_LIST, OnSelendokTexList)
301 ON_BN_CLICKED(IDC_LOCK, OnLock)
302 ON_BN_CLICKED(IDC_CHECKIN, OnCheckin)
303 ON_BN_CLICKED(IDC_RCS_STATUS, OnRcsStatus)
304 ON_BN_CLICKED(IDC_DELETE, OnDelete)
305 ON_BN_CLICKED(IDC_VOLATILE, OnVolatile)
306 ON_BN_CLICKED(IDC_WATER, OnWater)
307 ON_BN_CLICKED(IDC_FORCEFIELD, OnForcefield)
308 ON_BN_CLICKED(IDC_CHECK_ANIMATE, OnCheckAnimate)
309 ON_BN_CLICKED(IDC_LOAD_BITMAP, OnLoadBitmap)
310 ON_BN_CLICKED(IDC_CHECK_DESTROY, OnCheckDestroy)
311 ON_EN_KILLFOCUS(IDC_REFLECT, OnKillfocusReflect)
312 ON_EN_KILLFOCUS(IDC_SLIDEU, OnKillfocusSlideu)
313 ON_EN_KILLFOCUS(IDC_SLIDEV, OnKillfocusSlidev)
314 ON_EN_KILLFOCUS(IDC_DAMAGE, OnKillfocusDamage)
315 ON_EN_KILLFOCUS(IDC_TEX_NUM, OnKillfocusTexNum)
316 ON_WM_TIMER()
317 ON_WM_LBUTTONDOWN()
318 ON_BN_CLICKED(IDC_TEXTURE_CURRENT, OnTextureCurrent)
319 ON_WM_VSCROLL()
320 ON_BN_CLICKED(IDC_MINE_TEXTURE, OnMineTexture)
321 ON_BN_CLICKED(IDC_OBJECT_TEXTURE, OnObjectTexture)
322 ON_BN_CLICKED(IDC_TERRAIN_TEXTURE, OnTerrainTexture)
323 ON_EN_KILLFOCUS(IDC_BLUE_LIGHTING, OnKillfocusBlueLighting)
324 ON_EN_KILLFOCUS(IDC_GREEN_LIGHTING, OnKillfocusGreenLighting)
325 ON_EN_KILLFOCUS(IDC_RED_LIGHTING, OnKillfocusRedLighting)
326 ON_WM_HELPINFO()
327 ON_BN_CLICKED(IDC_ADD_NEW_SMALL, OnAddNewSmall)
328 ON_BN_CLICKED(IDC_ADD_NEW_TINY, OnAddNewTiny)
329 ON_EN_KILLFOCUS(IDC_ALPHA_EDIT, OnKillfocusAlphaEdit)
330 ON_BN_CLICKED(IDC_TEXTURE_FLY_THRU_CHECK, OnTextureFlyThruCheck)
331 ON_BN_CLICKED(IDC_PING_PONG, OnPingPong)
332 ON_BN_CLICKED(IDC_TEXTURE_CHANGE_NAME, OnTextureChangeName)
333 ON_CBN_SELENDOK(IDC_DESTROY_PULLDOWN, OnSelendokDestroyPulldown)
334 ON_BN_CLICKED(IDC_SATURATE, OnSaturate)
335 ON_BN_CLICKED(IDC_OVERRIDE, OnOverride)
336 ON_BN_CLICKED(IDC_SAVE_AS_TGA, OnSaveAsTga)
337 ON_BN_CLICKED(IDC_CONVERT_TO_NORMAL, OnConvertToNormal)
338 ON_BN_CLICKED(IDC_CONVERT_TO_SMALL, OnConvertToSmall)
339 ON_BN_CLICKED(IDC_CONVERT_TO_TINY, OnConvertToTiny)
340 ON_EN_KILLFOCUS(IDC_SPEED_EDIT, OnKillfocusSpeedEdit)
341 ON_BN_CLICKED(IDC_IMPORT_BUMP, OnImportBump)
342 ON_BN_CLICKED(IDC_GENERATE_OMNI, OnGenerateOmni)
343 ON_BN_CLICKED(IDC_SRC_BUMP, OnSrcBump)
344 ON_BN_CLICKED(IDC_BUMP1, OnBump1)
345 ON_BN_CLICKED(IDC_BUMP2, OnBump2)
346 ON_BN_CLICKED(IDC_BUMP3, OnBump3)
347 ON_BN_CLICKED(IDC_BUMP4, OnBump4)
348 ON_BN_CLICKED(IDC_METAL_CHECK, OnMetalCheck)
349 ON_BN_CLICKED(IDC_MARBLE_CHECK, OnMarbleCheck)
350 ON_BN_CLICKED(IDC_PLASTIC_CHECK, OnPlasticCheck)
351 ON_BN_CLICKED(IDC_EFFECT_TEXTURE, OnEffectTexture)
352 ON_BN_CLICKED(IDC_HUD_COCKPIT_TEXTURE, OnHudCockpitTexture)
353 ON_BN_CLICKED(IDC_LIGHT_TEXTURE, OnLightTexture)
354 ON_BN_CLICKED(IDC_PROCEDURAL_CHECK, OnProceduralCheck)
355 ON_BN_CLICKED(IDC_PROCEDURAL_BUTTON, OnProceduralButton)
356 ON_BN_CLICKED(IDC_WATER_PROCEDURAL_CHECK, OnWaterProceduralCheck)
357 ON_BN_CLICKED(IDC_FORCE_LIGHTMAPS, OnForceLightmaps)
358 ON_BN_CLICKED(IDC_CORONA_A, OnCoronaA)
359 ON_BN_CLICKED(IDC_CORONA_B, OnCoronaB)
360 ON_BN_CLICKED(IDC_CORONA_C, OnCoronaC)
361 ON_BN_CLICKED(IDC_CORONA_D, OnCoronaD)
362 ON_BN_CLICKED(IDC_MULTICHECKTEX, OnMultichecktex)
363 ON_BN_CLICKED(IDC_IMPORT_4444, OnImport4444)
364 ON_BN_CLICKED(IDC_SATURATE_LIGHTMAP, OnSaturateLightmap)
365 ON_BN_CLICKED(IDC_ADD_NEW_HUGE, OnAddNewHuge)
366 ON_BN_CLICKED(IDC_LAVA_CHECKBOX, OnLavaCheckbox)
367 ON_BN_CLICKED(IDC_RUBBLE_CHECKBOX, OnRubbleCheckbox)
368 ON_CBN_SELENDOK(IDC_TEXTURE_AMBIENT_SOUND_PULLDOWN, OnSelendokTextureAmbientSoundPulldown)
369 ON_EN_KILLFOCUS(IDC_TEXTURE_AMBIENT_SOUND_VOLUME, OnKillfocusTextureAmbientSoundVolume)
370 ON_BN_CLICKED(IDC_SMOOTH_SPEC_CHECK, OnSmoothSpecCheck)
371 ON_BN_CLICKED(IDC_AMBIENT_SOUND_SELECT, OnAmbientSoundSelect)
372 ON_BN_CLICKED(IDC_CHECK_BREAKABLE, OnCheckBreakable)
373 //}}AFX_MSG_MAP
374 END_MESSAGE_MAP()
375
376 /////////////////////////////////////////////////////////////////////////////
377 // CWorldTexturesDialog message handlers
378
379 bool InputTextureName(char *buf, int len, char *title, char *prompt, CWnd *wnd);
380
381 void CWorldTexturesDialog::OnWtexdlgAddnew() {
382 char filename[255], dir[255], fname[128], ext[32];
383 char cur_name[100];
384 int bm_handle, tex_handle;
385 int anim = 0, c;
386
387 if (!Network_up) {
388 OutrageMessageBox("Sorry babe, the network is down. This action is a no-no.\n");
389 return;
390 }
391
392 int alt_format = IsDlgButtonChecked(IDC_IMPORT_4444);
393 int format = 0;
394
395 if (alt_format) {
396 int answer = MessageBox("Are you sure you wish to import this texture with a 4444 format?", "Question", MB_YESNO);
397 if (answer == IDNO)
398 return;
399
400 format = BITMAP_FORMAT_4444;
401 }
402
403 CString filter =
404 "Descent III files "
405 "(*.itl,*.tga,*.bbm,*.lbm,*.ogf,*.oaf,*.ilf,*.pcx)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.oaf;*.ifl;*.itl||";
406
407 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir)))
408 return;
409
410 ddio_SplitPath(filename, dir, fname, ext);
411
412 // Okay, we selected a file. Lets do what needs to be done here.
413 if (!strnicmp(ext, "ITL", 3)) {
414 LoadITLFile(filename, NORMAL_TEXTURE);
415 UpdateDialog();
416 return;
417 }
418
419 bm_handle = LoadTextureImage(filename, &anim, NORMAL_TEXTURE, 0, 0, format);
420
421 if (bm_handle < 0) {
422 OutrageMessageBox("Couldn't open that bitmap/anim file.");
423 return;
424 }
425
426 tex_handle = AllocTexture();
427
428 strcpy(cur_name, fname); // Start with the filename
429 char *t = strchr(cur_name, '.'); // Strip the extention
430 if (!t)
431 t = cur_name + strlen(cur_name);
432 *t = 0;
433 c = 0;
434 do { // Make sure the name not already in use
435 if (FindTextureName(cur_name) == -1)
436 break;
437
438 *t = 0;
439 sprintf(cur_name, "%s%d", cur_name, ++c);
440 } while (1);
441 cur_name[0] = toupper(cur_name[0]); // make first char uppercase
442
443 // Get the name from the user
444 if (!InputTextureName(cur_name, sizeof(cur_name), "Texture name", "Enter a name for your texture:", this)) {
445 FreeTexture(tex_handle);
446 return;
447 }
448
449 strcpy(GameTextures[tex_handle].name, cur_name);
450
451 if (anim)
452 GameTextures[tex_handle].flags |= TF_ANIMATED;
453 else
454 GameTextures[tex_handle].flags &= ~TF_ANIMATED;
455
456 GameTextures[tex_handle].bm_handle = bm_handle;
457
458 mprintf(0, "Making a copy of this bitmap/anim locally...\n");
459
460 if (!anim) {
461 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
462 GameBitmaps[GameTextures[tex_handle].bm_handle].name);
463 bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle);
464 } else {
465 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
466 GameVClips[GameTextures[tex_handle].bm_handle].name);
467 SaveVClip(filename, GameTextures[tex_handle].bm_handle);
468 }
469
470 CheckIfTextureIsTmap2(tex_handle);
471
472 mng_AllocTrackLock(cur_name, PAGETYPE_TEXTURE);
473
474 D3EditState.texdlg_texture = tex_handle;
475
476 UpdateDialog();
477 }
478
479 void CWorldTexturesDialog::OnPaint() {
480 CPaintDC dc(this); // device context for painting
481
482 // TODO: Add your message handler code here
483
484 // Do not call CDialog::OnPaint() for painting messages
485 m_RedrawListbox = 1;
486 UpdateDialog();
487 }
488
489 void CWorldTexturesDialog::OnNext() {
490 D3EditState.texdlg_texture = GetNextTexture(D3EditState.texdlg_texture);
491
492 UpdateDialog();
493 }
494
495 void CWorldTexturesDialog::OnPrevious() {
496
497 D3EditState.texdlg_texture = GetPreviousTexture(D3EditState.texdlg_texture);
498
499 UpdateDialog();
500 }
501
502 // Redraw the dialog based on our current texture
503 void CWorldTexturesDialog::UpdateDialog(void) {
504 CEdit *ebox;
505 CButton *bbox;
506 int n = D3EditState.texdlg_texture;
507 int last_texture = -1;
508 char str[50];
509 int i;
510
511 if (GameTextures[n].used == 0) {
512 n = 0;
513 D3EditState.texdlg_texture = 0;
514 }
515
516 ebox = (CEdit *)GetDlgItem(IDC_TEX_NUM);
517 sprintf(str, "%d", n);
518 ebox->SetWindowText(str);
519
520 ebox = (CEdit *)GetDlgItem(IDC_BITMAP_NAME);
521 if (GameTextures[n].flags & TF_ANIMATED)
522 ebox->SetWindowText(GameVClips[GameTextures[n].bm_handle].name);
523 else
524 ebox->SetWindowText(GameBitmaps[GameTextures[n].bm_handle].name);
525
526 SendDlgItemMessage(IDC_DESTROY_PULLDOWN, CB_RESETCONTENT, 0, 0);
527 for (i = 0; i < MAX_TEXTURES; i++) {
528 if (GameTextures[i].used)
529 SendDlgItemMessage(IDC_DESTROY_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name);
530 }
531
532 ebox = (CEdit *)GetDlgItem(IDC_DESTROY_PULLDOWN);
533
534 if (GameTextures[n].flags & TF_DESTROYABLE)
535 SendDlgItemMessage(IDC_DESTROY_PULLDOWN, CB_SELECTSTRING, 0,
536 (LPARAM)(LPCTSTR)GameTextures[GameTextures[n].destroy_handle].name);
537 else
538 ebox->SetWindowText("NOT DESTROYABLE");
539
540 ebox = (CEdit *)GetDlgItem(IDC_REFLECT);
541 sprintf(str, "%f", GameTextures[n].reflectivity);
542 ebox->SetWindowText(str);
543
544 ebox = (CEdit *)GetDlgItem(IDC_ALPHA_EDIT);
545 sprintf(str, "%f", GameTextures[n].alpha);
546 ebox->SetWindowText(str);
547
548 ebox = (CEdit *)GetDlgItem(IDC_SPEED_EDIT);
549 sprintf(str, "%f", GameTextures[n].speed);
550 ebox->SetWindowText(str);
551
552 ebox = (CEdit *)GetDlgItem(IDC_TEXTURE_WIDTH);
553 if (GameTextures[n].flags & TF_ANIMATED)
554 sprintf(str, "Width: %d", bm_w(GameVClips[GameTextures[n].bm_handle].frames[0], 0));
555 else
556 sprintf(str, "Width: %d", bm_w(GameTextures[n].bm_handle, 0));
557
558 ebox->SetWindowText(str);
559
560 ebox = (CEdit *)GetDlgItem(IDC_TEXTURE_HEIGHT);
561 if (GameTextures[n].flags & TF_ANIMATED)
562 sprintf(str, "Height: %d", bm_h(GameVClips[GameTextures[n].bm_handle].frames[0], 0));
563 else
564 sprintf(str, "Height: %d", bm_h(GameTextures[n].bm_handle, 0));
565 ebox->SetWindowText(str);
566
567 ebox = (CEdit *)GetDlgItem(IDC_RED_LIGHTING);
568 sprintf(str, "%f", GameTextures[n].r);
569 ebox->SetWindowText(str);
570
571 ebox = (CEdit *)GetDlgItem(IDC_GREEN_LIGHTING);
572 sprintf(str, "%f", GameTextures[n].g);
573 ebox->SetWindowText(str);
574
575 ebox = (CEdit *)GetDlgItem(IDC_BLUE_LIGHTING);
576 sprintf(str, "%f", GameTextures[n].b);
577 ebox->SetWindowText(str);
578
579 ebox = (CEdit *)GetDlgItem(IDC_DAMAGE);
580 itoa(GameTextures[n].damage, str, 10);
581 ebox->SetWindowText(str);
582
583 ebox = (CEdit *)GetDlgItem(IDC_SLIDEU);
584 sprintf(str, "%f", GameTextures[n].slide_u);
585 ebox->SetWindowText(str);
586
587 ebox = (CEdit *)GetDlgItem(IDC_SLIDEV);
588 sprintf(str, "%f", GameTextures[n].slide_v);
589 ebox->SetWindowText(str);
590
591 // Update combo
592 if (n != last_texture)
593 m_ambient_sound_combo.SetSelected(GameTextures[n].sound);
594
595 ebox = (CEdit *)GetDlgItem(IDC_TEXTURE_AMBIENT_SOUND_VOLUME);
596 sprintf(str, "%.1f", GameTextures[n].sound_volume);
597 ebox->SetWindowText(str);
598
599 SendDlgItemMessage(IDC_PALETTIZED_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "Running in 16bit mode");
600
601 SendDlgItemMessage(IDC_TEX_LIST, CB_RESETCONTENT, 0, 0);
602 for (i = 0; i < MAX_TEXTURES; i++) {
603 if (GameTextures[i].used)
604 SendDlgItemMessage(IDC_TEX_LIST, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name);
605 }
606 SendDlgItemMessage(IDC_TEX_LIST, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[n].name);
607
608 bbox = (CButton *)GetDlgItem(IDC_CHECKIN);
609 if (mng_FindTrackLock(GameTextures[n].name, PAGETYPE_TEXTURE) == -1) {
610 bbox->EnableWindow(FALSE);
611 bbox = (CButton *)GetDlgItem(IDC_LOCK);
612 bbox->EnableWindow(TRUE);
613 } else {
614 bbox->EnableWindow(TRUE);
615 bbox = (CButton *)GetDlgItem(IDC_LOCK);
616 bbox->EnableWindow(FALSE);
617 }
618
619 bbox = (CButton *)GetDlgItem(IDC_CHECK_ANIMATE);
620 bbox->EnableWindow(FALSE);
621
622 // Prevent some schmo from locking the sample texture
623 if (!stricmp(GameTextures[n].name, "SAMPLE TEXTURE")) {
624 bbox = (CButton *)GetDlgItem(IDC_LOCK);
625 bbox->EnableWindow(FALSE);
626 }
627
628 if (GameTextures[n].r > 0 || GameTextures[n].g > 0 || GameTextures[n].b > 0)
629 GameTextures[n].flags |= TF_LIGHT;
630 else
631 GameTextures[n].flags &= ~TF_LIGHT;
632
633 // Do the damn bitmask stuff
634
635 CheckDlgButton(IDC_VOLATILE, GameTextures[n].flags & TF_VOLATILE ? 1 : 0);
636 CheckDlgButton(IDC_WATER, GameTextures[n].flags & TF_WATER ? 1 : 0);
637 CheckDlgButton(IDC_LAVA_CHECKBOX, GameTextures[n].flags & TF_LAVA ? 1 : 0);
638 CheckDlgButton(IDC_RUBBLE_CHECKBOX, GameTextures[n].flags & TF_RUBBLE ? 1 : 0);
639 CheckDlgButton(IDC_SMOOTH_SPEC_CHECK, GameTextures[n].flags & TF_SMOOTH_SPECULAR ? 1 : 0);
640 CheckDlgButton(IDC_FORCEFIELD, GameTextures[n].flags & TF_FORCEFIELD ? 1 : 0);
641 CheckDlgButton(IDC_CHECK_ANIMATE, GameTextures[n].flags & TF_ANIMATED ? 1 : 0);
642 CheckDlgButton(IDC_CHECK_TMAP2, GameTextures[n].flags & TF_TMAP2 ? 1 : 0);
643 CheckDlgButton(IDC_CHECK_DESTROY, GameTextures[n].flags & TF_DESTROYABLE ? 1 : 0);
644 CheckDlgButton(IDC_CHECK_BREAKABLE, GameTextures[n].flags & TF_BREAKABLE ? 1 : 0);
645 CheckDlgButton(IDC_4444_CHECK, GameBitmaps[GetTextureBitmap(n, 0)].format == BITMAP_FORMAT_4444 ? 1 : 0);
646
647 // Do coronas
648 CheckDlgButton(IDC_CORONA_A, GameTextures[n].corona_type == 0);
649 CheckDlgButton(IDC_CORONA_B, GameTextures[n].corona_type == 1);
650 CheckDlgButton(IDC_CORONA_C, GameTextures[n].corona_type == 2);
651 CheckDlgButton(IDC_CORONA_D, GameTextures[n].corona_type == 3);
652
653 CheckDlgButton(IDC_LIGHT_CHECK, GameTextures[n].flags & TF_LIGHT ? 1 : 0);
654 CheckDlgButton(IDC_MINE_TEXTURE, GameTextures[n].flags & TF_MINE ? 1 : 0);
655 CheckDlgButton(IDC_TERRAIN_TEXTURE, GameTextures[n].flags & TF_TERRAIN ? 1 : 0);
656 CheckDlgButton(IDC_OBJECT_TEXTURE, GameTextures[n].flags & TF_OBJECT ? 1 : 0);
657 CheckDlgButton(IDC_EFFECT_TEXTURE, GameTextures[n].flags & TF_EFFECT ? 1 : 0);
658 CheckDlgButton(IDC_HUD_COCKPIT_TEXTURE, GameTextures[n].flags & TF_HUD_COCKPIT ? 1 : 0);
659 CheckDlgButton(IDC_LIGHT_TEXTURE, GameTextures[n].flags & TF_LIGHT ? 1 : 0);
660 CheckDlgButton(IDC_PROCEDURAL_CHECK, GameTextures[n].flags & TF_PROCEDURAL ? 1 : 0);
661 CheckDlgButton(IDC_WATER_PROCEDURAL_CHECK, GameTextures[n].flags & TF_WATER_PROCEDURAL ? 1 : 0);
662 CheckDlgButton(IDC_FORCE_LIGHTMAPS, GameTextures[n].flags & TF_FORCE_LIGHTMAP ? 1 : 0);
663 CheckDlgButton(IDC_SATURATE_LIGHTMAP, GameTextures[n].flags & TF_SATURATE_LIGHTMAP ? 1 : 0);
664
665 CheckDlgButton(IDC_METAL_CHECK, GameTextures[n].flags & TF_METAL ? 1 : 0);
666 CheckDlgButton(IDC_MARBLE_CHECK, GameTextures[n].flags & TF_MARBLE ? 1 : 0);
667 CheckDlgButton(IDC_PLASTIC_CHECK, GameTextures[n].flags & TF_PLASTIC ? 1 : 0);
668
669 CheckDlgButton(IDC_TEXTURE_FLY_THRU_CHECK, GameTextures[n].flags & TF_FLY_THRU ? 1 : 0);
670
671 CheckDlgButton(IDC_PING_PONG, GameTextures[n].flags & TF_PING_PONG ? 1 : 0);
672 CheckDlgButton(IDC_SATURATE, GameTextures[n].flags & TF_SATURATE ? 1 : 0);
673
674 CheckDlgButton(IDC_SRC_BUMP, m_bumpmap == 0 ? 1 : 0);
675 CheckDlgButton(IDC_BUMP1, m_bumpmap == 1 ? 1 : 0);
676 CheckDlgButton(IDC_BUMP2, m_bumpmap == 2 ? 1 : 0);
677 CheckDlgButton(IDC_BUMP3, m_bumpmap == 3 ? 1 : 0);
678 CheckDlgButton(IDC_BUMP4, m_bumpmap == 4 ? 1 : 0);
679
680 if (GameTextures[n].flags & TF_ANIMATED)
681 CheckDlgButton(IDC_CHECK_MIPPED, 0);
682 else {
683 if (bm_mipped(GameTextures[n].bm_handle))
684 CheckDlgButton(IDC_CHECK_MIPPED, 1);
685 else
686 CheckDlgButton(IDC_CHECK_MIPPED, 0);
687 }
688
689 bbox = (CButton *)GetDlgItem(IDC_PROCEDURAL_BUTTON);
690 if (GameTextures[n].flags & TF_PROCEDURAL)
691 bbox->EnableWindow(TRUE);
692 else
693 bbox->EnableWindow(FALSE);
694
695 bbox = (CButton *)GetDlgItem(IDC_WATER_PROCEDURAL_CHECK);
696 if (GameTextures[n].flags & TF_PROCEDURAL)
697 bbox->EnableWindow(TRUE);
698 else
699 bbox->EnableWindow(FALSE);
700
701 UpdateTextureViews(1);
702
703 last_texture = n;
704 }
705
706 void CWorldTexturesDialog::UpdateTextureViews(int frame) {
707 // Display texture in IDC_TEXTUREVIEW
708 int n = D3EditState.texdlg_texture;
709 int freebitmap = 0;
710
711 if (!GameTextures[n].used) {
712 n = GetNextTexture(n);
713 D3EditState.texdlg_texture = n;
714 return;
715 }
716
717 CWnd *texwnd;
718 RECT rect;
719 int x, y, bm_handle, w, h;
720 static int last_frame = 0;
721 static int last_texture = -1;
722 static int last_tex_count = -1;
723 int update_listbox = 0;
724
725 DrawSwatch(IDC_TEXTURE_SWATCH, GameTextures[n].r, GameTextures[n].g, GameTextures[n].b);
726
727 if (last_texture == n && last_tex_count == Num_textures && m_RedrawListbox == 0)
728 update_listbox = 0;
729 else {
730 m_RedrawListbox = 0;
731 update_listbox = 1;
732 last_texture = n;
733 last_tex_count = Num_textures;
734 }
735
736 if (!GameTextures[m_TexStart].used)
737 m_TexStart = GetNextTexture(m_TexStart);
738
739 frame = last_frame++;
740
741 texwnd = GetDlgItem(IDC_TEXTUREVIEW);
742 texwnd->GetWindowRect(&rect);
743 ScreenToClient(&rect);
744
745 Desktop_surf->attach_to_window((unsigned)m_hWnd);
746
747 w = rect.right - rect.left;
748 h = rect.bottom - rect.top;
749
750 // Desktop_surf->clear(rect.left,rect.top,w,h);
751
752 bm_handle = GetTextureBitmap(n, frame);
753
754 if (GameTextures[n].flags & TF_TEXTURE_256 && bm_w(bm_handle, 0) == 256) {
755 // Downsize this bitmap to make it fit on screen
756 int temp_bm = bm_AllocBitmap(128, 128, (128 * 128 * 2) / 3);
757 GameBitmaps[temp_bm].format = GameBitmaps[bm_handle].format;
758 if (GameBitmaps[bm_handle].flags & BF_MIPMAPPED)
759 GameBitmaps[temp_bm].flags |= BF_MIPMAPPED;
760 bm_ScaleBitmapToBitmap(temp_bm, bm_handle);
761 bm_handle = temp_bm;
762 freebitmap = 1;
763 }
764
765 m_TextureSurf.create(bm_w(bm_handle, 0), bm_h(bm_handle, 0), bm_bpp(bm_handle));
766 m_TextureSurf.load(bm_handle);
767
768 x = rect.left + ((rect.right - rect.left) / 2) - m_TextureSurf.width() / 2;
769 y = rect.top + ((rect.bottom - rect.top) / 2) - m_TextureSurf.height() / 2;
770
771 Desktop_surf->blt(x, y, &m_TextureSurf);
772 m_TextureSurf.free();
773 if (freebitmap)
774 bm_FreeBitmap(bm_handle);
775
776 // Display texture in IDC_DESTROYVIEW
777
778 if (GameTextures[n].flags & TF_DESTROYABLE && GameTextures[n].destroy_handle >= 0) {
779 CWnd *texwnd;
780 RECT rect;
781 int x, y, bm_handle;
782
783 texwnd = GetDlgItem(IDC_DESTROYVIEW);
784 texwnd->GetWindowRect(&rect);
785 ScreenToClient(&rect);
786
787 bm_handle = GetTextureBitmap(GameTextures[n].destroy_handle, frame);
788 m_TextureSurf.create(bm_w(bm_handle, 0), bm_h(bm_handle, 0), bm_bpp(bm_handle));
789 m_TextureSurf.load(bm_handle);
790
791 x = rect.left + ((rect.right - rect.left) / 2) - m_TextureSurf.width() / 2;
792 y = rect.top + ((rect.bottom - rect.top) / 2) - m_TextureSurf.height() / 2;
793
794 Desktop_surf->blt(x, y, &m_TextureSurf);
795 m_TextureSurf.free();
796 } else {
797 CWnd *texwnd;
798 RECT rect;
799
800 texwnd = GetDlgItem(IDC_DESTROYVIEW);
801 texwnd->GetWindowRect(&rect);
802 ScreenToClient(&rect);
803 w = rect.right - rect.left;
804 h = rect.bottom - rect.top;
805
806 Desktop_surf->clear(rect.left, rect.top, w, h);
807 }
808
809 /*// Display bumpmaps
810 if ((GameTextures[n].src_bumpmap!=-1 && m_bumpmap==0) || (GameTextures[n].bumpmaps[m_bumpmap-1]!=-1))
811 {
812 CWnd *texwnd;
813 RECT rect;
814 int x, y, bm_handle;
815 uint16_t *src_data,*dest_data;
816 int bump_handle;
817
818 if (m_bumpmap==0)
819 bump_handle=GameTextures[n].src_bumpmap;
820 else
821 bump_handle=GameTextures[n].bumpmaps[m_bumpmap-1];
822
823 ASSERT (bump_handle>=0);
824
825 texwnd = GetDlgItem(IDC_BUMPVIEW);
826 texwnd->GetWindowRect(&rect);
827 ScreenToClient(&rect);
828
829 bm_handle=bm_AllocBitmap (BUMP_WIDTH,BUMP_HEIGHT,0);
830 ASSERT (bm_handle>=0);
831
832 src_data=(uint16_t *)bump_data(bump_handle);
833 dest_data=(uint16_t *)bm_data(bm_handle,0);
834
835 memcpy (dest_data,src_data,BUMP_WIDTH*BUMP_HEIGHT*2);
836
837 bm_ChangeSize (bm_handle,128,128);
838
839 m_TextureSurf.create(bm_w(bm_handle,0), bm_h(bm_handle,0), bm_bpp(bm_handle));
840 m_TextureSurf.load(bm_handle);
841
842 x = rect.left + ((rect.right-rect.left)/2) - m_TextureSurf.width()/2;
843 y = rect.top + ((rect.bottom-rect.top)/2) - m_TextureSurf.height()/2;
844
845 Desktop_surf->blt(x, y, &m_TextureSurf);
846 m_TextureSurf.free();
847 bm_FreeBitmap (bm_handle);
848 }
849 else*/
850 {
851 CWnd *texwnd;
852 RECT rect;
853
854 texwnd = GetDlgItem(IDC_BUMPVIEW);
855 texwnd->GetWindowRect(&rect);
856 ScreenToClient(&rect);
857 w = rect.right - rect.left;
858 h = rect.bottom - rect.top;
859
860 Desktop_surf->clear(rect.left, rect.top, w, h);
861 }
862
863 // Now do that listbox
864
865 if (update_listbox) {
866 // resume updating this damned 'listbox'
867 texwnd = GetDlgItem(IDC_TEXTURE_LISTBOX);
868 texwnd->GetWindowRect(&rect);
869 ScreenToClient(&rect);
870 w = rect.right - rect.left;
871 h = rect.bottom - rect.top;
872
873 Desktop_surf->clear(rect.left, rect.top, w, h);
874
875 int texnum = m_TexStart;
876 int count = 0, done = 0;
877
878 while (!done) {
879 m_TextureSurf.create(32, 32, BPP_16);
880
881 bm_handle = GetTextureBitmap(texnum, 0);
882
883 if (bm_handle >= 0) {
884 m_TextureSurf.load(bm_handle);
885
886 x = 4 + rect.left + ((count % TEXTURES_PER_ROW) * 40);
887 y = 4 + rect.top + ((count / TEXTURES_PER_ROW) * 40);
888
889 if (m_CheckForTextureList) {
890
891 if (m_CheckX >= x && m_CheckX <= (x + 40) && m_CheckY >= y && m_CheckY <= (y + 40)) {
892 m_CheckForTextureList = 0;
893 D3EditState.texdlg_texture = texnum;
894 m_TextureSurf.free();
895 Desktop_surf->attach_to_window((unsigned)NULL);
896 UpdateDialog();
897 return;
898 }
899 }
900 }
901
902 if (texnum == n) // draw a white box if this is the current texture
903 {
904 grViewport *vport = new grViewport(&m_TextureSurf);
905
906 int x = 0, y = 0;
907
908 vport->lock();
909 vport->line(GR_RGB(255, 255, 255), x, y, x + vport->width() - 1, y);
910 vport->line(GR_RGB(255, 255, 255), x + vport->width() - 1, y, x + vport->width() - 1, y + vport->height() - 1);
911 vport->line(GR_RGB(255, 255, 255), x + vport->width() - 1, y + vport->height() - 1, x, y + vport->height() - 1);
912 vport->line(GR_RGB(255, 255, 255), x, y + vport->height() - 1, x, y);
913 vport->unlock();
914
915 delete vport;
916 }
917
918 Desktop_surf->blt(x, y, &m_TextureSurf);
919
920 texnum = GetNextTexture(texnum);
921 ASSERT(GameTextures[texnum].used);
922 m_TextureSurf.free();
923 count++;
924 if (count == TEXTURES_PER_ROW * 9)
925 done = 1;
926 if (texnum <= m_TexStart)
927 done = 1;
928 }
929
930 // must define the vertical scroll bar dimensions
931 CScrollBar *bar = (CScrollBar *)GetDlgItem(IDC_TEXLIST_VERT);
932 SCROLLINFO si;
933
934 m_TexPageLen = (count / TEXTURES_PER_ROW) + ((count % TEXTURES_PER_ROW) ? 1 : 0);
935 m_TexListPos = bar->GetScrollPos();
936 si.cbSize = sizeof(si);
937 si.fMask = SIF_ALL;
938 si.nMin = 0;
939 si.nMax = (Num_textures / TEXTURES_PER_ROW) + ((Num_textures % TEXTURES_PER_ROW) ? 1 : 0) - 1;
940 si.nPos = m_TexListPos;
941 si.nPage = m_TexPageLen;
942 bar->SetScrollInfo(&si);
943 bar->ShowScrollBar(TRUE);
944 }
945
946 m_CheckForTextureList = 0;
947 Desktop_surf->attach_to_window((unsigned)NULL);
948 }
949
950 void CWorldTexturesDialog::OnSelendokTexList() {
951 int i, cur;
952 char name[200];
953
954 cur = SendDlgItemMessage(IDC_TEX_LIST, CB_GETCURSEL, 0, 0);
955 SendDlgItemMessage(IDC_TEX_LIST, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
956
957 i = FindTextureName(name);
958
959 if (i == -1) {
960 mprintf(0, "Possible corrupted texture list, but probably nothing.");
961 UpdateDialog();
962 }
963
964 D3EditState.texdlg_texture = i;
965 UpdateDialog();
966 }
967
968 int TlockState = 0;
969 int AutoChecking = 0;
970
971 void CWorldTexturesDialog::OnLock() {
972 int n = D3EditState.texdlg_texture;
973 mngs_Pagelock temp_pl;
974 mngs_texture_page texpage;
975 int r;
976
977 if (AutoChecking != 2 && !mng_MakeLocker()) {
978 TlockState = 0;
979 return;
980 }
981
982 strcpy(temp_pl.name, GameTextures[n].name);
983 temp_pl.pagetype = PAGETYPE_TEXTURE;
984
985 r = mng_CheckIfPageLocked(&temp_pl);
986 if (r == 2) {
987 int answer;
988 answer = OutrageMessageBox(MBOX_YESNO, "This page is not even in the table file, or the database maybe corrupt. "
989 "Override to 'Unlocked'? (Select NO if you don't know what you're doing)");
990 if (answer == IDYES) {
991 strcpy(temp_pl.holder, "UNLOCKED");
992 if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) {
993 MessageBox(ErrorString, "Error!");
994 if (AutoChecking != 2)
995 mng_EraseLocker();
996 return;
997 }
998 }
999 } else if (r < 0) {
1000 OutrageMessageBox(ErrorString);
1001 TlockState = 0;
1002
1003 if (AutoChecking != 2)
1004 mng_EraseLocker();
1005
1006 return;
1007
1008 } else if (r == 1) {
1009 OutrageMessageBox(InfoString);
1010 TlockState = 0;
1011
1012 if (AutoChecking != 2)
1013 mng_EraseLocker();
1014 return;
1015
1016 } else {
1017
1018 // Everything is ok. Tell the network we're locking it and get a copy to
1019 // our local drive
1020
1021 strcpy(temp_pl.holder, TableUser);
1022 if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) {
1023 MessageBox(ErrorString, "Error!");
1024 if (AutoChecking != 2)
1025 mng_EraseLocker();
1026
1027 TlockState = 0;
1028 return;
1029 } else {
1030 if (mng_FindSpecificTexPage(temp_pl.name, &texpage)) {
1031 if (mng_AssignTexPageToTexture(&texpage, n)) {
1032 if (!mng_ReplacePage(GameTextures[n].name, GameTextures[n].name, n, PAGETYPE_TEXTURE, 1)) {
1033 OutrageMessageBox("There was problem writing that page locally!");
1034
1035 if (AutoChecking != 2)
1036 mng_EraseLocker();
1037
1038 TlockState = 0;
1039 return;
1040 }
1041 if (!AutoChecking)
1042 OutrageMessageBox("Texture locked.");
1043 } else
1044 OutrageMessageBox("There was a problem loading this texture. You might encounter problems in dealing with "
1045 "it. Good luck!");
1046
1047 mng_AllocTrackLock(GameTextures[n].name, PAGETYPE_TEXTURE);
1048
1049 if (AutoChecking != 2)
1050 UpdateDialog();
1051 TlockState = 1;
1052 } else
1053 OutrageMessageBox("Couldn't find that texture in the table file!");
1054 }
1055 }
1056
1057 if (AutoChecking != 2)
1058 mng_EraseLocker();
1059 }
1060
1061 void CWorldTexturesDialog::OnCheckin() {
1062 int n = D3EditState.texdlg_texture;
1063 mngs_Pagelock temp_pl;
1064 int r;
1065
1066 if (!(GameTextures[n].flags & TF_TEXTURE_TYPES)) {
1067 OutrageMessageBox(
1068 "You need to select what type of texture this is before checking it in (ie robot, mine, terrain, etc).");
1069 return;
1070 }
1071
1072 if (!mng_MakeLocker())
1073 return;
1074
1075 strcpy(temp_pl.name, GameTextures[n].name);
1076 temp_pl.pagetype = PAGETYPE_TEXTURE;
1077
1078 r = mng_CheckIfPageOwned(&temp_pl, TableUser);
1079 if (r < 0)
1080 OutrageMessageBox(ErrorString);
1081 else if (r == 0)
1082 OutrageMessageBox(InfoString);
1083 else {
1084 strcpy(temp_pl.holder, "UNLOCKED");
1085 if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) {
1086 OutrageMessageBox(ErrorString, "Error!");
1087 mng_EraseLocker();
1088 return;
1089 } else {
1090 if (!mng_ReplacePage(GameTextures[n].name, GameTextures[n].name, n, PAGETYPE_TEXTURE, 0))
1091 OutrageMessageBox(ErrorString);
1092 else {
1093 // Save this textures bitmap to the network for all
1094
1095 std::filesystem::path fname;
1096
1097 if (GameTextures[n].flags & TF_ANIMATED) {
1098 fname = ManageGraphicsDir / GameVClips[GameTextures[n].bm_handle].name;
1099 SaveVClip(fname, GameTextures[n].bm_handle);
1100
1101 fname = LocalManageGraphicsDir / GameVClips[GameTextures[n].bm_handle].name;
1102 SaveVClip(fname, GameTextures[n].bm_handle);
1103 } else {
1104 fname = ManageGraphicsDir / GameBitmaps[GameTextures[n].bm_handle].name;
1105 bm_SaveFileBitmap(fname, GameTextures[n].bm_handle);
1106
1107 fname = LocalManageGraphicsDir / GameBitmaps[GameTextures[n].bm_handle].name;
1108 bm_SaveFileBitmap(fname, GameTextures[n].bm_handle);
1109 }
1110
1111 if (!AutoChecking)
1112 OutrageMessageBox("Texture checked in.");
1113 int dret = mng_DeletePage(GameTextures[n].name, PAGETYPE_TEXTURE, 1);
1114 ASSERT(dret == 1);
1115 mng_EraseLocker();
1116
1117 int p = mng_FindTrackLock(GameTextures[n].name, PAGETYPE_TEXTURE);
1118 ASSERT(p != -1);
1119 mng_FreeTrackLock(p);
1120 UpdateDialog();
1121 }
1122 }
1123 }
1124 mng_EraseLocker();
1125 }
1126
1127 void CWorldTexturesDialog::OnRcsStatus() {
1128 char str[10000];
1129 int total = 0;
1130
1131 mng_DisplayLockList(TableUser);
1132
1133 sprintf(str, "User %s has these textures held locally:\n\n", TableUser);
1134 for (int i = 0; i < MAX_TRACKLOCKS; i++) {
1135 if (GlobalTrackLocks[i].used && GlobalTrackLocks[i].pagetype == PAGETYPE_TEXTURE) {
1136 char temp[90];
1137
1138 sprintf(temp, "%s", GlobalTrackLocks[i].name);
1139 strcat(str, temp);
1140 strcat(str, "\n");
1141 total++;
1142 }
1143 }
1144
1145 if (total != 0) {
1146 // Display that string
1147 MessageBox(str, "Textures", MB_OK);
1148 }
1149 }
1150
1151 void CWorldTexturesDialog::SaveTexturesOnClose() {
1152 int i, t;
1153
1154 // When closing, save all our textures locally
1155
1156 if (!Network_up)
1157 return; // don't save a damn thing if the network is down
1158
1159 for (i = 0; i < MAX_TRACKLOCKS; i++) {
1160 if (GlobalTrackLocks[i].used == 1 && GlobalTrackLocks[i].pagetype == PAGETYPE_TEXTURE) {
1161 t = FindTextureName(GlobalTrackLocks[i].name);
1162 ASSERT(t != -1);
1163
1164 mng_ReplacePage(GameTextures[t].name, GameTextures[t].name, t, PAGETYPE_TEXTURE, 1);
1165
1166 std::filesystem::path fname;
1167
1168 if (GameTextures[t].flags & TF_ANIMATED) {
1169 fname = LocalManageGraphicsDir / GameVClips[GameTextures[t].bm_handle].name;
1170 SaveVClip(fname, GameTextures[t].bm_handle);
1171 } else {
1172 fname = LocalManageGraphicsDir / GameBitmaps[GameTextures[t].bm_handle].name;
1173 bm_SaveFileBitmap(fname, GameTextures[t].bm_handle);
1174 }
1175 }
1176 }
1177 }
1178
1179 BOOL CWorldTexturesDialog::DestroyWindow() {
1180
1181 CWnd::KillTimer(1);
1182 SaveTexturesOnClose();
1183
1184 return CDialog::DestroyWindow();
1185 }
1186
1187 void CWorldTexturesDialog::OnDelete() {
1188 int answer, tl;
1189 mngs_Pagelock pl;
1190 int n = D3EditState.texdlg_texture;
1191
1192 if ((tl = mng_FindTrackLock(GameTextures[n].name, PAGETYPE_TEXTURE)) == -1) {
1193 // OutrageMessageBox ("This texture is not yours to delete. Lock first.");
1194 answer = MessageBox("This texture is not locked...do you wish to lock it so you can delete it?",
1195 GameTextures[n].name, MB_YESNO);
1196 if (answer == IDNO)
1197 return;
1198
1199 AutoChecking = 1;
1200 TlockState = 0;
1201
1202 OnLock();
1203 if (!TlockState) {
1204 OutrageMessageBox("Couldn't lock that texture to delete it!");
1205 AutoChecking = 0;
1206 return;
1207 }
1208 AutoChecking = 0;
1209 tl = mng_FindTrackLock(GameTextures[n].name, PAGETYPE_TEXTURE);
1210 ASSERT(tl != -1);
1211
1212 // return;
1213 }
1214 answer = MessageBox("Are you sure you want to delete this texture?", GameTextures[n].name, MB_YESNO);
1215 if (answer == IDNO)
1216 return;
1217
1218 if (!mng_MakeLocker())
1219 return;
1220
1221 strncpy(pl.name, GameTextures[n].name, 30);
1222 pl.pagetype = PAGETYPE_TEXTURE;
1223 if (mng_CheckIfPageOwned(&pl, TableUser) != 1) {
1224 mng_FreeTrackLock(tl);
1225 if (!mng_DeletePage(GameTextures[n].name, PAGETYPE_TEXTURE, 1)) {
1226 mprintf(0, ErrorString);
1227 Int3();
1228 }
1229 } else {
1230 mng_FreeTrackLock(tl);
1231 mng_DeletePage(GameTextures[n].name, PAGETYPE_TEXTURE, 0);
1232 mng_DeletePage(GameTextures[n].name, PAGETYPE_TEXTURE, 1);
1233
1234 mng_DeletePagelock(GameTextures[n].name, PAGETYPE_TEXTURE);
1235 }
1236
1237 if (GameTextures[n].flags & TF_ANIMATED)
1238 FreeVClip(GameTextures[n].bm_handle);
1239 else
1240 bm_FreeBitmap(GameTextures[n].bm_handle);
1241
1242 FreeTexture(n);
1243 mng_EraseLocker();
1244
1245 MessageBox("Texture deleted.");
1246 D3EditState.texdlg_texture = GetNextTexture(n);
1247 if (D3EditState.texdlg_texture == n)
1248 mprintf(0, "Wrapped!\n");
1249
1250 UpdateDialog();
1251 }
1252
1253 // The following functions harvest the checkbuttons
1254
1255 void CWorldTexturesDialog::OnVolatile() {
1256 int c = IsDlgButtonChecked(IDC_VOLATILE);
1257 int n = D3EditState.texdlg_texture;
1258
1259 if (c)
1260 GameTextures[n].flags |= TF_VOLATILE;
1261 else
1262 GameTextures[n].flags &= ~TF_VOLATILE;
1263 }
1264
1265 void CWorldTexturesDialog::OnWater() {
1266 int c = IsDlgButtonChecked(IDC_WATER);
1267 int n = D3EditState.texdlg_texture;
1268
1269 if (c)
1270 GameTextures[n].flags |= TF_WATER;
1271 else
1272 GameTextures[n].flags &= ~TF_WATER;
1273 }
1274
1275 void CWorldTexturesDialog::OnForcefield() {
1276 int n = D3EditState.texdlg_texture;
1277 int c = IsDlgButtonChecked(IDC_FORCEFIELD);
1278
1279 if (c)
1280 GameTextures[n].flags |= TF_FORCEFIELD;
1281 else
1282 GameTextures[n].flags &= ~TF_FORCEFIELD;
1283 }
1284
1285 void CWorldTexturesDialog::OnCheckAnimate() {
1286 int n = D3EditState.texdlg_texture;
1287 int c = IsDlgButtonChecked(IDC_CHECK_ANIMATE);
1288
1289 if (c)
1290 GameTextures[n].flags |= TF_ANIMATED;
1291 else
1292 GameTextures[n].flags &= ~TF_ANIMATED;
1293 }
1294
1295 void CWorldTexturesDialog::OnLoadBitmap() {
1296 char filename[255];
1297 int bm_handle;
1298 int anim = 0;
1299 int n = D3EditState.texdlg_texture;
1300 int tex_size = NORMAL_TEXTURE;
1301
1302 CString filter =
1303 "Descent III files (*.tga,*.bbm,*.lbm,*.ogf,*.oaf,*.ilf,*.pcx)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.oaf;*.ifl||";
1304
1305 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir)))
1306 return;
1307
1308 // Okay, we selected a file. Lets do what needs to be done here.
1309 if (GameTextures[n].flags & TF_TEXTURE_64)
1310 tex_size = SMALL_TEXTURE;
1311 else if (GameTextures[n].flags & TF_TEXTURE_32)
1312 tex_size = TINY_TEXTURE;
1313 else if (GameTextures[n].flags & TF_TEXTURE_256)
1314 tex_size = HUGE_TEXTURE;
1315
1316 int format = GameBitmaps[GetTextureBitmap(n, 0)].format;
1317
1318 bm_handle = LoadTextureImage(filename, &anim, tex_size, 0, 0, format);
1319
1320 if (bm_handle < 0) {
1321 OutrageMessageBox("Could not load that bitmap...restoring previous bitmap.");
1322 return;
1323 }
1324
1325 GameTextures[n].bm_handle = bm_handle;
1326
1327 if (anim)
1328 GameTextures[n].flags |= TF_ANIMATED;
1329 else
1330 GameTextures[n].flags &= ~TF_ANIMATED;
1331
1332 mprintf(0, "Making a copy of this bitmap locally...\n");
1333
1334 if (anim) {
1335 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1336 GameVClips[GameTextures[n].bm_handle].name);
1337 SaveVClip(filename, GameTextures[n].bm_handle);
1338 } else {
1339 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1340 GameBitmaps[GameTextures[n].bm_handle].name);
1341 bm_SaveFileBitmap(filename, GameTextures[n].bm_handle);
1342 }
1343
1344 CheckIfTextureIsTmap2(n);
1345 UpdateDialog();
1346 }
1347
1348 void CWorldTexturesDialog::OnCheckDestroy() {
1349 int n = D3EditState.texdlg_texture;
1350 int c = IsDlgButtonChecked(IDC_CHECK_DESTROY);
1351
1352 if (c) {
1353 GameTextures[n].flags |= TF_DESTROYABLE;
1354 GameTextures[n].destroy_handle = n;
1355 } else
1356 GameTextures[n].flags &= ~TF_DESTROYABLE;
1357
1358 UpdateDialog();
1359 }
1360
1361 void CWorldTexturesDialog::OnKillfocusReflect() {
1362 CEdit *ebox;
1363 char name[20];
1364 int n = D3EditState.texdlg_texture;
1365
1366 ebox = (CEdit *)GetDlgItem(IDC_REFLECT);
1367 ebox->GetWindowText(name, 20);
1368
1369 GameTextures[n].reflectivity = atof(name);
1370
1371 if (GameTextures[n].reflectivity > 1)
1372 GameTextures[n].reflectivity = 1.0f;
1373 if (GameTextures[n].reflectivity < 0)
1374 GameTextures[n].reflectivity = 0.0f;
1375 }
1376
1377 void CWorldTexturesDialog::OnKillfocusSlideu() {
1378 CEdit *ebox;
1379 char name[20];
1380 int n = D3EditState.texdlg_texture;
1381
1382 ebox = (CEdit *)GetDlgItem(IDC_SLIDEU);
1383 ebox->GetWindowText(name, 20);
1384
1385 GameTextures[n].slide_u = atof(name);
1386 }
1387
1388 void CWorldTexturesDialog::OnKillfocusSlidev() {
1389 CEdit *ebox;
1390 char name[20];
1391 int n = D3EditState.texdlg_texture;
1392
1393 ebox = (CEdit *)GetDlgItem(IDC_SLIDEV);
1394 ebox->GetWindowText(name, 20);
1395
1396 GameTextures[n].slide_v = atof(name);
1397 }
1398
1399 void CWorldTexturesDialog::OnKillfocusDamage() {
1400 CEdit *ebox;
1401 char name[20];
1402 int n = D3EditState.texdlg_texture;
1403
1404 ebox = (CEdit *)GetDlgItem(IDC_DAMAGE);
1405 ebox->GetWindowText(name, 20);
1406
1407 GameTextures[n].damage = atoi(name);
1408 }
1409
1410 void CWorldTexturesDialog::OnKillfocusTexNum() {
1411 CEdit *ebox;
1412 char name[20];
1413 int n;
1414
1415 ebox = (CEdit *)GetDlgItem(IDC_TEX_NUM);
1416 ebox->GetWindowText(name, 20);
1417
1418 n = atoi(name);
1419
1420 if (!GameTextures[n].used) {
1421 int a = MessageBox("That is not a valid texture number...show anyway? (may cause a crash)", "WARNING", MB_YESNO);
1422 if (a == IDNO) {
1423 char str[30];
1424 sprintf(str, "%d", D3EditState.texdlg_texture);
1425 ebox->SetWindowText(str);
1426 return;
1427 }
1428 }
1429
1430 D3EditState.texdlg_texture = n;
1431 UpdateDialog();
1432 }
1433
1434 BOOL CWorldTexturesDialog::OnInitDialog() {
1435 CDialog::OnInitDialog();
1436 CWnd::SetTimer(1, 100, NULL);
1437
1438 int n = D3EditState.texdlg_texture;
1439 m_ambient_sound_combo.Init(GameTextures[n].sound);
1440
1441 return TRUE; // return TRUE unless you set the focus to a control
1442 // EXCEPTION: OCX Property Pages should return FALSE
1443 }
1444
1445 void CWorldTexturesDialog::OnTimer(UINT nIDEvent) {
1446
1447 int n = D3EditState.texdlg_texture;
1448
1449 if (GameTextures[n].flags & TF_ANIMATED ||
1450 ((GameTextures[n].flags & TF_DESTROYABLE) && (GameTextures[GameTextures[n].destroy_handle].flags & TF_ANIMATED)))
1451 UpdateTextureViews(1);
1452
1453 CDialog::OnTimer(nIDEvent);
1454 }
1455
1456 void CWorldTexturesDialog::OnLButtonDown(UINT nFlags, CPoint point) {
1457 // TODO: Add your message handler code here and/or call default
1458
1459 m_CheckForTextureList = 1;
1460 m_CheckX = point.x;
1461 m_CheckY = point.y;
1462
1463 CDialog::OnLButtonDown(nFlags, point);
1464
1465 m_RedrawListbox = 1;
1466 UpdateDialog();
1467 }
1468
1469 void CWorldTexturesDialog::TextureListUp(int rows) {
1470 int old = m_TexStart;
1471 int done = 0, count = 0;
1472
1473 while ((count < (TEXTURES_PER_ROW * rows)) && !done) {
1474
1475 m_TexStart = GetPreviousTexture(m_TexStart);
1476
1477 if (old <= m_TexStart) {
1478 m_TexStart = old;
1479 done = 1;
1480 } else
1481 count++;
1482 }
1483
1484 m_RedrawListbox = 1;
1485 UpdateDialog();
1486 }
1487
1488 void CWorldTexturesDialog::TextureListDown(int rows) {
1489 int old = m_TexStart;
1490 int done = 0, count = 0;
1491
1492 while ((count < (TEXTURES_PER_ROW * rows)) && !done) {
1493 m_TexStart = GetNextTexture(m_TexStart);
1494 if (old >= m_TexStart) {
1495 m_TexStart = old;
1496 done = 1;
1497 } else
1498 count++;
1499 }
1500
1501 m_RedrawListbox = 1;
1502 UpdateDialog();
1503 }
1504
1505 void CWorldTexturesDialog::OnTextureCurrent() {
1506
1507 // m_TexStart=D3EditState.texdlg_texture/TEXTURES_PER_ROW;
1508 // m_RedrawListbox=1;
1509
1510 // UpdateDialog();
1511 }
1512
1513 void CWorldTexturesDialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar) {
1514 // TODO: Add your message handler code here and/or call default
1515 // pScrollBar is one of the scroll bars in the dialog. to determine which one, get
1516 // its id. (Note that for a window's scrollbar, this object is invalid)
1517 int id = -1, min, max;
1518 int new_pos = 0;
1519
1520 if (pScrollBar) {
1521 id = pScrollBar->GetDlgCtrlID();
1522 pScrollBar->GetScrollRange(&min, &max);
1523 }
1524
1525 switch (id) {
1526 case IDC_TEXLIST_VERT:
1527 // vertically scroll the texture list box
1528 switch (nSBCode) {
1529 case SB_LINEDOWN:
1530 new_pos = m_TexListPos + 1;
1531 break;
1532 case SB_LINEUP:
1533 new_pos = m_TexListPos - 1;
1534 break;
1535 case SB_THUMBPOSITION:
1536 new_pos = nPos;
1537 break;
1538 case SB_THUMBTRACK:
1539 new_pos = nPos;
1540 break;
1541 case SB_PAGEDOWN:
1542 new_pos = m_TexListPos + m_TexPageLen;
1543 break;
1544 case SB_PAGEUP:
1545 new_pos = m_TexListPos - m_TexPageLen;
1546 break;
1547 default:
1548 new_pos = m_TexListPos;
1549 }
1550
1551 if (new_pos < 0)
1552 new_pos = 0;
1553 if (new_pos > (max - m_TexPageLen))
1554 new_pos = (max - m_TexPageLen) + 1;
1555 if (new_pos != m_TexListPos) {
1556 // ok, new_pos will be an index into the listbox, NOT the texture list.
1557 // so we will get the number of texture rows we went up or down and change
1558 // tex_start accordingly.
1559 mprintf(0, "scroll new_pos = %d. original_pos = %d\n", new_pos, m_TexListPos);
1560 if (new_pos < m_TexListPos)
1561 TextureListUp(abs(m_TexListPos - new_pos));
1562 if (new_pos > m_TexListPos)
1563 TextureListDown(abs(new_pos - m_TexListPos));
1564
1565 m_TexListPos = new_pos;
1566
1567 SCROLLINFO si;
1568
1569 si.cbSize = sizeof(si);
1570 si.fMask = SIF_POS;
1571 si.nPos = m_TexListPos;
1572 pScrollBar->SetScrollInfo(&si);
1573 }
1574 break;
1575
1576 default:
1577 Int3(); // WHAT THE FUCK!!
1578 }
1579
1580 CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
1581 }
1582
1583 // Opens a ITL text file and individually adds each on of those bitmaps as a texture
1584 int CWorldTexturesDialog::LoadITLFile(char *filename, int type) {
1585 CFILE *infile;
1586 char name[PAGENAME_LEN];
1587 uint32_t i, done = 0, total = 0;
1588 char cur_name[100];
1589 int tex_handle, tex_list[200];
1590 int c = 1, finding_name = 1;
1591
1592 ASSERT(filename != NULL);
1593
1594 infile = (CFILE *)cfopen(filename, "rt");
1595 if (!infile) {
1596 mprintf(0, "Couldn't load ITL file %s!\n", filename);
1597 return -1;
1598 }
1599
1600 mprintf(0, "Loading ITL file %s\n", name);
1601
1602 while (!done) {
1603 char curline[200];
1604 char texname[200];
1605
1606 if (cfeof(infile)) {
1607 done = 1;
1608 continue;
1609 }
1610
1611 // Read a line and parse it
1612 cf_ReadString(curline, 200, infile);
1613
1614 if (curline[0] == ';' || curline[1] == ';' || curline[0] == ' ' || curline[1] == ' ' || curline[0] == '\n')
1615 continue;
1616 else {
1617 int lastslash = -1;
1618 char bmname[200];
1619
1620 strcpy(texname, curline);
1621
1622 for (i = 0; i < strlen(curline); i++)
1623 if (curline[i] == '\\')
1624 lastslash = i;
1625
1626 if (lastslash == -1) {
1627 for (i = 0; i < strlen(filename); i++)
1628 if (filename[i] == '\\')
1629 lastslash = i;
1630
1631 ASSERT(lastslash != -1);
1632
1633 strcpy(bmname, filename);
1634 bmname[lastslash + 1] = 0;
1635 strcat(bmname, curline);
1636 } else
1637 strcpy(bmname, curline);
1638
1639 // Try and load this file
1640
1641 int bm = LoadTextureImage(bmname, 0, type, 0);
1642 if (bm <= 0) {
1643 mprintf(0, "Error loading frame %d of ITL file %s!\n", total, filename);
1644 goto Here;
1645 }
1646
1647 tex_handle = AllocTexture();
1648 GameTextures[tex_handle].bm_handle = bm;
1649
1650 finding_name = 1;
1651 c = 1;
1652
1653 while (finding_name) {
1654 if (c == 1)
1655 sprintf(cur_name, "%s", texname);
1656 else
1657 sprintf(cur_name, "%s%d", texname, c);
1658
1659 if (FindTextureName(cur_name) != -1)
1660 c++;
1661 else
1662 finding_name = 0;
1663 }
1664
1665 strcpy(GameTextures[tex_handle].name, cur_name);
1666
1667 GameTextures[tex_handle].flags &= ~TF_ANIMATED;
1668
1669 if (type == SMALL_TEXTURE)
1670 GameTextures[tex_handle].flags |= TF_TEXTURE_64;
1671 else if (type == TINY_TEXTURE)
1672 GameTextures[tex_handle].flags |= TF_TEXTURE_32;
1673 else if (type == HUGE_TEXTURE)
1674 GameTextures[tex_handle].flags |= TF_TEXTURE_256;
1675
1676 GameTextures[tex_handle].bm_handle = bm;
1677 mng_AllocTrackLock(cur_name, PAGETYPE_TEXTURE);
1678
1679 tex_list[total] = tex_handle;
1680
1681 total++;
1682 }
1683 }
1684
1685 Here:
1686
1687 cfclose(infile);
1688
1689 mprintf(0, "Making a copy of these textures locally...\n");
1690
1691 for (i = 0; i < total; i++) {
1692 tex_handle = tex_list[i];
1693
1694 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1695 GameBitmaps[GameTextures[tex_handle].bm_handle].name);
1696 bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle);
1697 }
1698
1699 return 1;
1700 }
1701
1702 void CWorldTexturesDialog::OnMineTexture() {
1703 int c = IsDlgButtonChecked(IDC_MINE_TEXTURE);
1704 int n = D3EditState.texdlg_texture;
1705
1706 if (c)
1707 GameTextures[n].flags |= TF_MINE;
1708 else
1709 GameTextures[n].flags &= ~TF_MINE;
1710 }
1711
1712 void CWorldTexturesDialog::OnObjectTexture() {
1713 int c = IsDlgButtonChecked(IDC_OBJECT_TEXTURE);
1714 int n = D3EditState.texdlg_texture;
1715
1716 if (c)
1717 GameTextures[n].flags |= TF_OBJECT;
1718 else
1719 GameTextures[n].flags &= ~TF_OBJECT;
1720 }
1721
1722 void CWorldTexturesDialog::OnTerrainTexture() {
1723 int c = IsDlgButtonChecked(IDC_TERRAIN_TEXTURE);
1724 int n = D3EditState.texdlg_texture;
1725
1726 if (c)
1727 GameTextures[n].flags |= TF_TERRAIN;
1728 else
1729 GameTextures[n].flags &= ~TF_TERRAIN;
1730 }
1731
1732 void CWorldTexturesDialog::OnKillfocusBlueLighting() {
1733 CEdit *ebox;
1734 char name[20];
1735 int n = D3EditState.texdlg_texture;
1736
1737 ebox = (CEdit *)GetDlgItem(IDC_BLUE_LIGHTING);
1738 ebox->GetWindowText(name, 20);
1739
1740 GameTextures[n].b = atof(name);
1741 UpdateDialog();
1742 }
1743
1744 void CWorldTexturesDialog::OnKillfocusGreenLighting() {
1745 CEdit *ebox;
1746 char name[20];
1747 int n = D3EditState.texdlg_texture;
1748
1749 ebox = (CEdit *)GetDlgItem(IDC_GREEN_LIGHTING);
1750 ebox->GetWindowText(name, 20);
1751
1752 GameTextures[n].g = atof(name);
1753 UpdateDialog();
1754 }
1755
1756 void CWorldTexturesDialog::OnKillfocusRedLighting() {
1757 CEdit *ebox;
1758 char name[20];
1759 int n = D3EditState.texdlg_texture;
1760
1761 ebox = (CEdit *)GetDlgItem(IDC_RED_LIGHTING);
1762 ebox->GetWindowText(name, 20);
1763
1764 GameTextures[n].r = atof(name);
1765 UpdateDialog();
1766 }
1767
1768 BOOL CWorldTexturesDialog::OnHelpInfo(HELPINFO *pHelpInfo) {
1769 // TODO: Add your message handler code here and/or call default
1770 WinHelp(HID_TEXTURESDLG, HELP_CONTEXT);
1771 return TRUE;
1772 // return CDialog::OnHelpInfo(pHelpInfo);
1773 }
1774
1775 void CWorldTexturesDialog::OnAddNewSmall() {
1776 char filename[255], dir[255], fname[128], ext[32];
1777 char cur_name[100];
1778 int bm_handle, tex_handle;
1779 int c = 1, finding_name = 1;
1780 int anim = 0;
1781
1782 if (!Network_up) {
1783 OutrageMessageBox("Sorry babe, the network is down. This action is a no-no.\n");
1784 return;
1785 }
1786
1787 int alt_format = IsDlgButtonChecked(IDC_IMPORT_4444);
1788 int format = 0;
1789
1790 if (alt_format) {
1791 int answer = MessageBox("Are you sure you wish to import this texture with a 4444 format?", "Question", MB_YESNO);
1792 if (answer == IDNO)
1793 return;
1794
1795 format = BITMAP_FORMAT_4444;
1796 }
1797
1798 CString filter =
1799 "Descent III files "
1800 "(*.itl,*.tga,*.bbm,*.lbm,*.ogf,*.oaf,*.ilf,*.pcx)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.oaf;*.ifl;*.itl||";
1801
1802 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir)))
1803 return;
1804
1805 ddio_SplitPath(filename, dir, fname, ext);
1806
1807 // Okay, we selected a file. Lets do what needs to be done here.
1808 if (!strnicmp(ext, "ITL", 3)) {
1809 LoadITLFile(filename, SMALL_TEXTURE);
1810 UpdateDialog();
1811 return;
1812 }
1813
1814 bm_handle = LoadTextureImage(filename, &anim, SMALL_TEXTURE, 0, 0, format);
1815
1816 if (bm_handle < 0) {
1817 OutrageMessageBox("Couldn't open that bitmap/anim file.");
1818 return;
1819 }
1820
1821 tex_handle = AllocTexture();
1822
1823 while (finding_name) {
1824 if (c == 1)
1825 sprintf(cur_name, "%s", fname);
1826 else
1827 sprintf(cur_name, "%s%d", fname, c);
1828
1829 if (FindTextureName(cur_name) != -1)
1830 c++;
1831 else
1832 finding_name = 0;
1833 }
1834
1835 strcpy(GameTextures[tex_handle].name, cur_name);
1836
1837 if (anim)
1838 GameTextures[tex_handle].flags |= TF_ANIMATED;
1839 else
1840 GameTextures[tex_handle].flags &= ~TF_ANIMATED;
1841
1842 GameTextures[tex_handle].flags |= TF_TEXTURE_64;
1843
1844 GameTextures[tex_handle].bm_handle = bm_handle;
1845
1846 mprintf(0, "Making a copy of this bitmap/anim locally...\n");
1847
1848 if (!anim) {
1849 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1850 GameBitmaps[GameTextures[tex_handle].bm_handle].name);
1851 bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle);
1852 } else {
1853 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1854 GameVClips[GameTextures[tex_handle].bm_handle].name);
1855 SaveVClip(filename, GameTextures[tex_handle].bm_handle);
1856 }
1857
1858 CheckIfTextureIsTmap2(tex_handle);
1859
1860 mng_AllocTrackLock(cur_name, PAGETYPE_TEXTURE);
1861
1862 D3EditState.texdlg_texture = tex_handle;
1863
1864 UpdateDialog();
1865 }
1866
1867 void CWorldTexturesDialog::OnAddNewTiny() {
1868 char filename[255], dir[255], fname[128], ext[32];
1869 char cur_name[100];
1870 int bm_handle, tex_handle;
1871 int c = 1, finding_name = 1;
1872 int anim = 0;
1873
1874 if (!Network_up) {
1875 OutrageMessageBox("Sorry babe, the network is down. This action is a no-no.\n");
1876 return;
1877 }
1878
1879 int alt_format = IsDlgButtonChecked(IDC_IMPORT_4444);
1880 int format = 0;
1881
1882 if (alt_format) {
1883 int answer = MessageBox("Are you sure you wish to import this texture with a 4444 format?", "Question", MB_YESNO);
1884 if (answer == IDNO)
1885 return;
1886
1887 format = BITMAP_FORMAT_4444;
1888 }
1889
1890 CString filter =
1891 "Descent III files "
1892 "(*.itl,*.tga,*.bbm,*.lbm,*.ogf,*.oaf,*.ilf,*.pcx)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.oaf;*.ifl;*.itl||";
1893
1894 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir)))
1895 return;
1896
1897 ddio_SplitPath(filename, dir, fname, ext);
1898
1899 // Okay, we selected a file. Lets do what needs to be done here.
1900 if (!strnicmp(ext, "ITL", 3)) {
1901 LoadITLFile(filename, TINY_TEXTURE);
1902 UpdateDialog();
1903 return;
1904 }
1905
1906 bm_handle = LoadTextureImage(filename, &anim, TINY_TEXTURE, 0, 0, format);
1907
1908 if (bm_handle < 0) {
1909 OutrageMessageBox("Couldn't open that bitmap/anim file.");
1910 return;
1911 }
1912
1913 tex_handle = AllocTexture();
1914
1915 while (finding_name) {
1916 if (c == 1)
1917 sprintf(cur_name, "%s", fname);
1918 else
1919 sprintf(cur_name, "%s%d", fname, c);
1920 if (FindTextureName(cur_name) != -1)
1921 c++;
1922 else
1923 finding_name = 0;
1924 }
1925
1926 strcpy(GameTextures[tex_handle].name, cur_name);
1927
1928 if (anim)
1929 GameTextures[tex_handle].flags |= TF_ANIMATED;
1930 else
1931 GameTextures[tex_handle].flags &= ~TF_ANIMATED;
1932
1933 GameTextures[tex_handle].flags |= TF_TEXTURE_32;
1934
1935 GameTextures[tex_handle].bm_handle = bm_handle;
1936
1937 mprintf(0, "Making a copy of this bitmap/anim locally...\n");
1938
1939 if (!anim) {
1940 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1941 GameBitmaps[GameTextures[tex_handle].bm_handle].name);
1942 bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle);
1943 } else {
1944 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1945 GameVClips[GameTextures[tex_handle].bm_handle].name);
1946 SaveVClip(filename, GameTextures[tex_handle].bm_handle);
1947 }
1948
1949 CheckIfTextureIsTmap2(tex_handle);
1950
1951 mng_AllocTrackLock(cur_name, PAGETYPE_TEXTURE);
1952
1953 D3EditState.texdlg_texture = tex_handle;
1954
1955 UpdateDialog();
1956 }
1957
1958 void CWorldTexturesDialog::OnKillfocusAlphaEdit() {
1959 CEdit *ebox;
1960 char name[20];
1961 int n = D3EditState.texdlg_texture;
1962
1963 ebox = (CEdit *)GetDlgItem(IDC_ALPHA_EDIT);
1964 ebox->GetWindowText(name, 20);
1965
1966 GameTextures[n].alpha = atof(name);
1967
1968 if (GameTextures[n].alpha < .9999)
1969 GameTextures[n].flags |= TF_ALPHA;
1970 else
1971 GameTextures[n].flags &= ~TF_ALPHA;
1972
1973 UpdateDialog();
1974 }
1975
1976 void CWorldTexturesDialog::OnTextureFlyThruCheck() {
1977 // TODO: Add your control notification handler code here
1978 int n = D3EditState.texdlg_texture;
1979 int c = IsDlgButtonChecked(IDC_TEXTURE_FLY_THRU_CHECK);
1980
1981 if (c)
1982 GameTextures[n].flags |= TF_FLY_THRU;
1983 else
1984 GameTextures[n].flags &= ~TF_FLY_THRU;
1985 }
1986
1987 void CWorldTexturesDialog::OnPingPong() {
1988 int n = D3EditState.texdlg_texture;
1989 int c = IsDlgButtonChecked(IDC_PING_PONG);
1990
1991 if (c)
1992 GameTextures[n].flags |= TF_PING_PONG;
1993 else
1994 GameTextures[n].flags &= ~TF_PING_PONG;
1995 }
1996
1997 // Gets a name from the user, making sure it's unique
1998 // Returns true if got new name, false if cancelled.
1999 // the data in buf not changed if cancel is pressed
2000 bool InputTextureName(char *buf, int len, char *title, char *prompt, CWnd *wnd) {
2001 char *tempbuf = (char *)mem_malloc(len);
2002
2003 strcpy(tempbuf, buf);
2004
2005 try_again:
2006
2007 if (!InputString(tempbuf, len, title, prompt, wnd)) {
2008 mem_free(tempbuf);
2009 return 0;
2010 }
2011
2012 if (FindTextureName(tempbuf) != -1) {
2013 OutrageMessageBox("The name you specified is already in use. Enter another name.");
2014 goto try_again;
2015 }
2016
2017 strcpy(buf, tempbuf);
2018 mem_free(tempbuf);
2019
2020 return 1;
2021 }
2022
2023 void CWorldTexturesDialog::OnTextureChangeName() {
2024 int n = D3EditState.texdlg_texture;
2025 char name[PAGENAME_LEN];
2026 mngs_Pagelock pl;
2027
2028 // Make sure we have this texture locked, if not reset name and bail
2029 int p = mng_FindTrackLock(GameTextures[n].name, PAGETYPE_TEXTURE);
2030 if (p == -1) {
2031 OutrageMessageBox("You must lock this texture if you wish to change its name.");
2032 return;
2033 }
2034
2035 // Get new name
2036 strcpy(name, GameTextures[n].name);
2037 if (!InputTextureName(name, sizeof(name), "Texture name", "Enter a new name for this texture:", this))
2038 return;
2039
2040 if (!mng_MakeLocker())
2041 return;
2042
2043 // Check to see if this page exists on the network. If so, we have to
2044 // rename it so we can prevent havoc
2045 strcpy(pl.name, GameTextures[n].name);
2046 pl.pagetype = PAGETYPE_TEXTURE;
2047
2048 int ret = mng_CheckIfPageOwned(&pl, TableUser);
2049 if (ret < 0)
2050 OutrageMessageBox(ErrorString);
2051 else if (ret == 1)
2052 mng_RenamePage(GameTextures[n].name, name, PAGETYPE_TEXTURE);
2053 else if (ret == 2) {
2054 // This page has never been checked in, replace only local copy
2055
2056 char oldname[PAGENAME_LEN];
2057 strcpy(oldname, GameTextures[n].name);
2058 strcpy(GameTextures[n].name, name);
2059 mng_ReplacePage(oldname, GameTextures[n].name, n, PAGETYPE_TEXTURE, 1);
2060
2061 } else if (ret == 0) {
2062 OutrageMessageBox("You don't own this page. Get Jason now!");
2063 mng_FreeTrackLock(p);
2064 return;
2065 }
2066
2067 // Finally, copy our new name to the appropriate arrays
2068 strcpy(GlobalTrackLocks[p].name, name);
2069 strcpy(GameTextures[n].name, name);
2070 UpdateDialog();
2071 mng_EraseLocker();
2072 }
2073
2074 void CWorldTexturesDialog::OnSelendokDestroyPulldown() {
2075 int i, cur;
2076 char name[200];
2077
2078 cur = SendDlgItemMessage(IDC_DESTROY_PULLDOWN, CB_GETCURSEL, 0, 0);
2079 SendDlgItemMessage(IDC_DESTROY_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
2080
2081 i = FindTextureName(name);
2082
2083 if (i == -1) {
2084 mprintf(0, "Possible corrupted texture list, but probably nothing.");
2085 UpdateDialog();
2086 }
2087
2088 GameTextures[D3EditState.texdlg_texture].destroy_handle = i;
2089 UpdateDialog();
2090 }
2091
2092 void CWorldTexturesDialog::OnSaturate() {
2093 int n = D3EditState.texdlg_texture;
2094 int c = IsDlgButtonChecked(IDC_SATURATE);
2095
2096 if (c)
2097 GameTextures[n].flags |= TF_SATURATE;
2098 else
2099 GameTextures[n].flags &= ~TF_SATURATE;
2100 }
2101
2102 void CWorldTexturesDialog::OnOverride() {
2103 int n = D3EditState.texdlg_texture;
2104 mngs_Pagelock temp_pl;
2105
2106 strcpy(temp_pl.name, GameTextures[n].name);
2107 temp_pl.pagetype = PAGETYPE_TEXTURE;
2108
2109 mng_OverrideToUnlocked(&temp_pl);
2110 }
2111
2112 void CWorldTexturesDialog::OnSaveAsTga() {
2113 int n = D3EditState.texdlg_texture;
2114
2115 if (GameTextures[n].flags & TF_ANIMATED) {
2116 OutrageMessageBox("You cannot save an animated texture!");
2117 return;
2118 }
2119
2120 CString filter = "TGA files (*.tga)|*.tga||";
2121 char filename[255];
2122 if (!SaveFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir)))
2123 return;
2124
2125 if (!strchr(filename, '.'))
2126 strcat(filename, ".tga");
2127
2128 // FIXME: Save as PNG
2129 // bm_SaveBitmapTGA (filename,GameTextures[n].bm_handle);
2130 OutrageMessageBox("TGA saved!");
2131 }
2132
2133 void CWorldTexturesDialog::DrawSwatch(int handle, float r, float g, float b) {
2134 CWnd *texwnd;
2135 RECT rect;
2136 int w, h;
2137 float rmax = std::max(r, g);
2138 rmax = std::max(rmax, b);
2139
2140 if (rmax >= .001) {
2141 r /= rmax;
2142 g /= rmax;
2143 b /= rmax;
2144 }
2145
2146 texwnd = GetDlgItem(handle);
2147 texwnd->GetWindowRect(&rect);
2148 ScreenToClient(&rect);
2149
2150 Desktop_surf->attach_to_window((unsigned)m_hWnd);
2151
2152 w = rect.right - rect.left;
2153 h = rect.bottom - rect.top;
2154
2155 ddgr_color color = GR_RGB(r * 255, g * 255, b * 255);
2156
2157 Desktop_surf->clear(rect.left, rect.top, w, h, color);
2158
2159 Desktop_surf->attach_to_window(NULL);
2160 }
2161
2162 void CWorldTexturesDialog::ChangeSize(int w, int h) {
2163 int n = D3EditState.texdlg_texture;
2164 char str[255];
2165
2166 sprintf(str, "Are you sure you wish to change this texture to %d x %d?", w, h);
2167
2168 int answer = MessageBox(str, GameTextures[n].name, MB_YESNO);
2169 if (answer == IDNO)
2170 return;
2171
2172 if (GameTextures[n].flags & TF_ANIMATED) {
2173 vclip *vc = &GameVClips[GameTextures[n].bm_handle];
2174 for (int i = 0; i < vc->num_frames; i++)
2175 bm_ChangeSize(vc->frames[i], w, h);
2176 } else {
2177 bm_ChangeSize(GameTextures[n].bm_handle, w, h);
2178 }
2179
2180 GameTextures[n].flags &= ~(TF_TEXTURE_32 | TF_TEXTURE_64 | TF_TEXTURE_256);
2181 if (w == 64)
2182 GameTextures[n].flags |= TF_TEXTURE_64;
2183 else if (w == 32)
2184 GameTextures[n].flags |= TF_TEXTURE_32;
2185
2186 mprintf(0, "Texture changed to %d x %d!\n", w, h);
2187
2188 UpdateDialog();
2189 }
2190
2191 void CWorldTexturesDialog::OnConvertToNormal() { ChangeSize(128, 128); }
2192
2193 void CWorldTexturesDialog::OnConvertToSmall() { ChangeSize(64, 64); }
2194
2195 void CWorldTexturesDialog::OnConvertToTiny() { ChangeSize(32, 32); }
2196
2197 void CWorldTexturesDialog::OnKillfocusSpeedEdit() {
2198 CEdit *ebox;
2199 char name[20];
2200 int n = D3EditState.texdlg_texture;
2201
2202 ebox = (CEdit *)GetDlgItem(IDC_SPEED_EDIT);
2203 ebox->GetWindowText(name, 20);
2204
2205 GameTextures[n].speed = atof(name);
2206 UpdateDialog();
2207 }
2208
2209 void CWorldTexturesDialog::OnImportBump() {
2210 /*char filename[255];
2211 int bm_handle;
2212 int n=D3EditState.texdlg_texture;
2213
2214
2215 CString filter = "Descent III files (*.tga,*.ogf,*.pcx)|*.pcx;*.tga;*.ogf;||";
2216
2217 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir)))
2218 return;
2219
2220 bm_handle=bm_AllocLoadFileBitmap (filename,0);
2221
2222 if (bm_handle<0)
2223 {
2224 OutrageMessageBox ("Could not load that bumpmap!");
2225 return;
2226 }
2227
2228 if (bm_w(bm_handle,0)!=BUMP_WIDTH || bm_h(bm_handle,0)!=BUMP_HEIGHT)
2229 {
2230 OutrageMessageBox ("Bumpmaps must be 32x32 in size!");
2231 return;
2232 }
2233
2234 if (GameTextures[n].bumpmap!=-1)
2235 {
2236 bump_FreeBumpmap (GameTextures[n].bumpmap);
2237 GameTextures[n].src_bumpmap=-1;
2238 }
2239
2240 int src_bump=bump_AllocBumpmap ();
2241 ASSERT (src_bump>=0);
2242
2243 // Do the memcopy from the bitmap to the bumpmap
2244 uint16_t *src_data,*dest_data;
2245 src_data=(uint16_t *)bm_data(bm_handle,0);
2246 dest_data=(uint16_t *)bump_data(src_bump);
2247
2248 memcpy (dest_data,src_data,BUMP_WIDTH*BUMP_HEIGHT*2);
2249
2250 GameTextures[n].src_bumpmap=src_bump;
2251
2252 mprintf(0,"Making a copy of this bumpmap locally...\n");
2253
2254 sprintf (filename,"%s\\%s",LocalManageGraphicsDir,GameBitmaps[bm_handle].name);
2255 bm_SaveFileBitmap (filename,bm_handle);
2256
2257 // Free useless bitmap
2258 bm_FreeBitmap(bm_handle);
2259
2260 UpdateDialog ();*/
2261 }
2262
2263 void CWorldTexturesDialog::OnGenerateOmni() {
2264 int n = D3EditState.texdlg_texture;
2265
2266 if (GameTextures[n].bumpmap == -1) {
2267 OutrageMessageBox("You first need to import a source bumpmap!");
2268 return;
2269 }
2270
2271 BuildTextureBumpmaps(n);
2272
2273 OutrageMessageBox("Bumpmaps built!");
2274 }
2275
2276 void CWorldTexturesDialog::OnSrcBump() {
2277 m_bumpmap = 0;
2278 UpdateDialog();
2279 }
2280
2281 void CWorldTexturesDialog::OnBump1() {
2282 m_bumpmap = 1;
2283 UpdateDialog();
2284 }
2285
2286 void CWorldTexturesDialog::OnBump2() {
2287 m_bumpmap = 2;
2288 UpdateDialog();
2289 }
2290
2291 void CWorldTexturesDialog::OnBump3() {
2292 m_bumpmap = 3;
2293 UpdateDialog();
2294 }
2295
2296 void CWorldTexturesDialog::OnBump4() {
2297 m_bumpmap = 4;
2298 UpdateDialog();
2299 }
2300
2301 void CWorldTexturesDialog::OnMetalCheck() {
2302 int c = IsDlgButtonChecked(IDC_METAL_CHECK);
2303 int n = D3EditState.texdlg_texture;
2304
2305 GameTextures[n].flags &= ~(TF_SPECULAR);
2306
2307 if (c)
2308 GameTextures[n].flags |= TF_METAL;
2309 else
2310 GameTextures[n].flags &= ~TF_METAL;
2311
2312 UpdateDialog();
2313 }
2314
2315 void CWorldTexturesDialog::OnMarbleCheck() {
2316 int c = IsDlgButtonChecked(IDC_MARBLE_CHECK);
2317 int n = D3EditState.texdlg_texture;
2318
2319 GameTextures[n].flags &= ~(TF_SPECULAR);
2320
2321 if (c)
2322 GameTextures[n].flags |= TF_MARBLE;
2323 else
2324 GameTextures[n].flags &= ~TF_MARBLE;
2325
2326 UpdateDialog();
2327 }
2328
2329 void CWorldTexturesDialog::OnPlasticCheck() {
2330 int c = IsDlgButtonChecked(IDC_PLASTIC_CHECK);
2331 int n = D3EditState.texdlg_texture;
2332
2333 GameTextures[n].flags &= ~(TF_SPECULAR);
2334
2335 if (c)
2336 GameTextures[n].flags |= TF_PLASTIC;
2337 else
2338 GameTextures[n].flags &= ~TF_PLASTIC;
2339
2340 UpdateDialog();
2341 }
2342
2343 void CWorldTexturesDialog::OnEffectTexture() {
2344 int c = IsDlgButtonChecked(IDC_EFFECT_TEXTURE);
2345 int n = D3EditState.texdlg_texture;
2346
2347 if (c)
2348 GameTextures[n].flags |= TF_EFFECT;
2349 else
2350 GameTextures[n].flags &= ~TF_EFFECT;
2351 }
2352
2353 void CWorldTexturesDialog::OnHudCockpitTexture() {
2354 int c = IsDlgButtonChecked(IDC_HUD_COCKPIT_TEXTURE);
2355 int n = D3EditState.texdlg_texture;
2356
2357 if (c)
2358 GameTextures[n].flags |= TF_HUD_COCKPIT;
2359 else
2360 GameTextures[n].flags &= ~TF_HUD_COCKPIT;
2361 }
2362
2363 void CWorldTexturesDialog::OnLightTexture() {
2364 int n = D3EditState.texdlg_texture;
2365
2366 OutrageMessageBox("You cannot change this setting. Change the RGB values instead.");
2367
2368 CheckDlgButton(IDC_LIGHT_TEXTURE, GameTextures[n].flags & TF_LIGHT ? 1 : 0);
2369 }
2370
2371 void CWorldTexturesDialog::OnProceduralCheck() {
2372 int c = IsDlgButtonChecked(IDC_PROCEDURAL_CHECK);
2373 int n = D3EditState.texdlg_texture;
2374
2375 if (c)
2376 GameTextures[n].flags |= TF_PROCEDURAL;
2377 else
2378 GameTextures[n].flags &= ~TF_PROCEDURAL;
2379
2380 UpdateDialog();
2381 }
2382
2383 void CWorldTexturesDialog::OnProceduralButton() {
2384 int n = D3EditState.texdlg_texture;
2385
2386 if (GameTextures[n].used == 0)
2387 return;
2388
2389 if (GameTextures[n].flags & TF_WATER_PROCEDURAL) {
2390 CWaterProceduralDialog dlg;
2391 dlg.DoModal();
2392 } else {
2393 CProceduralDialog dlg;
2394 dlg.DoModal();
2395 }
2396
2397 UpdateDialog();
2398 }
2399
2400 void CWorldTexturesDialog::OnWaterProceduralCheck() {
2401 int c = IsDlgButtonChecked(IDC_WATER_PROCEDURAL_CHECK);
2402 int n = D3EditState.texdlg_texture;
2403
2404 if (c)
2405 GameTextures[n].flags |= TF_WATER_PROCEDURAL;
2406 else
2407 GameTextures[n].flags &= ~TF_WATER_PROCEDURAL;
2408
2409 UpdateDialog();
2410 }
2411
2412 void CWorldTexturesDialog::OnForceLightmaps() {
2413 int c = IsDlgButtonChecked(IDC_FORCE_LIGHTMAPS);
2414 int n = D3EditState.texdlg_texture;
2415
2416 if (c)
2417 GameTextures[n].flags |= TF_FORCE_LIGHTMAP;
2418 else
2419 GameTextures[n].flags &= ~TF_FORCE_LIGHTMAP;
2420
2421 UpdateDialog();
2422 }
2423
2424 void CWorldTexturesDialog::OnCoronaA() {
2425 int n = D3EditState.texdlg_texture;
2426
2427 GameTextures[n].corona_type = 0;
2428 UpdateDialog();
2429 }
2430
2431 void CWorldTexturesDialog::OnCoronaB() {
2432 int n = D3EditState.texdlg_texture;
2433
2434 GameTextures[n].corona_type = 1;
2435 UpdateDialog();
2436 }
2437
2438 void CWorldTexturesDialog::OnCoronaC() {
2439 int n = D3EditState.texdlg_texture;
2440
2441 GameTextures[n].corona_type = 2;
2442 UpdateDialog();
2443 }
2444
2445 void CWorldTexturesDialog::OnCoronaD() {
2446 int n = D3EditState.texdlg_texture;
2447
2448 GameTextures[n].corona_type = 3;
2449 UpdateDialog();
2450 }
2451
2452 void CWorldTexturesDialog::OnMultichecktex() {
2453 // CManageCheckin dlg;
2454
2455 // dlg.DoModal();
2456 UpdateDialog();
2457 }
2458
2459 void CWorldTexturesDialog::OnImport4444() {
2460 // TODO: Add your control notification handler code here
2461 }
2462
2463 void CWorldTexturesDialog::OnSaturateLightmap() {
2464 int c = IsDlgButtonChecked(IDC_SATURATE_LIGHTMAP);
2465 int n = D3EditState.texdlg_texture;
2466
2467 if (c)
2468 GameTextures[n].flags |= TF_SATURATE_LIGHTMAP;
2469 else
2470 GameTextures[n].flags &= ~TF_SATURATE_LIGHTMAP;
2471
2472 UpdateDialog();
2473 }
2474
2475 void CWorldTexturesDialog::OnAddNewHuge() {
2476 char filename[255], dir[255], fname[128], ext[32];
2477 char cur_name[100];
2478 int bm_handle, tex_handle;
2479 int c = 1, finding_name = 1;
2480 int anim = 0;
2481
2482 if (!Network_up) {
2483 OutrageMessageBox("Sorry babe, the network is down. This action is a no-no.\n");
2484 return;
2485 }
2486
2487 int answer = MessageBox("256x256 textures are for SKIES ONLY. If you are caught using them for any other purpose "
2488 "you will be killed! Are you sure this is what you want to do?",
2489 "WARNING!", MB_YESNO);
2490 if (answer == IDNO)
2491 return;
2492
2493 int alt_format = IsDlgButtonChecked(IDC_IMPORT_4444);
2494 int format = 0;
2495
2496 if (alt_format) {
2497 answer = MessageBox("Are you sure you wish to import this texture with a 4444 format?", "Question", MB_YESNO);
2498 if (answer == IDNO)
2499 return;
2500
2501 format = BITMAP_FORMAT_4444;
2502 }
2503
2504 CString filter =
2505 "Descent III files "
2506 "(*.itl,*.tga,*.bbm,*.lbm,*.ogf,*.oaf,*.ilf,*.pcx)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.oaf;*.ifl;*.itl||";
2507
2508 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_bitmap_dir, sizeof(Current_bitmap_dir)))
2509 return;
2510
2511 ddio_SplitPath(filename, dir, fname, ext);
2512
2513 // Okay, we selected a file. Lets do what needs to be done here.
2514 if (!strnicmp(ext, "ITL", 3)) {
2515 LoadITLFile(filename, HUGE_TEXTURE);
2516 UpdateDialog();
2517 return;
2518 }
2519
2520 bm_handle = LoadTextureImage(filename, &anim, HUGE_TEXTURE, 0, 0, format);
2521
2522 if (bm_handle < 0) {
2523 OutrageMessageBox("Couldn't open that bitmap/anim file.");
2524 return;
2525 }
2526
2527 tex_handle = AllocTexture();
2528
2529 while (finding_name) {
2530 if (c == 1)
2531 sprintf(cur_name, "%s", fname);
2532 else
2533 sprintf(cur_name, "%s%d", fname, c);
2534 if (FindTextureName(cur_name) != -1)
2535 c++;
2536 else
2537 finding_name = 0;
2538 }
2539
2540 strcpy(GameTextures[tex_handle].name, cur_name);
2541
2542 if (anim)
2543 GameTextures[tex_handle].flags |= TF_ANIMATED;
2544 else
2545 GameTextures[tex_handle].flags &= ~TF_ANIMATED;
2546
2547 GameTextures[tex_handle].flags |= TF_TEXTURE_256;
2548
2549 GameTextures[tex_handle].bm_handle = bm_handle;
2550
2551 mprintf(0, "Making a copy of this bitmap/anim locally...\n");
2552
2553 if (!anim) {
2554 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
2555 GameBitmaps[GameTextures[tex_handle].bm_handle].name);
2556 bm_SaveFileBitmap(filename, GameTextures[tex_handle].bm_handle);
2557 } else {
2558 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
2559 GameVClips[GameTextures[tex_handle].bm_handle].name);
2560 SaveVClip(filename, GameTextures[tex_handle].bm_handle);
2561 }
2562
2563 CheckIfTextureIsTmap2(tex_handle);
2564
2565 mng_AllocTrackLock(cur_name, PAGETYPE_TEXTURE);
2566
2567 D3EditState.texdlg_texture = tex_handle;
2568
2569 UpdateDialog();
2570 }
2571
2572 void CWorldTexturesDialog::OnLavaCheckbox() {
2573 int c = IsDlgButtonChecked(IDC_LAVA_CHECKBOX);
2574 int n = D3EditState.texdlg_texture;
2575
2576 if (c)
2577 GameTextures[n].flags |= TF_LAVA;
2578 else
2579 GameTextures[n].flags &= ~TF_LAVA;
2580 }
2581
2582 void CWorldTexturesDialog::OnRubbleCheckbox() {
2583 int c = IsDlgButtonChecked(IDC_RUBBLE_CHECKBOX);
2584 int n = D3EditState.texdlg_texture;
2585
2586 if (c)
2587 GameTextures[n].flags |= TF_RUBBLE;
2588 else
2589 GameTextures[n].flags &= ~TF_RUBBLE;
2590 }
2591
2592 void CWorldTexturesDialog::OnSelendokTextureAmbientSoundPulldown() {
2593 int n = D3EditState.texdlg_texture;
2594
2595 GameTextures[n].sound = m_ambient_sound_combo.GetSelected();
2596 }
2597
2598 void CWorldTexturesDialog::OnKillfocusTextureAmbientSoundVolume() {
2599 char str[256];
2600
2601 ((CEdit *)GetDlgItem(IDC_TEXTURE_AMBIENT_SOUND_VOLUME))->GetWindowText(str, sizeof(str));
2602
2603 float volume = atof(str);
2604
2605 if ((volume > 100) || (volume < 0))
2606 OutrageMessageBox("Volume must be between 0 and 100");
2607 else {
2608 int n = D3EditState.texdlg_texture;
2609 GameTextures[n].sound_volume = volume;
2610 }
2611 }
2612
2613 void CWorldTexturesDialog::OnSmoothSpecCheck() {
2614 // TODO: Add your control notification handler code here
2615 int c = IsDlgButtonChecked(IDC_SMOOTH_SPEC_CHECK);
2616 int n = D3EditState.texdlg_texture;
2617
2618 if (c)
2619 GameTextures[n].flags |= TF_SMOOTH_SPECULAR;
2620 else
2621 GameTextures[n].flags &= ~TF_SMOOTH_SPECULAR;
2622 }
2623
2624 #include "soundload.h"
2625 #include "DallasSoundDlg.h"
2626
2627 void CWorldTexturesDialog::OnAmbientSoundSelect() {
2628 CDallasSoundDlg dlg;
2629
2630 int selected = m_ambient_sound_combo.GetSelected();
2631 if (selected != -1)
2632 dlg.m_SoundName = Sounds[selected].name;
2633
2634 if (dlg.DoModal() == IDCANCEL)
2635 return;
2636
2637 m_ambient_sound_combo.SetSelected(dlg.m_SoundIndex);
2638 }
2639
2640 void CWorldTexturesDialog::OnCheckBreakable() {
2641 int n = D3EditState.texdlg_texture;
2642 int c = IsDlgButtonChecked(IDC_CHECK_BREAKABLE);
2643
2644 if (c)
2645 GameTextures[n].flags |= TF_BREAKABLE;
2646 else
2647 GameTextures[n].flags &= ~TF_BREAKABLE;
2648
2649 UpdateDialog();
2650 }