| 1 |
/** |
| 2 |
* FreeDink editor-specific code |
| 3 |
|
| 4 |
* Copyright (C) 1997, 1998, 1999, 2002, 2003 Seth A. Robinson |
| 5 |
* Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011, 2012, 2014, 2015 Sylvain Beucler |
| 6 |
|
| 7 |
* This file is part of GNU FreeDink |
| 8 |
|
| 9 |
* GNU FreeDink is free software; you can redistribute it and/or |
| 10 |
* modify it under the terms of the GNU General Public License as |
| 11 |
* published by the Free Software Foundation; either version 3 of the |
| 12 |
* License, or (at your option) any later version. |
| 13 |
|
| 14 |
* GNU FreeDink is distributed in the hope that it will be useful, but |
| 15 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
* General Public License for more details. |
| 18 |
|
| 19 |
* You should have received a copy of the GNU General Public License |
| 20 |
* along with this program. If not, see |
| 21 |
* <http://www.gnu.org/licenses/>. |
| 22 |
*/ |
| 23 |
|
| 24 |
#ifdef HAVE_CONFIG_H |
| 25 |
#include <config.h> |
| 26 |
#endif |
| 27 |
|
| 28 |
#include <gettext.h> |
| 29 |
#define _(String) gettext (String) |
| 30 |
|
| 31 |
/* #define WIN32_LEAN_AND_MEAN */ |
| 32 |
#include <stdio.h> |
| 33 |
#include <stdlib.h> |
| 34 |
#include <string.h> |
| 35 |
#include <time.h> |
| 36 |
/* for tolower */ |
| 37 |
#include <ctype.h> |
| 38 |
/* #include <io.h> */ |
| 39 |
/* #include <direct.h> */ |
| 40 |
#include <unistd.h> |
| 41 |
#include <getopt.h> |
| 42 |
|
| 43 |
#include "SDL.h" |
| 44 |
#include "SDL2_gfxPrimitives.h" |
| 45 |
#include "SDL2_rotozoom.h" |
| 46 |
#include "SDL2_framerate.h" |
| 47 |
|
| 48 |
#include "app.h" |
| 49 |
#include "AppFreeDinkedit.h" |
| 50 |
#include "DMod.h" |
| 51 |
#include "hardness_tiles.h" |
| 52 |
#include "fastfile.h" |
| 53 |
#include "IOGfxPrimitives.h" |
| 54 |
#include "IOGfxDisplay.h" |
| 55 |
#include "IOGfxSurface.h" |
| 56 |
#include "ImageLoader.h" |
| 57 |
#include "gfx.h" |
| 58 |
#include "editor_screen.h" |
| 59 |
#include "live_screen.h" |
| 60 |
#include "live_sprites_manager.h" |
| 61 |
#include "gfx_sprites.h" |
| 62 |
#include "gfx_tiles.h" |
| 63 |
#include "gfx_fonts.h" |
| 64 |
#include "dinkini.h" /* check_seq_status */ |
| 65 |
#include "sfx.h" |
| 66 |
#include "input.h" |
| 67 |
#include "io_util.h" |
| 68 |
#include "resources.h" |
| 69 |
#include "paths.h" |
| 70 |
#include "log.h" |
| 71 |
|
| 72 |
//Dinkedit-only vars |
| 73 |
|
| 74 |
|
| 75 |
/* |
| 76 |
* I count 10 modes in Dinkedit: map(1), screen tiles(3), screen |
| 77 |
* sprites(6), screen hardness initialization (9, switches to 8 |
| 78 |
* immediately), screen hardness(8), tile hardness(4), sprite |
| 79 |
* chooser(5), tile chooser(2), sprite hardness editor(7), plus input |
| 80 |
* dialog(0). */ |
| 81 |
/* TODO: The goal is to split the big keybinding functions into these |
| 82 |
* modes, and in each mode, call a function instead of inlining the |
| 83 |
* code. And we may use 'else if', or even a hashmap to do the |
| 84 |
* bindings. |
| 85 |
*/ |
| 86 |
|
| 87 |
/* Use constants for readability */ |
| 88 |
enum editor_mode { |
| 89 |
EDITOR_MODE_INIT, |
| 90 |
|
| 91 |
EDITOR_MODE_MINIMAP, |
| 92 |
|
| 93 |
EDITOR_MODE_TILE_PICKER, |
| 94 |
EDITOR_MODE_SPRITE_PICKER, |
| 95 |
|
| 96 |
EDITOR_MODE_SCREEN_TILES, |
| 97 |
EDITOR_MODE_SCREEN_SPRITES, |
| 98 |
EDITOR_MODE_SCREEN_HARDNESS, |
| 99 |
EDITOR_MODE_SCREEN_HARDNESS_INIT, |
| 100 |
|
| 101 |
EDITOR_MODE_TILE_HARDNESS, |
| 102 |
EDITOR_MODE_SPRITE_HARDNESS, |
| 103 |
}; |
| 104 |
static enum editor_mode g_editorMode = EDITOR_MODE_INIT; |
| 105 |
|
| 106 |
#define INPUT_MINIMAP_LOAD 30 |
| 107 |
#define INPUT_SCREEN_VISION 32 |
| 108 |
#define INPUT_SCREEN_MIDI 33 |
| 109 |
#define INPUT_SCREEN_TYPE 34 |
| 110 |
|
| 111 |
enum editor_buttons { |
| 112 |
EDITOR_ACTION_FIRST = 0, // min constant for loops, like SDLKey |
| 113 |
EDITOR_ACTION_NOOP = 0, |
| 114 |
EDITOR_ACTION_ESCAPE = 1, |
| 115 |
EDITOR_ACTION_RETURN, |
| 116 |
EDITOR_ACTION_X, |
| 117 |
EDITOR_ACTION_Z, |
| 118 |
EDITOR_ACTION_TAB, |
| 119 |
EDITOR_ACTION_LAST // max+1 constant for loops |
| 120 |
}; |
| 121 |
|
| 122 |
EditorMap buffmap; |
| 123 |
/*bool*/int buf_mode = /*false*/0; |
| 124 |
static char buf_path[100]; |
| 125 |
static int buf_map = 0; |
| 126 |
static int cur_map; |
| 127 |
|
| 128 |
static int draw_screen_tiny = -1; |
| 129 |
|
| 130 |
/* Save x and y coordinates for mode 4, 5 and 6 */ |
| 131 |
static int m4x,m4y,m5x,m5y,m6x,m6y,m5ax,m5ay; |
| 132 |
|
| 133 |
static int sp_base_walk = -1; |
| 134 |
static int sp_base_idle = -1; |
| 135 |
static int sp_base_attack = -1; |
| 136 |
static int sp_base_hit = -1; |
| 137 |
static int sp_base_die = -1; |
| 138 |
static int sp_gold, sp_defense, sp_strength, sp_exp, sp_hitpoints; |
| 139 |
static int sp_timer = 33; |
| 140 |
static int sp_que; |
| 141 |
static int sp_hard = 1; |
| 142 |
static int sp_sound = 0; |
| 143 |
static int sp_type = 1; |
| 144 |
static int sp_is_warp = 0; |
| 145 |
static int sp_warp_map = 0; |
| 146 |
static /*bool*/int show_display = /*true*/1; |
| 147 |
static int sp_picker = 0; |
| 148 |
static int sp_nohit = 0; |
| 149 |
static int sp_touch_damage = 0; |
| 150 |
static int sp_warp_x = 0; |
| 151 |
static int sp_warp_y = 0; |
| 152 |
static int sp_parm_seq = 0; |
| 153 |
static char sp_script[15]; |
| 154 |
|
| 155 |
static int old_command; |
| 156 |
static int sp_cycle = 0; |
| 157 |
static int cur_tileset; |
| 158 |
static int selx = 1; |
| 159 |
static int sely = 1; |
| 160 |
static int last_mode = 0; |
| 161 |
static int last_modereal = 0; |
| 162 |
static int hold_warp_map, hold_warp_x,hold_warp_y; |
| 163 |
static int sp_seq,sp_frame = 0; |
| 164 |
|
| 165 |
|
| 166 |
/* const int NUM_SOUND_EFFECTS = 6; */ |
| 167 |
#define NUM_SOUND_EFFECTS 2 |
| 168 |
|
| 169 |
typedef enum enum_EFFECT |
| 170 |
{ |
| 171 |
SOUND_STOP = 0, |
| 172 |
/* SOUND_THROW, */ |
| 173 |
SOUND_JUMP, |
| 174 |
/* SOUND_STUNNED, */ |
| 175 |
/* SOUND_BEARSTRIKE, */ |
| 176 |
/* SOUND_BEARMISS, */ |
| 177 |
} EFFECT; |
| 178 |
|
| 179 |
static char *szSoundEffects[NUM_SOUND_EFFECTS] = |
| 180 |
{ |
| 181 |
"stop.wav", |
| 182 |
/* "THROW.WAV", */ |
| 183 |
"jump.wav" |
| 184 |
/* "STUNNED.WAV", */ |
| 185 |
/* "STRIKE02.WAV", */ |
| 186 |
/* "MISS02.WAV" */ |
| 187 |
}; |
| 188 |
|
| 189 |
|
| 190 |
static int x = 640; |
| 191 |
static int y = 480; |
| 192 |
|
| 193 |
static char in_temp[200]; |
| 194 |
static int in_command; |
| 195 |
static int in_onflag; |
| 196 |
static unsigned int in_max = 10; |
| 197 |
static int in_huh = 0; |
| 198 |
static char in_default[200]; |
| 199 |
static int in_master = 0; |
| 200 |
|
| 201 |
static int *in_int; |
| 202 |
static char *in_string; |
| 203 |
static int in_x, in_y; |
| 204 |
static /*bool*/int in_enabled; |
| 205 |
|
| 206 |
static int sp_mode; |
| 207 |
static int sp_speed = 0; |
| 208 |
static int sp_brain = 0; |
| 209 |
static /*bool*/int sp_screenmatch = 0; |
| 210 |
static int hard_tile = 0; |
| 211 |
static int last_sprite_added = 0; |
| 212 |
static int map_vision = 0; |
| 213 |
|
| 214 |
static int m1x,m1y; |
| 215 |
static int m2x,m2y; |
| 216 |
static int m3x,m3y; |
| 217 |
static int cur_tile; |
| 218 |
|
| 219 |
|
| 220 |
/** |
| 221 |
* Append a line of text at the end of a file |
| 222 |
*/ |
| 223 |
static void add_text(char *text, char *filename) |
| 224 |
{ |
| 225 |
if (strlen(text) < 1) |
| 226 |
return; |
| 227 |
|
| 228 |
FILE *fp = paths_dmodfile_fopen(filename, "ab"); |
| 229 |
if (fp != NULL) |
| 230 |
{ |
| 231 |
fwrite(text, strlen(text), 1, fp); |
| 232 |
fclose(fp); |
| 233 |
} |
| 234 |
else |
| 235 |
{ |
| 236 |
perror("add_text"); |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
/** |
| 241 |
* Get the screen tile under coords x,y |
| 242 |
*/ |
| 243 |
int xy2screentile(int x, int y) |
| 244 |
{ |
| 245 |
return |
| 246 |
((y + 1) * 12) / 50 |
| 247 |
+ x / 50; |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
// PROC NAMES |
| 253 |
|
| 254 |
void draw_screen_editor(void); |
| 255 |
void draw_minimap(void); |
| 256 |
/* void dderror(HRESULT hErr); */ |
| 257 |
|
| 258 |
static bool skip_screen_clipping() { |
| 259 |
return (g_editorMode == EDITOR_MODE_MINIMAP || g_editorMode == EDITOR_MODE_SPRITE_PICKER) && draw_screen_tiny < 1; |
| 260 |
} |
| 261 |
|
| 262 |
void draw_sprite(IOGfxSurface* IOGFX_lpdest, int h) { |
| 263 |
rect box_crap,box_real; |
| 264 |
/* HRESULT ddrval; */ |
| 265 |
/* DDBLTFX ddbltfx; */ |
| 266 |
/* ddbltfx.dwSize = sizeof( ddbltfx); */ |
| 267 |
/* ddbltfx.dwFillColor = 0; */ |
| 268 |
|
| 269 |
if (get_box(h, &box_crap, &box_real, skip_screen_clipping())) |
| 270 |
{ |
| 271 |
/* while(1) */ |
| 272 |
/* { */ |
| 273 |
/* again: */ |
| 274 |
/* ddrval = lpdest->Blt(&box_crap, k[getpic(h)].k, */ |
| 275 |
/* &box_real, DDBLT_KEYSRC, &ddbltfx); */ |
| 276 |
|
| 277 |
// GFX |
| 278 |
{ |
| 279 |
SDL_Rect src, dst; |
| 280 |
src.x = box_real.left; |
| 281 |
src.y = box_real.top; |
| 282 |
src.w = box_real.right - box_real.left; |
| 283 |
src.h = box_real.bottom - box_real.top; |
| 284 |
dst.x = box_crap.left; |
| 285 |
dst.y = box_crap.top; |
| 286 |
dst.w = box_crap.right - box_crap.left; |
| 287 |
dst.h = box_crap.bottom - box_crap.top; |
| 288 |
IOGFX_lpdest->blitStretch(GFX_k[getpic(h)].k, &src, &dst); |
| 289 |
} |
| 290 |
|
| 291 |
/* if (ddrval != DD_OK) */ |
| 292 |
/* { */ |
| 293 |
/* if (ddrval == DDERR_WASSTILLDRAWING) */ |
| 294 |
/* goto again; */ |
| 295 |
|
| 296 |
/* //dderror(ddrval); */ |
| 297 |
/* dderror(ddrval); */ |
| 298 |
/* if (draw_screen_tiny > 0) */ |
| 299 |
/* { */ |
| 300 |
/* Msg("MainSpriteDraw(): Could not draw sprite %d, pic %d. (Seq %d, Fram %d) (map %d)",h,getpic(h),spr[h].pseq, spr[h].pframe, draw_screen_tiny); */ |
| 301 |
/* Msg("Box_crap: %d %d %d %d, Box_real: %d %d %d %d",box_crap.left,box_crap.top, */ |
| 302 |
/* box_crap.right, box_crap.bottom,box_real.left,box_real.top, */ |
| 303 |
/* box_real.right, box_real.bottom); */ |
| 304 |
/* } */ |
| 305 |
/* else */ |
| 306 |
/* { */ |
| 307 |
/* Msg("MainSpriteDraw(): Could not draw sprite %d, pic %d. (map %d)",h,getpic(h), cur_map); */ |
| 308 |
/* } */ |
| 309 |
/* check_sprite_status(h); */ |
| 310 |
/* break; */ |
| 311 |
/* } */ |
| 312 |
/* break; */ |
| 313 |
/* } */ |
| 314 |
} |
| 315 |
} |
| 316 |
|
| 317 |
|
| 318 |
/** |
| 319 |
* Draw all screen sprites, ordered by queue. |
| 320 |
* |
| 321 |
* Also cf. game's game_place_sprites(...) and |
| 322 |
* game_place_sprites_background(...). |
| 323 |
*/ |
| 324 |
void place_sprites() |
| 325 |
{ |
| 326 |
int rank[MAX_SPRITES_EDITOR]; |
| 327 |
screen_rank_editor_sprites(rank); |
| 328 |
|
| 329 |
int r1 = 0; |
| 330 |
for (; r1 < MAX_SPRITES_EDITOR && rank[r1] > 0; r1++) |
| 331 |
{ |
| 332 |
//Msg("Ok, rank[%d] is %d.",oo,rank[oo]); |
| 333 |
int j = rank[r1]; |
| 334 |
|
| 335 |
if (cur_ed_screen.sprite[j].active == 1 |
| 336 |
&& (cur_ed_screen.sprite[j].vision == 0 || cur_ed_screen.sprite[j].vision == map_vision)) |
| 337 |
{ |
| 338 |
//we have instructions to make a sprite |
| 339 |
|
| 340 |
if (cur_ed_screen.sprite[j].type == 0 || cur_ed_screen.sprite[j].type == 2) |
| 341 |
{ |
| 342 |
//make it part of the background (much faster) |
| 343 |
int sprite = add_sprite_dumb(cur_ed_screen.sprite[j].x,cur_ed_screen.sprite[j].y, 0, |
| 344 |
cur_ed_screen.sprite[j].seq,cur_ed_screen.sprite[j].frame, |
| 345 |
cur_ed_screen.sprite[j].size); |
| 346 |
|
| 347 |
spr[sprite].hard = cur_ed_screen.sprite[j].hard; |
| 348 |
check_sprite_status(sprite); |
| 349 |
spr[sprite].sp_index = j; |
| 350 |
rect_copy(&spr[sprite].alt , &cur_ed_screen.sprite[j].alt); |
| 351 |
|
| 352 |
if (cur_ed_screen.sprite[j].type == 0) |
| 353 |
draw_sprite(IOGFX_background, sprite); |
| 354 |
|
| 355 |
if (spr[sprite].hard == 0) |
| 356 |
{ |
| 357 |
if (cur_ed_screen.sprite[j].is_warp == 0) |
| 358 |
add_hardness(sprite, 1); |
| 359 |
else add_hardness(sprite, 100 + j); |
| 360 |
} |
| 361 |
|
| 362 |
lsm_remove_sprite(sprite); |
| 363 |
} |
| 364 |
|
| 365 |
if (cur_ed_screen.sprite[j].type == 1) |
| 366 |
{ |
| 367 |
//make it a living sprite |
| 368 |
|
| 369 |
int sprite = add_sprite_dumb(cur_ed_screen.sprite[j].x,cur_ed_screen.sprite[j].y, 0, |
| 370 |
cur_ed_screen.sprite[j].seq,cur_ed_screen.sprite[j].frame, |
| 371 |
cur_ed_screen.sprite[j].size); |
| 372 |
|
| 373 |
spr[sprite].que = cur_ed_screen.sprite[j].que; |
| 374 |
check_sprite_status(sprite); |
| 375 |
spr[sprite].hard = cur_ed_screen.sprite[j].hard; |
| 376 |
|
| 377 |
rect_copy(&spr[sprite].alt , &cur_ed_screen.sprite[j].alt); |
| 378 |
|
| 379 |
if (spr[sprite].hard == 0) |
| 380 |
{ |
| 381 |
if (cur_ed_screen.sprite[j].is_warp == 0) |
| 382 |
add_hardness(sprite, 1); else add_hardness(sprite,100+j); |
| 383 |
} |
| 384 |
} |
| 385 |
} |
| 386 |
} |
| 387 |
} |
| 388 |
|
| 389 |
void editor_save_screen(int num) { |
| 390 |
save_screen(g_dmod.map.map_dat.c_str(), num); |
| 391 |
} |
| 392 |
|
| 393 |
void editor_load_screen(int num) |
| 394 |
{ |
| 395 |
if (load_screen_to(g_dmod.map.map_dat.c_str(), num, &cur_ed_screen) < 0) |
| 396 |
return; |
| 397 |
fill_whole_hard(); |
| 398 |
} |
| 399 |
|
| 400 |
/* Draw background from tiles */ |
| 401 |
void draw_screen_editor(void) |
| 402 |
{ |
| 403 |
IOGFX_background->fillRect(NULL, 0,0,0); |
| 404 |
fill_whole_hard(); |
| 405 |
|
| 406 |
lsm_kill_all_nonlive_sprites(); |
| 407 |
|
| 408 |
gfx_tiles_draw_screen(g_dmod.bgTilesets.slots, cur_ed_screen.t); |
| 409 |
place_sprites(); |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
/** |
| 416 |
* Draw the currently selected tile square (in the bottom-right corner |
| 417 |
* of the screen) |
| 418 |
*/ |
| 419 |
void draw_current() |
| 420 |
{ |
| 421 |
int srctileset_idx0 = cur_tile / 128; |
| 422 |
int srctile_square_idx0 = cur_tile % 128; |
| 423 |
|
| 424 |
SDL_Rect src; |
| 425 |
int srctile_square_x = srctile_square_idx0 % GFX_TILES_SCREEN_W; |
| 426 |
int srctile_square_y = srctile_square_idx0 / GFX_TILES_SCREEN_W; |
| 427 |
src.x = srctile_square_x * GFX_TILES_SQUARE_SIZE; |
| 428 |
src.y = srctile_square_y * GFX_TILES_SQUARE_SIZE; |
| 429 |
src.w = GFX_TILES_SQUARE_SIZE; |
| 430 |
src.h = GFX_TILES_SQUARE_SIZE; |
| 431 |
|
| 432 |
SDL_Rect dst = {590, 430}; |
| 433 |
IOGFX_background->blit(g_dmod.bgTilesets.slots[srctileset_idx0 + 1], &src, &dst); |
| 434 |
} |
| 435 |
|
| 436 |
|
| 437 |
/* Draw harness. */ |
| 438 |
void drawallhard( void) |
| 439 |
{ |
| 440 |
/* rect box_crap; */ |
| 441 |
/* int ddrval; */ |
| 442 |
/* DDBLTFX ddbltfx; */ |
| 443 |
int x1, y1; |
| 444 |
|
| 445 |
/* TODO: test me! Then factor the code */ |
| 446 |
for (x1=0; x1 < 600; x1++) |
| 447 |
for (y1=0; y1 < 400; y1++) |
| 448 |
{ |
| 449 |
if (screen_hitmap[x1][y1] == 1) |
| 450 |
{ |
| 451 |
/* ddbltfx.dwFillColor = 1; */ |
| 452 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 453 |
/* box_crap.top = y1; */ |
| 454 |
/* box_crap.bottom = y1+1; */ |
| 455 |
/* box_crap.left = x1+playl; //20 is to compensate for the border */ |
| 456 |
/* box_crap.right = x1+1+playl; */ |
| 457 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); */ |
| 458 |
/* if (ddrval != DD_OK) Msg("There was an error!"); */ |
| 459 |
// GFX |
| 460 |
{ |
| 461 |
SDL_Rect GFX_box_crap; |
| 462 |
GFX_box_crap.x = x1 + playl; |
| 463 |
GFX_box_crap.y = y1; |
| 464 |
GFX_box_crap.w = 1; |
| 465 |
GFX_box_crap.h = 1; |
| 466 |
IOGFX_backbuffer->fillRect(&GFX_box_crap, GFX_ref_pal[1].r, GFX_ref_pal[1].g, GFX_ref_pal[1].b); |
| 467 |
} |
| 468 |
} |
| 469 |
|
| 470 |
if (screen_hitmap[x1][y1] == 2) |
| 471 |
{ |
| 472 |
/* ddbltfx.dwFillColor = 128; */ |
| 473 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 474 |
/* box_crap.top = y1; */ |
| 475 |
/* box_crap.bottom = y1+1; */ |
| 476 |
/* box_crap.left = x1+playl; //20 is to compensate for the border */ |
| 477 |
/* box_crap.right = x1+1+playl; */ |
| 478 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); */ |
| 479 |
/* if (ddrval != DD_OK) Msg("There was an error!"); */ |
| 480 |
// GFX |
| 481 |
{ |
| 482 |
SDL_Rect GFX_box_crap; |
| 483 |
GFX_box_crap.x = x1 + playl; |
| 484 |
GFX_box_crap.y = y1; |
| 485 |
GFX_box_crap.w = 1; |
| 486 |
GFX_box_crap.h = 1; |
| 487 |
IOGFX_backbuffer->fillRect(&GFX_box_crap, GFX_ref_pal[128].r, GFX_ref_pal[128].g, GFX_ref_pal[128].b); |
| 488 |
} |
| 489 |
} |
| 490 |
|
| 491 |
if (screen_hitmap[x1][y1] == 3) |
| 492 |
{ |
| 493 |
/* ddbltfx.dwFillColor = 45; */ |
| 494 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 495 |
/* box_crap.top = y1; */ |
| 496 |
/* box_crap.bottom = y1+1; */ |
| 497 |
/* box_crap.left = x1+playl; //20 is to compensate for the border */ |
| 498 |
/* box_crap.right = x1+1+playl; */ |
| 499 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); */ |
| 500 |
/* if (ddrval != DD_OK) Msg("There was an error!"); */ |
| 501 |
// GFX |
| 502 |
{ |
| 503 |
SDL_Rect GFX_box_crap; |
| 504 |
GFX_box_crap.x = x1 + playl; |
| 505 |
GFX_box_crap.y = y1; |
| 506 |
GFX_box_crap.w = 1; |
| 507 |
GFX_box_crap.h = 1; |
| 508 |
IOGFX_backbuffer->fillRect(&GFX_box_crap, GFX_ref_pal[45].r, GFX_ref_pal[45].g, GFX_ref_pal[45].b); |
| 509 |
} |
| 510 |
} |
| 511 |
|
| 512 |
if (screen_hitmap[x1][y1] > 100) |
| 513 |
{ |
| 514 |
|
| 515 |
if (cur_ed_screen.sprite[ (screen_hitmap[x1][y1]) - 100].is_warp == 1) |
| 516 |
{ |
| 517 |
//draw a little pixel |
| 518 |
/* ddbltfx.dwFillColor = 20; */ |
| 519 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 520 |
/* box_crap.top = y1; */ |
| 521 |
/* box_crap.bottom = y1+1; */ |
| 522 |
/* box_crap.left = x1+playl; //20 is to compensate for the border */ |
| 523 |
/* box_crap.right = x1+1+playl; */ |
| 524 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); */ |
| 525 |
/* if (ddrval != DD_OK) Msg("There was an error!"); */ |
| 526 |
// GFX |
| 527 |
{ |
| 528 |
SDL_Rect GFX_box_crap; |
| 529 |
GFX_box_crap.x = x1 + playl; |
| 530 |
GFX_box_crap.y = y1; |
| 531 |
GFX_box_crap.w = 1; |
| 532 |
GFX_box_crap.h = 1; |
| 533 |
IOGFX_backbuffer->fillRect(&GFX_box_crap, GFX_ref_pal[20].r, GFX_ref_pal[20].g, GFX_ref_pal[20].b); |
| 534 |
} |
| 535 |
} |
| 536 |
else |
| 537 |
{ |
| 538 |
//draw a little pixel |
| 539 |
/* ddbltfx.dwFillColor = 23; */ |
| 540 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 541 |
/* box_crap.top = y1; */ |
| 542 |
/* box_crap.bottom = y1+1; */ |
| 543 |
/* box_crap.left = x1+playl; //20 is to compensate for the border */ |
| 544 |
/* box_crap.right = x1+1+playl; */ |
| 545 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); */ |
| 546 |
/* if (ddrval != DD_OK) Msg("There was an error!"); */ |
| 547 |
// GFX |
| 548 |
{ |
| 549 |
SDL_Rect GFX_box_crap; |
| 550 |
GFX_box_crap.x = x1 + playl; |
| 551 |
GFX_box_crap.y = y1; |
| 552 |
GFX_box_crap.w = 1; |
| 553 |
GFX_box_crap.h = 1; |
| 554 |
IOGFX_backbuffer->fillRect(&GFX_box_crap, GFX_ref_pal[23].r, GFX_ref_pal[23].g, GFX_ref_pal[23].b); |
| 555 |
} |
| 556 |
} |
| 557 |
} |
| 558 |
} |
| 559 |
} |
| 560 |
|
| 561 |
/* Edit a tile hardness - show semi-transparent red/blue/orange |
| 562 |
squares on pixels with different kinds of hardness */ |
| 563 |
void draw_hard( void) |
| 564 |
{ |
| 565 |
//RECT rcRect; |
| 566 |
int x; |
| 567 |
for (x = 0; x < 50; x++) |
| 568 |
{ |
| 569 |
int y; |
| 570 |
for (y = 0; y < 50; y++) |
| 571 |
{ |
| 572 |
/* red */ |
| 573 |
if (hmap.htile[hard_tile].hm[x][y] == 1) |
| 574 |
{ |
| 575 |
/* lpDDSBack->BltFast(95+(x*9), y*9, k[seq[10].frame[2]].k, */ |
| 576 |
/* &k[seq[10].frame[2]].box, DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT); */ |
| 577 |
// GFX |
| 578 |
{ |
| 579 |
SDL_Rect dst; |
| 580 |
dst.x = 95 + x*9; |
| 581 |
dst.y = y*9; |
| 582 |
IOGFX_backbuffer->blit(GFX_k[seq[10].frame[2]].k, NULL, &dst); |
| 583 |
} |
| 584 |
} |
| 585 |
|
| 586 |
/* blue */ |
| 587 |
if (hmap.htile[hard_tile].hm[x][y] == 2) |
| 588 |
{ |
| 589 |
/* lpDDSBack->BltFast(95+(x*9),y*9, k[seq[10].frame[9]].k, */ |
| 590 |
/* &k[seq[10].frame[9]].box, DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT); */ |
| 591 |
// GFX |
| 592 |
{ |
| 593 |
SDL_Rect dst; |
| 594 |
dst.x = 95 + x*9; |
| 595 |
dst.y = y*9; |
| 596 |
IOGFX_backbuffer->blit(GFX_k[seq[10].frame[9]].k, NULL, &dst); |
| 597 |
} |
| 598 |
} |
| 599 |
|
| 600 |
/* orange */ |
| 601 |
if (hmap.htile[hard_tile].hm[x][y] == 3) |
| 602 |
{ |
| 603 |
/* lpDDSBack->BltFast(95+(x*9),y*9, k[seq[10].frame[10]].k, */ |
| 604 |
/* &k[seq[10].frame[10]].box, DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT); */ |
| 605 |
// GFX |
| 606 |
{ |
| 607 |
SDL_Rect dst; |
| 608 |
dst.x = 95 + x*9; |
| 609 |
dst.y = y*9; |
| 610 |
IOGFX_backbuffer->blit(GFX_k[seq[10].frame[10]].k, NULL, &dst); |
| 611 |
} |
| 612 |
} |
| 613 |
} |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
|
| 618 |
void |
| 619 |
draw_this_map(EditorMap* pmap) |
| 620 |
{ |
| 621 |
int x; |
| 622 |
for (x = 0; x < 768; x++) |
| 623 |
{ |
| 624 |
/* Blue square - unused screen */ |
| 625 |
if (pmap->loc[x+1] == 0) |
| 626 |
{ |
| 627 |
/* lpDDSTwo->BltFast((x) * 20 - ((x / 32) * 640), (x / 32) * 20, k[seq[10].frame[6]].k, */ |
| 628 |
/* &k[seq[10].frame[6]].box, DDBLTFAST_NOCOLORKEY| DDBLTFAST_WAIT ); */ |
| 629 |
// GFX |
| 630 |
{ |
| 631 |
SDL_Rect dst; |
| 632 |
dst.x = x * 20 - x/32*640; |
| 633 |
dst.y = x/32 * 20; |
| 634 |
IOGFX_background->blitNoColorKey(GFX_k[seq[10].frame[6]].k, NULL, &dst); |
| 635 |
} |
| 636 |
} |
| 637 |
/* Red square - used screen */ |
| 638 |
if (pmap->loc[x+1] > 0) |
| 639 |
{ |
| 640 |
/* lpDDSTwo->BltFast((x) * 20 - ((x / 32) * 640), (x / 32) * 20, k[seq[10].frame[7]].k, */ |
| 641 |
/* &k[seq[10].frame[7]].box, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); */ |
| 642 |
// GFX |
| 643 |
{ |
| 644 |
SDL_Rect dst; |
| 645 |
dst.x = x * 20 - x/32*640; |
| 646 |
dst.y = x/32 * 20; |
| 647 |
IOGFX_background->blitNoColorKey(GFX_k[seq[10].frame[7]].k, NULL, &dst); |
| 648 |
} |
| 649 |
} |
| 650 |
|
| 651 |
/* M mark - screen has MIDI */ |
| 652 |
if (pmap->music[x+1] != 0) |
| 653 |
{ |
| 654 |
/* lpDDSTwo->BltFast((x) * 20 - ((x / 32) * 640), (x / 32) * 20, k[seq[10].frame[12]].k, */ |
| 655 |
/* &k[seq[10].frame[12]].box, DDBLTFAST_SRCCOLORKEY| DDBLTFAST_WAIT ); */ |
| 656 |
// GFX |
| 657 |
{ |
| 658 |
SDL_Rect dst; |
| 659 |
dst.x = x * 20 - x/32*640; |
| 660 |
dst.y = x/32 * 20; |
| 661 |
IOGFX_background->blit(GFX_k[seq[10].frame[12]].k, NULL, &dst); |
| 662 |
} |
| 663 |
} |
| 664 |
/* S mark - screen has screentype / is indoor */ |
| 665 |
if (pmap->indoor[x+1] != 0) |
| 666 |
{ |
| 667 |
/* lpDDSTwo->BltFast( (x) * 20 - ((x / 32) * 640), (x / 32) * 20, k[seq[10].frame[13]].k, */ |
| 668 |
/* &k[seq[10].frame[13]].box, DDBLTFAST_SRCCOLORKEY| DDBLTFAST_WAIT ); */ |
| 669 |
// GFX |
| 670 |
{ |
| 671 |
SDL_Rect dst; |
| 672 |
dst.x = x * 20 - x/32*640; |
| 673 |
dst.y = x/32 * 20; |
| 674 |
IOGFX_background->blit(GFX_k[seq[10].frame[13]].k, NULL, &dst); |
| 675 |
} |
| 676 |
} |
| 677 |
} |
| 678 |
} |
| 679 |
|
| 680 |
/* Draw all squares in the map picker mode, including the 'M' (midi) |
| 681 |
and 'S' (screentype) marks */ |
| 682 |
void draw_minimap(void) |
| 683 |
{ |
| 684 |
/*box_crap.top = spr[h].y + k[spr[h].pic].hardbox.top; |
| 685 |
box_crap.bottom = spr[h].y + k[spr[h].pic].hardbox.bottom; |
| 686 |
box_crap.left = spr[h].x + k[spr[h].pic].hardbox.left; |
| 687 |
box_crap.right = spr[h].x + k[spr[h].pic].hardbox.right; |
| 688 |
*/ |
| 689 |
//lpDDSBack->Blt(NULL ,NULL,NULL, DDBLT_COLORFILL, &ddbltfx); |
| 690 |
draw_this_map(&g_dmod.map); |
| 691 |
} |
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
/*bool*/int load_screen_buf(const int num) |
| 697 |
{ |
| 698 |
char mapdat_path[120]; |
| 699 |
/* TODO: Dinkedit historically loads map with a filename relative to |
| 700 |
the current D-Mod directory. Maybe change that to handle absolute |
| 701 |
paths and paths relative to the refdir. */ |
| 702 |
sprintf(mapdat_path, "%sMAP.DAT", buf_path); |
| 703 |
load_screen_to(mapdat_path, num, &cur_ed_screen); |
| 704 |
|
| 705 |
return /*true*/1; |
| 706 |
} |
| 707 |
|
| 708 |
void load_info_buff(void) |
| 709 |
{ |
| 710 |
char dinkdat_path[120]; |
| 711 |
|
| 712 |
sprintf(dinkdat_path, "%sDINK.DAT", buf_path); |
| 713 |
|
| 714 |
buffmap.dink_dat = dinkdat_path; |
| 715 |
if (!buffmap.load()) |
| 716 |
{ |
| 717 |
log_error("World not found in %s.", buf_path); |
| 718 |
buf_mode = /*false*/0; |
| 719 |
} |
| 720 |
else |
| 721 |
{ |
| 722 |
log_info("World data loaded."); |
| 723 |
buf_mode = /*true*/1; |
| 724 |
} |
| 725 |
} |
| 726 |
|
| 727 |
/* draw_minimap() but on a different map ('L' in map picker mode) */ |
| 728 |
void draw_minimap_buff(void) |
| 729 |
{ |
| 730 |
load_info_buff(); |
| 731 |
|
| 732 |
if (!buf_mode) |
| 733 |
{ |
| 734 |
//failed |
| 735 |
/* TODO: display error message to the user */ |
| 736 |
draw_minimap(); |
| 737 |
return; |
| 738 |
} |
| 739 |
|
| 740 |
draw_this_map(&buffmap); |
| 741 |
} |
| 742 |
|
| 743 |
|
| 744 |
/** |
| 745 |
* Add new screen to the map |
| 746 |
*/ |
| 747 |
int add_new_map() |
| 748 |
{ |
| 749 |
int loc_max = 0; |
| 750 |
for (int i = 0; i < 768+1; i++) |
| 751 |
if (g_dmod.map.loc[i] > loc_max) |
| 752 |
loc_max = g_dmod.map.loc[i]; |
| 753 |
|
| 754 |
int loc_new = loc_max + 1; |
| 755 |
if (loc_new > 768) |
| 756 |
return -1; |
| 757 |
|
| 758 |
editor_save_screen(loc_new); |
| 759 |
return loc_new; |
| 760 |
} |
| 761 |
|
| 762 |
|
| 763 |
void show_text_box(int enabled) { |
| 764 |
if (enabled) { |
| 765 |
in_enabled = 1; |
| 766 |
SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE); |
| 767 |
} else { |
| 768 |
in_enabled = 0; |
| 769 |
SDL_EventState(SDL_TEXTINPUT, SDL_IGNORE); |
| 770 |
} |
| 771 |
} |
| 772 |
|
| 773 |
|
| 774 |
/* Update mouse position with relative motion coordinates */ |
| 775 |
void freedinkedit_update_cursor_position(SDL_Event* ev) |
| 776 |
{ |
| 777 |
if (ev->type != SDL_MOUSEMOTION) |
| 778 |
return; |
| 779 |
|
| 780 |
int dx = ev->motion.xrel; |
| 781 |
int dy = ev->motion.yrel; |
| 782 |
|
| 783 |
sp_cycle = 0; |
| 784 |
spr[1].x += dx; |
| 785 |
spr[1].y += dy; |
| 786 |
} |
| 787 |
|
| 788 |
void check_joystick() |
| 789 |
{ |
| 790 |
/* Clean-up */ |
| 791 |
/* Actions */ |
| 792 |
{ |
| 793 |
int a = EDITOR_ACTION_FIRST; |
| 794 |
for (a = EDITOR_ACTION_FIRST; a < EDITOR_ACTION_LAST; a++) |
| 795 |
sjoy.joybit[a] = 0; |
| 796 |
} |
| 797 |
|
| 798 |
/* Arrows */ |
| 799 |
sjoy.right = 0; |
| 800 |
sjoy.left = 0; |
| 801 |
sjoy.up = 0; |
| 802 |
sjoy.down = 0; |
| 803 |
|
| 804 |
if (joystick) |
| 805 |
{ |
| 806 |
SDL_JoystickUpdate(); |
| 807 |
Sint16 x_pos = 0, y_pos = 0; |
| 808 |
/* SDL counts buttons from 0, not from 1 */ |
| 809 |
int i = 0; |
| 810 |
for (i = 0; i < NB_BUTTONS; i++) |
| 811 |
if (SDL_JoystickGetButton(jinfo, i)) |
| 812 |
{ |
| 813 |
if (i == 1-1) |
| 814 |
sjoy.joybit[EDITOR_ACTION_ESCAPE] = 1; |
| 815 |
else if (i == 2-1) |
| 816 |
sjoy.joybit[EDITOR_ACTION_RETURN] = 1; |
| 817 |
else if (i == 3-1) |
| 818 |
sjoy.joybit[EDITOR_ACTION_X] = 1; |
| 819 |
else if (i == 4-1) |
| 820 |
sjoy.joybit[EDITOR_ACTION_Z] = 1; |
| 821 |
else if (i == 5-1) |
| 822 |
sjoy.joybit[EDITOR_ACTION_TAB] = 1; |
| 823 |
} |
| 824 |
|
| 825 |
x_pos = SDL_JoystickGetAxis(jinfo, 0); |
| 826 |
y_pos = SDL_JoystickGetAxis(jinfo, 1); |
| 827 |
/* Using thresold=10% (original game) is just enough to get rid |
| 828 |
of the noise. Let's use 30% instead, otherwise Dink will go |
| 829 |
diags too easily. */ |
| 830 |
{ |
| 831 |
Sint16 threshold = 32767 * 30/100; |
| 832 |
if (x_pos < -threshold) sjoy.left = 1; |
| 833 |
if (x_pos > +threshold) sjoy.right = 1; |
| 834 |
if (y_pos < -threshold) sjoy.up = 1; |
| 835 |
if (y_pos > +threshold) sjoy.down = 1; |
| 836 |
} |
| 837 |
} |
| 838 |
|
| 839 |
if (input_getscancodestate(SDL_SCANCODE_ESCAPE)) sjoy.joybit[EDITOR_ACTION_ESCAPE] = 1; |
| 840 |
if (input_getscancodestate(SDL_SCANCODE_RETURN)) sjoy.joybit[EDITOR_ACTION_RETURN] = 1; |
| 841 |
if (input_getcharstate(SDLK_x)) sjoy.joybit[EDITOR_ACTION_X] = 1; |
| 842 |
if (input_getcharstate(SDLK_z)) sjoy.joybit[EDITOR_ACTION_Z] = 1; |
| 843 |
if (input_getscancodestate(SDL_SCANCODE_TAB)) sjoy.joybit[EDITOR_ACTION_TAB] = 1; |
| 844 |
if (input_getscancodestate(SDL_SCANCODE_RIGHT)) sjoy.right = 1; |
| 845 |
if (input_getscancodestate(SDL_SCANCODE_LEFT)) sjoy.left = 1; |
| 846 |
if (input_getscancodestate(SDL_SCANCODE_DOWN)) sjoy.down = 1; |
| 847 |
if (input_getscancodestate(SDL_SCANCODE_UP)) sjoy.up = 1; |
| 848 |
|
| 849 |
{ |
| 850 |
int a = EDITOR_ACTION_FIRST; |
| 851 |
for (a = EDITOR_ACTION_FIRST; a < EDITOR_ACTION_LAST; a++) |
| 852 |
{ |
| 853 |
sjoy.button[a] = 0; |
| 854 |
if (sjoy.joybit[a] && sjoy.joybitold[a] == 0) |
| 855 |
/* Button was just pressed */ |
| 856 |
sjoy.button[a] = 1; |
| 857 |
sjoy.joybitold[a] = sjoy.joybit[a]; |
| 858 |
} |
| 859 |
} |
| 860 |
} |
| 861 |
|
| 862 |
|
| 863 |
/* Displays a tile fullscreen, so we can select some squares */ |
| 864 |
void loadtile(int tileset) |
| 865 |
{ |
| 866 |
/* DDBLTFX ddbltfx; */ |
| 867 |
/* ZeroMemory(&ddbltfx, sizeof(ddbltfx)); */ |
| 868 |
|
| 869 |
//feel tile background with a color |
| 870 |
|
| 871 |
/* ddbltfx.dwFillColor = 0; */ |
| 872 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 873 |
/* lpDDSTwo->Blt(NULL,NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); */ |
| 874 |
// GFX |
| 875 |
IOGFX_background->fillRect(NULL, 0,0,0); |
| 876 |
|
| 877 |
spr[1].seq = 3; spr[1].seq_orig = 3; |
| 878 |
// if (mode == 3) |
| 879 |
if (g_editorMode == EDITOR_MODE_SCREEN_TILES) |
| 880 |
{ |
| 881 |
m3x = spr[1].x; m3y = spr[1].y; |
| 882 |
spr[1].x = m2x; spr[1].y = m2y; g_editorMode = EDITOR_MODE_TILE_PICKER; |
| 883 |
spr[1].speed = 50; |
| 884 |
} |
| 885 |
|
| 886 |
// if (mode == 4) |
| 887 |
if (g_editorMode == EDITOR_MODE_TILE_HARDNESS) |
| 888 |
{ |
| 889 |
spr[1].x = m2x; spr[1].y = m2y; g_editorMode = EDITOR_MODE_TILE_PICKER; |
| 890 |
spr[1].speed = 50; |
| 891 |
} |
| 892 |
|
| 893 |
/* lpDDSTwo->BltFast(0, 0, tiles[tileset], &tilerect[tileset], DDBLTFAST_NOCOLORKEY |DDBLTFAST_WAIT); */ |
| 894 |
// GFX |
| 895 |
IOGFX_background->blit(g_dmod.bgTilesets.slots[tileset], NULL, NULL); |
| 896 |
cur_tileset = tileset; |
| 897 |
|
| 898 |
last_mode = tileset; |
| 899 |
|
| 900 |
lsm_kill_all_nonlive_sprites(); |
| 901 |
} |
| 902 |
|
| 903 |
|
| 904 |
int sp_get( int num) |
| 905 |
{ |
| 906 |
|
| 907 |
int t = 1; |
| 908 |
int j; |
| 909 |
for (j = 1; j < MAX_SEQUENCES; j++) |
| 910 |
{ |
| 911 |
check_frame_status(j, 1); |
| 912 |
|
| 913 |
if (seq[j].frame[1] != 0) |
| 914 |
{ |
| 915 |
if (t == num) |
| 916 |
{ |
| 917 |
|
| 918 |
|
| 919 |
return(j); |
| 920 |
|
| 921 |
} |
| 922 |
t++; |
| 923 |
|
| 924 |
} |
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
} |
| 929 |
|
| 930 |
return(0); |
| 931 |
|
| 932 |
} |
| 933 |
|
| 934 |
/* In sprite picking mode, draw a grid to separate sprites or |
| 935 |
sequences' 50x50 previews */ |
| 936 |
static void draw_sprite_picker_grid(void) |
| 937 |
{ |
| 938 |
for (int x = 1; x <= 12; x++) |
| 939 |
IOGFX_background->vlineRGB(x*50-1, 0,400, 123,132,99); |
| 940 |
for (int y = 1; y <= 8; y++) |
| 941 |
IOGFX_background->hlineRGB(0,600, y*50-1, 123,132,99); |
| 942 |
} |
| 943 |
|
| 944 |
/* Main sprite selection screen - display a page of the sequence |
| 945 |
selector */ |
| 946 |
void draw15(int num) |
| 947 |
{ |
| 948 |
/* int crap; */ |
| 949 |
/* DDBLTFX ddbltfx; */ |
| 950 |
/* rect crapRec, Rect, box_crap; */ |
| 951 |
int frame; |
| 952 |
/* int ddrval; */ |
| 953 |
int se; |
| 954 |
/* int dd; */ |
| 955 |
int x1; |
| 956 |
//get_sp_seq(2); |
| 957 |
|
| 958 |
lsm_kill_all_nonlive_sprites(); |
| 959 |
|
| 960 |
|
| 961 |
/* ZeroMemory(&ddbltfx, sizeof(ddbltfx)); */ |
| 962 |
/* ddbltfx.dwSize = sizeof( ddbltfx); */ |
| 963 |
/* ddbltfx.dwFillColor = 0; */ |
| 964 |
/* crap = lpDDSTwo->Blt(NULL ,NULL,NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); */ |
| 965 |
// GFX |
| 966 |
IOGFX_background->fillRect(NULL, 0,0,0); |
| 967 |
|
| 968 |
/* ZeroMemory(&ddbltfx, sizeof(ddbltfx)); */ |
| 969 |
/* ddbltfx.dwSize = sizeof( ddbltfx); */ |
| 970 |
|
| 971 |
Say("Please wait, loading sprite data into SmartCache system...", 147,160); |
| 972 |
|
| 973 |
g_display->flipStretch(IOGFX_backbuffer); |
| 974 |
|
| 975 |
/* Draw sprites */ |
| 976 |
for (x1 = 0; x1 <= 11; x1++) |
| 977 |
{ |
| 978 |
int y1; |
| 979 |
for (y1=0; y1 <= 7; y1++) |
| 980 |
{ |
| 981 |
num++; |
| 982 |
|
| 983 |
se = sp_get(num); |
| 984 |
check_seq_status(se); |
| 985 |
|
| 986 |
if (se > 0) |
| 987 |
{ |
| 988 |
frame = 1; |
| 989 |
|
| 990 |
/* Rect.left = x1 * 50; */ |
| 991 |
/* Rect.top = y1 * 50; */ |
| 992 |
/* Rect.right = Rect.left + 50; */ |
| 993 |
/* Rect.bottom = Rect.top + 50; */ |
| 994 |
|
| 995 |
/* crapRec = k[seq[se].frame[frame]].box; */ |
| 996 |
|
| 997 |
/* dd = lpDDSTwo->Blt(&Rect, k[seq[se].frame[frame]].k, */ |
| 998 |
/* &crapRec, DDBLT_KEYSRC | DDBLT_DDFX | DDBLT_WAIT, &ddbltfx); */ |
| 999 |
// GFX |
| 1000 |
{ |
| 1001 |
SDL_Rect dst; |
| 1002 |
dst.x = x1 * 50; |
| 1003 |
dst.y = y1 * 50; |
| 1004 |
dst.w = 50; |
| 1005 |
dst.h = 50; |
| 1006 |
IOGFX_background->blitStretch(GFX_k[seq[se].frame[frame]].k, NULL, &dst); |
| 1007 |
} |
| 1008 |
|
| 1009 |
|
| 1010 |
/* if (dd != DD_OK) Msg("Error with drawing sprite! Seq %d, Spr %d.", se, frame); */ |
| 1011 |
} |
| 1012 |
} |
| 1013 |
} |
| 1014 |
draw_sprite_picker_grid(); |
| 1015 |
} |
| 1016 |
|
| 1017 |
/* Inner sprite selection screen - display all frames/sprites in a |
| 1018 |
sequence */ |
| 1019 |
void draw96(int def) |
| 1020 |
{ |
| 1021 |
/* int crap; */ |
| 1022 |
/* DDBLTFX ddbltfx; */ |
| 1023 |
/* rect crapRec, Rect, box_crap; */ |
| 1024 |
/* int ddrval; */ |
| 1025 |
int se; |
| 1026 |
/* int dd; */ |
| 1027 |
int x1; |
| 1028 |
|
| 1029 |
//get_sp_seq(2); |
| 1030 |
se = sp_seq; |
| 1031 |
check_seq_status(se); |
| 1032 |
int num = 0; |
| 1033 |
lsm_kill_all_nonlive_sprites(); |
| 1034 |
|
| 1035 |
/* ZeroMemory(&ddbltfx, sizeof(ddbltfx)); */ |
| 1036 |
/* ddbltfx.dwSize = sizeof( ddbltfx); */ |
| 1037 |
/* ddbltfx.dwFillColor = 0; */ |
| 1038 |
/* crap = lpDDSTwo->Blt(NULL ,NULL,NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); */ |
| 1039 |
// GFX |
| 1040 |
IOGFX_background->fillRect(NULL, 0,0,0); |
| 1041 |
|
| 1042 |
/* ZeroMemory(&ddbltfx, sizeof(ddbltfx)); */ |
| 1043 |
/* ddbltfx.dwSize = sizeof( ddbltfx); */ |
| 1044 |
|
| 1045 |
for (x1=0; x1 <= 11; x1++) |
| 1046 |
{ |
| 1047 |
int y1; |
| 1048 |
for (y1=0; y1 <= 7; y1++) |
| 1049 |
{ |
| 1050 |
num++; |
| 1051 |
if (seq[se].frame[num] == 0) |
| 1052 |
{ |
| 1053 |
//all done displaying |
| 1054 |
goto pass; |
| 1055 |
} |
| 1056 |
//se = sp_get(num); |
| 1057 |
|
| 1058 |
/* Rect.left = x1 * 50; */ |
| 1059 |
/* Rect.top = y1 * 50; */ |
| 1060 |
/* Rect.right = Rect.left + 50; */ |
| 1061 |
/* Rect.bottom = Rect.top + 50; */ |
| 1062 |
|
| 1063 |
if (def > 0 && num == def) |
| 1064 |
{ |
| 1065 |
//set default location to sprite they are holding |
| 1066 |
spr[1].x = x1*50; |
| 1067 |
spr[1].y = y1 *50; |
| 1068 |
} |
| 1069 |
|
| 1070 |
/* crapRec = k[seq[se].frame[num]].box; */ |
| 1071 |
|
| 1072 |
/* dd = lpDDSTwo->Blt(&Rect, k[seq[se].frame[num]].k, */ |
| 1073 |
/* &crapRec, DDBLT_KEYSRC | DDBLT_DDFX | DDBLT_WAIT, &ddbltfx ); */ |
| 1074 |
// GFX |
| 1075 |
{ |
| 1076 |
SDL_Rect dst; |
| 1077 |
dst.x = x1 * 50; |
| 1078 |
dst.y = y1 * 50; |
| 1079 |
dst.w = 50; |
| 1080 |
dst.h = 50; |
| 1081 |
IOGFX_background->blitStretch(GFX_k[seq[se].frame[num]].k, NULL, &dst); |
| 1082 |
} |
| 1083 |
|
| 1084 |
/* if (dd != DD_OK) Msg("Error with drawing sprite! Seq %d, Spr %d.",se,frame); */ |
| 1085 |
} |
| 1086 |
} |
| 1087 |
|
| 1088 |
pass: |
| 1089 |
draw_sprite_picker_grid(); |
| 1090 |
} |
| 1091 |
|
| 1092 |
|
| 1093 |
void sp_add( void ) |
| 1094 |
{ |
| 1095 |
int j; |
| 1096 |
for (j = 1; j < 100; j++) |
| 1097 |
{ |
| 1098 |
if (cur_ed_screen.sprite[j].active == /*false*/0) |
| 1099 |
{ |
| 1100 |
|
| 1101 |
last_sprite_added = j; |
| 1102 |
//Msg("Adding sprite %d, seq %d, frame %d.",j,sp_seq,sp_frame); |
| 1103 |
cur_ed_screen.sprite[j].active = /*true*/1; |
| 1104 |
cur_ed_screen.sprite[j].frame = sp_frame; |
| 1105 |
cur_ed_screen.sprite[j].seq = sp_seq; |
| 1106 |
cur_ed_screen.sprite[j].x = spr[1].x; |
| 1107 |
cur_ed_screen.sprite[j].y = spr[1].y; |
| 1108 |
cur_ed_screen.sprite[j].size = spr[1].size; |
| 1109 |
cur_ed_screen.sprite[j].type = sp_type; |
| 1110 |
cur_ed_screen.sprite[j].brain = sp_brain; |
| 1111 |
cur_ed_screen.sprite[j].speed = sp_speed; |
| 1112 |
cur_ed_screen.sprite[j].base_walk = sp_base_walk; |
| 1113 |
cur_ed_screen.sprite[j].base_idle = sp_base_idle; |
| 1114 |
cur_ed_screen.sprite[j].base_attack = sp_base_attack; |
| 1115 |
cur_ed_screen.sprite[j].base_hit = sp_base_hit; |
| 1116 |
cur_ed_screen.sprite[j].timing = sp_timer; |
| 1117 |
cur_ed_screen.sprite[j].que = sp_que; |
| 1118 |
cur_ed_screen.sprite[j].hard = sp_hard; |
| 1119 |
cur_ed_screen.sprite[j].is_warp = sp_is_warp; |
| 1120 |
cur_ed_screen.sprite[j].warp_map = sp_warp_map; |
| 1121 |
cur_ed_screen.sprite[j].warp_x = sp_warp_x; |
| 1122 |
cur_ed_screen.sprite[j].warp_y = sp_warp_y; |
| 1123 |
cur_ed_screen.sprite[j].parm_seq = sp_parm_seq; |
| 1124 |
strcpy(cur_ed_screen.sprite[j].script, sp_script); |
| 1125 |
cur_ed_screen.sprite[j].base_die = sp_base_die; |
| 1126 |
cur_ed_screen.sprite[j].gold = sp_gold; |
| 1127 |
cur_ed_screen.sprite[j].exp = sp_exp; |
| 1128 |
cur_ed_screen.sprite[j].strength = sp_strength; |
| 1129 |
cur_ed_screen.sprite[j].defense = sp_defense; |
| 1130 |
cur_ed_screen.sprite[j].hitpoints = sp_hitpoints; |
| 1131 |
cur_ed_screen.sprite[j].sound = sp_sound; |
| 1132 |
cur_ed_screen.sprite[j].vision = map_vision; |
| 1133 |
cur_ed_screen.sprite[j].nohit = sp_nohit; |
| 1134 |
cur_ed_screen.sprite[j].touch_damage = sp_touch_damage; |
| 1135 |
rect_copy(&cur_ed_screen.sprite[j].alt , &spr[1].alt); |
| 1136 |
return; |
| 1137 |
} |
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
} |
| 1142 |
|
| 1143 |
|
| 1144 |
} |
| 1145 |
|
| 1146 |
|
| 1147 |
void smart_add(void) |
| 1148 |
{ |
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
sp_add(); |
| 1154 |
|
| 1155 |
if (sp_screenmatch) |
| 1156 |
{ |
| 1157 |
|
| 1158 |
if (spr[1].size == 100) |
| 1159 |
{ |
| 1160 |
//lets see if the sprite crosses into another screen |
| 1161 |
//use screenmatch technology |
| 1162 |
|
| 1163 |
if ((spr[1].x - k[getpic(1)].xoffset) + k[getpic(1)].box.right > 620) |
| 1164 |
{ |
| 1165 |
log_debug("need to add it to the right"); |
| 1166 |
|
| 1167 |
//need to add it to the right |
| 1168 |
if (g_dmod.map.loc[cur_map+1] > 0) |
| 1169 |
{ |
| 1170 |
editor_save_screen(g_dmod.map.loc[cur_map]); |
| 1171 |
log_debug("loading right map"); |
| 1172 |
editor_load_screen(g_dmod.map.loc[cur_map+1]); |
| 1173 |
int holdx = spr[1].x; |
| 1174 |
int holdy = spr[1].y; |
| 1175 |
spr[1].x -= 600; |
| 1176 |
sp_add(); |
| 1177 |
editor_save_screen(g_dmod.map.loc[cur_map+1]); |
| 1178 |
editor_load_screen(g_dmod.map.loc[cur_map]); |
| 1179 |
spr[1].x = holdx; |
| 1180 |
spr[1].y = holdy; |
| 1181 |
} |
| 1182 |
} |
| 1183 |
|
| 1184 |
|
| 1185 |
if ((spr[1].x - k[getpic(1)].xoffset) - k[getpic(1)].box.right < 20) |
| 1186 |
{ |
| 1187 |
log_debug("need to add it to the right"); |
| 1188 |
|
| 1189 |
//need to add it to the left |
| 1190 |
if (g_dmod.map.loc[cur_map-1] > 0) |
| 1191 |
{ |
| 1192 |
editor_save_screen(g_dmod.map.loc[cur_map]); |
| 1193 |
log_debug("loading right map"); |
| 1194 |
editor_load_screen(g_dmod.map.loc[cur_map-1]); |
| 1195 |
int holdx = spr[1].x; |
| 1196 |
int holdy = spr[1].y; |
| 1197 |
spr[1].x += 600; |
| 1198 |
sp_add(); |
| 1199 |
editor_save_screen(g_dmod.map.loc[cur_map-1]); |
| 1200 |
editor_load_screen(g_dmod.map.loc[cur_map]); |
| 1201 |
spr[1].x = holdx; |
| 1202 |
spr[1].y = holdy; |
| 1203 |
} |
| 1204 |
} |
| 1205 |
|
| 1206 |
|
| 1207 |
if ((spr[1].y - k[getpic(1)].yoffset) + k[getpic(1)].box.bottom > 400) |
| 1208 |
{ |
| 1209 |
log_debug("need to add it to the bottom"); |
| 1210 |
|
| 1211 |
//need to add it to the bottom |
| 1212 |
if (g_dmod.map.loc[cur_map+32] > 0) |
| 1213 |
{ |
| 1214 |
editor_save_screen(g_dmod.map.loc[cur_map]); |
| 1215 |
log_debug("loading bottom "); |
| 1216 |
editor_load_screen(g_dmod.map.loc[cur_map+32]); |
| 1217 |
int holdx = spr[1].x; |
| 1218 |
int holdy = spr[1].y; |
| 1219 |
spr[1].y -= 400; |
| 1220 |
sp_add(); |
| 1221 |
editor_save_screen(g_dmod.map.loc[cur_map+32]); |
| 1222 |
editor_load_screen(g_dmod.map.loc[cur_map]); |
| 1223 |
spr[1].x = holdx; |
| 1224 |
spr[1].y = holdy; |
| 1225 |
} |
| 1226 |
} |
| 1227 |
|
| 1228 |
|
| 1229 |
if ((spr[1].y - k[getpic(1)].yoffset) - k[getpic(1)].box.bottom < 0) |
| 1230 |
{ |
| 1231 |
log_debug("need to add it to the top"); |
| 1232 |
|
| 1233 |
//need to add it to the left |
| 1234 |
if (g_dmod.map.loc[cur_map-32] > 0) |
| 1235 |
{ |
| 1236 |
editor_save_screen(g_dmod.map.loc[cur_map]); |
| 1237 |
log_debug("loading top map"); |
| 1238 |
editor_load_screen(g_dmod.map.loc[cur_map-32]); |
| 1239 |
int holdx = spr[1].x; |
| 1240 |
int holdy = spr[1].y; |
| 1241 |
spr[1].y += 400; |
| 1242 |
sp_add(); |
| 1243 |
editor_save_screen(g_dmod.map.loc[cur_map-32]); |
| 1244 |
editor_load_screen(g_dmod.map.loc[cur_map]); |
| 1245 |
spr[1].x = holdx; |
| 1246 |
spr[1].y = holdy; |
| 1247 |
} |
| 1248 |
} |
| 1249 |
|
| 1250 |
} |
| 1251 |
|
| 1252 |
} |
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
} |
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
void blit(int seq1, int frame, IOGfxSurface* IOGFX_lpdest, int tx, int ty) |
| 1265 |
{ |
| 1266 |
/* RECT math; */ |
| 1267 |
|
| 1268 |
/* math = k[seq[seq1].frame[frame]].box; */ |
| 1269 |
/* OffsetRect(&math, tx, ty); */ |
| 1270 |
/* ddrval = lpdest->Blt(&math, k[seq[seq1].frame[frame]].k, &k[seq[seq1].frame[frame]].box, DDBLT_WAIT, NULL); */ |
| 1271 |
// GFX |
| 1272 |
// No scaling needed here |
| 1273 |
{ |
| 1274 |
SDL_Rect dst; |
| 1275 |
dst.x = tx; |
| 1276 |
dst.y = ty; |
| 1277 |
IOGFX_lpdest->blit(GFX_k[seq[seq1].frame[frame]].k, NULL, &dst); |
| 1278 |
} |
| 1279 |
} |
| 1280 |
|
| 1281 |
|
| 1282 |
/** |
| 1283 |
* Display the appropriate input dialog |
| 1284 |
*/ |
| 1285 |
void check_in(void) |
| 1286 |
{ |
| 1287 |
in_huh = in_master; |
| 1288 |
|
| 1289 |
/** |
| 1290 |
* - Sprite dialogs: |
| 1291 |
* 1 = size |
| 1292 |
* 2 = type (background|sprite) |
| 1293 |
* 3 = brain |
| 1294 |
* 4 = speed |
| 1295 |
* 5 = timer (timing) |
| 1296 |
* 6 = base_walk |
| 1297 |
* 7 = base_idle |
| 1298 |
* 8 = que |
| 1299 |
* 9 = hard (hardness_type - background|sprite) |
| 1300 |
* 10 = is_warp |
| 1301 |
* 11 = warp_map |
| 1302 |
* 12 = warp_x |
| 1303 |
* 13 = warp_y |
| 1304 |
* 14 = parm_seq |
| 1305 |
* 15 = script |
| 1306 |
* 16 = base_die |
| 1307 |
* 17 = sound (looping sound) |
| 1308 |
* 18 = hitpoints |
| 1309 |
* 19 = nohit |
| 1310 |
* 20 = touch_damage |
| 1311 |
* 21 = base_attack |
| 1312 |
* 22 = defense |
| 1313 |
* |
| 1314 |
* - Minimap dialogs: |
| 1315 |
* 30 = 'L' - load screen from another map |
| 1316 |
* |
| 1317 |
* - Screen dialogs: |
| 1318 |
* (called from minimap or screen mode) |
| 1319 |
* 31 = 'B' - screen script |
| 1320 |
* 32 = 'V' - vision |
| 1321 |
* (called from minimap mod) |
| 1322 |
* 33 = 'M' - screen midi |
| 1323 |
* 34 = 'S' - screen type (indoors / outside) |
| 1324 |
**/ |
| 1325 |
|
| 1326 |
/* In: */ |
| 1327 |
/* in_master = identifier for the property we need to edit */ |
| 1328 |
/* Out: */ |
| 1329 |
/* in_max = maximum length of input (as text) + 1 */ |
| 1330 |
/* in_command = data type (int|string) */ |
| 1331 |
/* in_int = pointer to the integer value to update */ |
| 1332 |
/* in_string = pointer to the string to update */ |
| 1333 |
/* in_onflag = trigger the creation of an input window */ |
| 1334 |
/* in_enabled = text box input mode */ |
| 1335 |
|
| 1336 |
if (in_master == 1) |
| 1337 |
{ |
| 1338 |
in_command = 1; //number |
| 1339 |
in_int = &spr[1].size; |
| 1340 |
in_max = 10; //max _length |
| 1341 |
sprintf(in_default,"%d",spr[1].size); //set default |
| 1342 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1343 |
Say("New Size?",260,175); |
| 1344 |
} |
| 1345 |
|
| 1346 |
if (in_master == 2) |
| 1347 |
{ |
| 1348 |
in_command = 1; //number |
| 1349 |
in_int = &sp_type; |
| 1350 |
in_max = 10; //max _length |
| 1351 |
sprintf(in_default,"%d",sp_type); //set default |
| 1352 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1353 |
Say("New Type?",260,175); |
| 1354 |
Say("Type controls the sprite's basic type - 0 means it is ornamental only" |
| 1355 |
"(cannot walk behind or think) 1 - means normal sprite. (for a tree or person)" |
| 1356 |
,10,10); |
| 1357 |
} |
| 1358 |
|
| 1359 |
if (in_master == 3) |
| 1360 |
{ |
| 1361 |
in_command = 1; //number |
| 1362 |
in_int = &sp_brain; |
| 1363 |
in_max = 10; //max _length |
| 1364 |
sprintf(in_default,"%d",sp_brain); //set default |
| 1365 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1366 |
Say("New Brain?",260,175); |
| 1367 |
Say("Brains are a predefined way for this sprite to behave. 0 = No movement, 1 = Dink," |
| 1368 |
" 2 = Dumb Sprite Bouncer, 3 = Duck, 4 = Pig, 6 = repeat, 7 = one loop then kill," |
| 1369 |
" 9 = monster (all diag), 10 = monster(no diag)" |
| 1370 |
,10,10); |
| 1371 |
} |
| 1372 |
|
| 1373 |
if (in_master == 4) |
| 1374 |
{ |
| 1375 |
in_command = 1; //number |
| 1376 |
in_int = &sp_speed; |
| 1377 |
in_max = 10; //max _length |
| 1378 |
sprintf(in_default,"%d",sp_speed); //set default |
| 1379 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1380 |
Say("New Speed?",260,175); |
| 1381 |
Say("Speed rating allows you to adjust how fast a certain sprite moves. Works with" |
| 1382 |
" most brains." |
| 1383 |
,10,10); |
| 1384 |
} |
| 1385 |
|
| 1386 |
if (in_master == 5) |
| 1387 |
{ |
| 1388 |
in_command = 1; //number |
| 1389 |
in_int = &sp_timer; |
| 1390 |
in_max = 10; //max _length |
| 1391 |
sprintf(in_default,"%d",sp_timer); //set default |
| 1392 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1393 |
Say("New Timing?",260,175); |
| 1394 |
Say("This is the delay the CPU waits before processing the sprite after each cycle. " |
| 1395 |
"(in thousands of a second - so 33 would mean 30 times a second)" |
| 1396 |
,10,10); |
| 1397 |
} |
| 1398 |
|
| 1399 |
if (in_master == 6) |
| 1400 |
{ |
| 1401 |
in_command = 1; //number |
| 1402 |
in_int = &sp_base_walk; |
| 1403 |
in_max = 10; //max _length |
| 1404 |
sprintf(in_default,"%d",sp_base_walk); //set default |
| 1405 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1406 |
Say("New Base Walk?",260,175); |
| 1407 |
Say("The base for which the CPU adds 1 through 9 to make the sprite move, depending on" |
| 1408 |
" direction. Must be a multiple of ten. (ie, 20 to look like a duck, 40 to look like a pig)" |
| 1409 |
,10,10); |
| 1410 |
} |
| 1411 |
|
| 1412 |
if (in_master == 7) |
| 1413 |
{ |
| 1414 |
in_command = 1; //number |
| 1415 |
in_int = &sp_base_idle; |
| 1416 |
in_max = 10; //max _length |
| 1417 |
sprintf(in_default,"%d",sp_base_idle); //set default |
| 1418 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1419 |
Say("New Base Idle?",260,175); |
| 1420 |
Say("Some brains can optionally use extra sprites for their \'idle\' pose." |
| 1421 |
,10,10); |
| 1422 |
} |
| 1423 |
|
| 1424 |
if (in_master == 8) |
| 1425 |
{ |
| 1426 |
in_command = 1; //number |
| 1427 |
in_int = &sp_que; |
| 1428 |
in_max = 10; //max _length |
| 1429 |
sprintf(in_default,"%d",sp_que); //set default |
| 1430 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1431 |
Say("New Depth Que?",250,175); |
| 1432 |
Say("From 1 to 20000, 0 for default. (defaults to y cord)" |
| 1433 |
,10,10); |
| 1434 |
} |
| 1435 |
|
| 1436 |
if (in_master == 9) |
| 1437 |
{ |
| 1438 |
in_command = 1; //number |
| 1439 |
in_int = &sp_hard; |
| 1440 |
in_max = 10; //max _length |
| 1441 |
sprintf(in_default,"%d",sp_hard); //set default |
| 1442 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1443 |
Say("New Hardness?",260,175); |
| 1444 |
Say("Sets how hardness works. 1 means normal, (monsters) 0 means added to background. (walls, trees)" |
| 1445 |
,10,10); |
| 1446 |
} |
| 1447 |
|
| 1448 |
if (in_master == 10) |
| 1449 |
{ |
| 1450 |
in_command = 1; //number |
| 1451 |
in_int = &sp_is_warp; |
| 1452 |
in_max = 10; //max _length |
| 1453 |
sprintf(in_default,"%d",sp_is_warp); //set default |
| 1454 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1455 |
Say("New Properties?",260,175); |
| 1456 |
Say("Sets special properties for the hardblock. 0 = normal (just hard) 1 = warp." |
| 1457 |
,10,10); |
| 1458 |
} |
| 1459 |
|
| 1460 |
if (in_master == 11) |
| 1461 |
{ |
| 1462 |
in_command = 1; //number |
| 1463 |
in_int = &sp_warp_map; |
| 1464 |
in_max = 10; //max _length |
| 1465 |
sprintf(in_default,"%d",sp_warp_map); //set default |
| 1466 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1467 |
Say("Warp Map #",260,175); |
| 1468 |
Say("These parms are valid if the hard block property setting is 1. (warp)" |
| 1469 |
,10,10); |
| 1470 |
} |
| 1471 |
|
| 1472 |
if (in_master == 12) |
| 1473 |
{ |
| 1474 |
in_command = 1; //number |
| 1475 |
in_int = &sp_warp_x; |
| 1476 |
in_max = 10; //max _length |
| 1477 |
sprintf(in_default,"%d",sp_warp_x); //set default |
| 1478 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1479 |
Say("Warp X:",260,175); |
| 1480 |
Say("The X location to warp to. (20 to 619)" |
| 1481 |
,10,10); |
| 1482 |
} |
| 1483 |
|
| 1484 |
if (in_master == 13) |
| 1485 |
{ |
| 1486 |
in_command = 1; //number |
| 1487 |
in_int = &sp_warp_y; |
| 1488 |
in_max = 10; //max _length |
| 1489 |
sprintf(in_default,"%d",sp_warp_y); //set default |
| 1490 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1491 |
Say("Warp Y:",260,175); |
| 1492 |
Say("The Y location to warp to. (0 to 499)" |
| 1493 |
,10,10); |
| 1494 |
} |
| 1495 |
|
| 1496 |
if (in_master == 14) |
| 1497 |
{ |
| 1498 |
in_command = 1; //number |
| 1499 |
in_int = &sp_parm_seq; |
| 1500 |
in_max = 10; //max _length |
| 1501 |
sprintf(in_default,"%d",sp_parm_seq); //set default |
| 1502 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1503 |
Say("Sequence:",260,175); |
| 1504 |
Say("This parm is used by some brains/settings if set. A sequence is an animation #." |
| 1505 |
,10,10); |
| 1506 |
} |
| 1507 |
|
| 1508 |
if (in_master == 15) |
| 1509 |
{ |
| 1510 |
in_command = 2; //string |
| 1511 |
sprintf(in_default, "%s", sp_script); |
| 1512 |
in_max = 13; |
| 1513 |
in_string = sp_script; |
| 1514 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1515 |
Say("Script:",260,175); |
| 1516 |
Say("Filename of script this sprite uses." |
| 1517 |
,10,10); |
| 1518 |
} |
| 1519 |
|
| 1520 |
if (in_master == 16) |
| 1521 |
{ |
| 1522 |
in_command = 1; //number |
| 1523 |
in_int = &sp_base_die; |
| 1524 |
in_max = 10; //max _length |
| 1525 |
sprintf(in_default,"%d",sp_base_die); //set default |
| 1526 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1527 |
Say("Base Death:",260,175); |
| 1528 |
Say("If this sprite dies, this will be used." |
| 1529 |
,10,10); |
| 1530 |
} |
| 1531 |
|
| 1532 |
if (in_master == 17) |
| 1533 |
{ |
| 1534 |
in_command = 1; //number |
| 1535 |
in_int = &sp_sound; |
| 1536 |
in_max = 10; //max _length |
| 1537 |
sprintf(in_default,"%d",sp_sound); //set default |
| 1538 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1539 |
Say("Sound:",260,175); |
| 1540 |
Say("This sprite will play this sound looped until it dies." |
| 1541 |
,10,10); |
| 1542 |
} |
| 1543 |
|
| 1544 |
if (in_master == 18) |
| 1545 |
{ |
| 1546 |
in_command = 1; //number |
| 1547 |
in_int = &sp_hitpoints; |
| 1548 |
in_max = 10; //max _length |
| 1549 |
sprintf(in_default,"%d",sp_hitpoints); //set default |
| 1550 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1551 |
Say("Hitpoints:",260,175); |
| 1552 |
Say("How strong is this creature? (0 = not alive/invincible)" |
| 1553 |
,10,10); |
| 1554 |
} |
| 1555 |
|
| 1556 |
if (in_master == 19) |
| 1557 |
{ |
| 1558 |
in_command = 1; //number |
| 1559 |
in_int = &sp_nohit; |
| 1560 |
in_max = 10; //max _length |
| 1561 |
sprintf(in_default,"%d",sp_nohit); //set default |
| 1562 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1563 |
Say("Nohit:",260,175); |
| 1564 |
Say("Can this be punched? 0 if yes. Either way it will" |
| 1565 |
"still check for hit() if a script is attached." |
| 1566 |
,10,10); |
| 1567 |
} |
| 1568 |
|
| 1569 |
if (in_master == 20) |
| 1570 |
{ |
| 1571 |
in_command = 1; //number |
| 1572 |
in_int = &sp_touch_damage; |
| 1573 |
in_max = 10; //max _length |
| 1574 |
sprintf(in_default,"%d",sp_touch_damage); //set default |
| 1575 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1576 |
Say("Touch Damage:",260,175); |
| 1577 |
Say("If not 0, the hardbox of this sprite will cause this" |
| 1578 |
"much damage if touched." |
| 1579 |
,10,10); |
| 1580 |
} |
| 1581 |
|
| 1582 |
if (in_master == 21) |
| 1583 |
{ |
| 1584 |
in_command = 1; //number |
| 1585 |
in_int = &sp_base_attack; |
| 1586 |
in_max = 10; //max _length |
| 1587 |
sprintf(in_default,"%d",sp_base_attack); //set default |
| 1588 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1589 |
Say("Base Attack:",260,175); |
| 1590 |
Say("If not -1, this monster can attack with this sprite base. (base + dir)" |
| 1591 |
,10,10); |
| 1592 |
} |
| 1593 |
|
| 1594 |
if (in_master == 22) |
| 1595 |
{ |
| 1596 |
in_command = 1; //number |
| 1597 |
in_int = &sp_defense; |
| 1598 |
in_max = 10; //max _length |
| 1599 |
sprintf(in_default,"%d",sp_defense); //set default |
| 1600 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1601 |
Say("Defense:",260,175); |
| 1602 |
Say("This will be deducted from any attack." |
| 1603 |
,10,10); |
| 1604 |
} |
| 1605 |
|
| 1606 |
if (in_master == INPUT_MINIMAP_LOAD) |
| 1607 |
{ |
| 1608 |
in_command = 2; //string |
| 1609 |
sprintf(in_default, "%s", buf_path); |
| 1610 |
in_max = 80; |
| 1611 |
in_string = buf_path; |
| 1612 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1613 |
Say("Path:",260,175); |
| 1614 |
Say("Enter the path with trailing backslash to a dir containing" |
| 1615 |
" another dink.dat and map.dat file to choose a replacement" |
| 1616 |
" for this block. (or enter to choose a replacement from the" |
| 1617 |
" current map)" |
| 1618 |
,10,10); |
| 1619 |
} |
| 1620 |
|
| 1621 |
if (in_master == 31) |
| 1622 |
{ |
| 1623 |
in_command = 2; //string |
| 1624 |
sprintf(in_default, "%s", cur_ed_screen.script); |
| 1625 |
in_max = 20; |
| 1626 |
in_string = cur_ed_screen.script; |
| 1627 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1628 |
Say("Script:",260,175); |
| 1629 |
Say("This script will be run before the screen is drawn. A good place" |
| 1630 |
"to change the vision, ect." |
| 1631 |
,10,10); |
| 1632 |
} |
| 1633 |
|
| 1634 |
if (in_master == INPUT_SCREEN_VISION) |
| 1635 |
{ |
| 1636 |
in_command = 1; //number |
| 1637 |
in_int = &map_vision; |
| 1638 |
in_max = 10; //max _length |
| 1639 |
sprintf(in_default,"%d",map_vision); //set default |
| 1640 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1641 |
Say("Vision:",260,175); |
| 1642 |
Say("Current vision. If not 0, any sprites you add will ONLY show up" |
| 1643 |
" in the game if the vision level matches this one." |
| 1644 |
,10,10); |
| 1645 |
} |
| 1646 |
|
| 1647 |
if (in_master == INPUT_SCREEN_MIDI) |
| 1648 |
{ |
| 1649 |
in_command = 1; //number |
| 1650 |
in_max = 10; //max _length |
| 1651 |
sprintf(in_default,"%d",*in_int); //set default |
| 1652 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1653 |
Say("Music # for screen?:",260,175); |
| 1654 |
Say("Will play #.MID for this screen if nothing else is playing." |
| 1655 |
,10,10); |
| 1656 |
} |
| 1657 |
|
| 1658 |
if (in_master == INPUT_SCREEN_TYPE) |
| 1659 |
{ |
| 1660 |
in_command = 1; //number |
| 1661 |
in_max = 10; //max _length |
| 1662 |
sprintf(in_default,"%d",*in_int); //set default |
| 1663 |
blit(30,1,IOGFX_backbuffer,250,170); |
| 1664 |
Say("Screentype?:",260,175); |
| 1665 |
Say("Enter 1 for 'indoors'. (so it won't show up on the player map)." |
| 1666 |
,10,10); |
| 1667 |
} |
| 1668 |
|
| 1669 |
old_command = in_master; |
| 1670 |
|
| 1671 |
in_master = 0; |
| 1672 |
in_onflag = /*true*/1; |
| 1673 |
} |
| 1674 |
|
| 1675 |
|
| 1676 |
//this changes all none 0 blocks in this tile to num |
| 1677 |
void change_tile(int tile, int num) |
| 1678 |
{ |
| 1679 |
int x; |
| 1680 |
for (x = 0; x < 50; x++) |
| 1681 |
{ |
| 1682 |
int y; |
| 1683 |
for (y = 0; y < 50; y++) |
| 1684 |
if (hmap.htile[tile].hm[x][y] != 0) |
| 1685 |
hmap.htile[tile].hm[x][y] = num; |
| 1686 |
} |
| 1687 |
} |
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
void copy_front_to_two( void) |
| 1692 |
{ |
| 1693 |
IOGFX_background->blit(IOGFX_backbuffer, NULL, NULL); |
| 1694 |
} |
| 1695 |
|
| 1696 |
|
| 1697 |
/* Create a 20x20 view of lpDDSTwo for use in the minimap */ |
| 1698 |
void shrink_screen_to_these_cords(int x1, int y1) |
| 1699 |
{ |
| 1700 |
/* RECT crapRec, Rect; */ |
| 1701 |
/* DDBLTFX ddbltfx; */ |
| 1702 |
/* ZeroMemory(&ddbltfx, sizeof(ddbltfx)); */ |
| 1703 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 1704 |
|
| 1705 |
/* SetRect(&crapRec, playl, 0, playx, 400); */ |
| 1706 |
/* SetRect(&Rect, x1, y1, x1+20, y1+20); */ |
| 1707 |
|
| 1708 |
/* lpDDSBack->Blt(&Rect, lpDDSTwo, */ |
| 1709 |
/* &crapRec, DDBLT_DDFX | DDBLT_WAIT, &ddbltfx); */ |
| 1710 |
|
| 1711 |
// GFX |
| 1712 |
/* Generic scaling - except no transparency */ |
| 1713 |
{ |
| 1714 |
SDL_Rect src, dst; |
| 1715 |
src.x = playl; |
| 1716 |
src.y = 0; |
| 1717 |
src.w = playx - playl; |
| 1718 |
src.h = 400; |
| 1719 |
dst.x = x1; |
| 1720 |
dst.y = y1; |
| 1721 |
dst.w = 20; |
| 1722 |
dst.h = 20; |
| 1723 |
IOGFX_backbuffer->blitStretch(IOGFX_background, &src, &dst); |
| 1724 |
} |
| 1725 |
} |
| 1726 |
|
| 1727 |
|
| 1728 |
/** |
| 1729 |
* So-called "Movie2000 sprite movie maker" feature. It will dump a |
| 1730 |
* series of DinkC moves that you specify using the mouse |
| 1731 |
* (destination) and the numpad (direction). Check |
| 1732 |
* http://www.dinknetwork.com/file/movie2000_tutorial |
| 1733 |
*/ |
| 1734 |
void write_moves(void) |
| 1735 |
{ |
| 1736 |
char crap[100+6+2]; |
| 1737 |
char move[100]; |
| 1738 |
char fname[100]; |
| 1739 |
|
| 1740 |
strcpy(fname, sp_script); |
| 1741 |
if (strlen(sp_script) <= 2) |
| 1742 |
strcpy(fname, "CRAP"); |
| 1743 |
|
| 1744 |
|
| 1745 |
if (input_getscancodejustpressed(SDL_SCANCODE_KP_8)) |
| 1746 |
{ |
| 1747 |
EditorSoundPlayEffect( SOUND_JUMP ); |
| 1748 |
sprintf(crap, "story/%s.c",fname); |
| 1749 |
sprintf(move, "move_stop(¤t_sprite, 8, %d, 1)\n", spr[1].y); |
| 1750 |
add_text(move, crap); |
| 1751 |
} |
| 1752 |
if (input_getscancodejustpressed(SDL_SCANCODE_KP_4)) |
| 1753 |
{ |
| 1754 |
EditorSoundPlayEffect( SOUND_JUMP ); |
| 1755 |
sprintf(crap, "story/%s.c",fname); |
| 1756 |
sprintf(move, "move_stop(¤t_sprite, 4, %d, 1)\n", spr[1].x); |
| 1757 |
add_text(move, crap); |
| 1758 |
} |
| 1759 |
if (input_getscancodejustpressed(SDL_SCANCODE_KP_5)) |
| 1760 |
{ |
| 1761 |
EditorSoundPlayEffect(SOUND_JUMP); |
| 1762 |
sprintf(crap, "story/%s.c",fname); |
| 1763 |
add_text("//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n", crap); |
| 1764 |
} |
| 1765 |
if (input_getscancodejustpressed(SDL_SCANCODE_KP_2)) |
| 1766 |
{ |
| 1767 |
EditorSoundPlayEffect(SOUND_JUMP); |
| 1768 |
sprintf(crap, "story/%s.c", fname); |
| 1769 |
sprintf(move, "move_stop(¤t_sprite, 2, %d, 1)\n", spr[1].y); |
| 1770 |
add_text(move, crap); |
| 1771 |
} |
| 1772 |
if (input_getscancodejustpressed(SDL_SCANCODE_KP_6)) |
| 1773 |
{ |
| 1774 |
EditorSoundPlayEffect( SOUND_JUMP ); |
| 1775 |
sprintf(crap, "story/%s.c",fname); |
| 1776 |
sprintf(move, "move_stop(¤t_sprite, 6, %d, 1)\n", spr[1].x); |
| 1777 |
add_text(move, crap); |
| 1778 |
} |
| 1779 |
if (input_getscancodejustpressed(SDL_SCANCODE_KP_7)) |
| 1780 |
{ |
| 1781 |
EditorSoundPlayEffect( SOUND_JUMP ); |
| 1782 |
sprintf(crap, "story/%s.c",fname); |
| 1783 |
sprintf(move, "move_stop(¤t_sprite, 7, %d, 1)\n", spr[1].x); |
| 1784 |
add_text(move, crap); |
| 1785 |
} |
| 1786 |
if (input_getscancodejustpressed(SDL_SCANCODE_KP_1)) |
| 1787 |
{ |
| 1788 |
EditorSoundPlayEffect( SOUND_JUMP ); |
| 1789 |
sprintf(crap, "story/%s.c",fname); |
| 1790 |
sprintf(move, "move_stop(¤t_sprite, 1, %d, 1)\n", spr[1].x); |
| 1791 |
add_text(move, crap); |
| 1792 |
} |
| 1793 |
if (input_getscancodejustpressed(SDL_SCANCODE_KP_9)) |
| 1794 |
{ |
| 1795 |
EditorSoundPlayEffect( SOUND_JUMP ); |
| 1796 |
sprintf(crap, "story/%s.c",fname); |
| 1797 |
sprintf(move, "move_stop(¤t_sprite, 9, %d, 1)\n", spr[1].x); |
| 1798 |
add_text(move, crap); |
| 1799 |
} |
| 1800 |
if (input_getscancodejustpressed(SDL_SCANCODE_KP_3)) |
| 1801 |
{ |
| 1802 |
EditorSoundPlayEffect( SOUND_JUMP ); |
| 1803 |
sprintf(crap, "story/%s.c",fname); |
| 1804 |
sprintf(move, "move_stop(¤t_sprite, 3, %d, 1)\n", spr[1].x); |
| 1805 |
add_text(move, crap); |
| 1806 |
} |
| 1807 |
} |
| 1808 |
|
| 1809 |
|
| 1810 |
/** |
| 1811 |
* Draw hardness single tile #'tile', pixel by pixel, in white. Used |
| 1812 |
* to draw the currently selected hardness tile. |
| 1813 |
*/ |
| 1814 |
void draw_hard_tile(int x1, int y1, int tile) |
| 1815 |
{ |
| 1816 |
SDL_Rect dst; |
| 1817 |
dst.w = 1; |
| 1818 |
dst.h = 1; |
| 1819 |
|
| 1820 |
int x = 0; |
| 1821 |
for (x = 0; x < 50; x++) |
| 1822 |
{ |
| 1823 |
int y = 0; |
| 1824 |
for (y = 0; y < 50; y++) |
| 1825 |
{ |
| 1826 |
if (hmap.htile[tile].hm[x][y] == 1) |
| 1827 |
{ |
| 1828 |
//draw it |
| 1829 |
dst.x = x1 + x |
| 1830 |
+ 20/* status bar length */; |
| 1831 |
dst.y = y1 + y; |
| 1832 |
/* TODO: not very efficient */ |
| 1833 |
IOGFX_backbuffer->fillRect(&dst, 255,255,255); |
| 1834 |
} |
| 1835 |
} |
| 1836 |
} |
| 1837 |
} |
| 1838 |
|
| 1839 |
/** |
| 1840 |
* Move out brain==1 here |
| 1841 |
* Return: |
| 1842 |
* 0 : continue |
| 1843 |
* 1 : goto skip_draw |
| 1844 |
* 2 : return from ::logic() |
| 1845 |
*/ |
| 1846 |
int gui_logic(int h) { |
| 1847 |
rect box_crap,box_real; |
| 1848 |
int holdx; |
| 1849 |
int xx; |
| 1850 |
/*BOOL*/int cool; |
| 1851 |
rect Rect; |
| 1852 |
|
| 1853 |
if ((spr[h].seq == 0) || (g_editorMode == EDITOR_MODE_TILE_HARDNESS)) { |
| 1854 |
//if (mode == 7) |
| 1855 |
if (g_editorMode == EDITOR_MODE_SPRITE_HARDNESS) { |
| 1856 |
//editing a sprite, setting hard box and depth dot. |
| 1857 |
spr[1].pseq = 1; |
| 1858 |
spr[1].pframe = 1; |
| 1859 |
|
| 1860 |
if (sjoy.button[EDITOR_ACTION_ESCAPE]) { |
| 1861 |
//they want out |
| 1862 |
//mode = 5; |
| 1863 |
g_editorMode = EDITOR_MODE_SPRITE_PICKER; |
| 1864 |
draw96(0); |
| 1865 |
spr[1].x = m5x; |
| 1866 |
spr[1].y = m5y; |
| 1867 |
spr[1].pseq = 10; |
| 1868 |
spr[1].pframe = 5; |
| 1869 |
spr[1].speed = 50; |
| 1870 |
goto sp_edit_end; |
| 1871 |
|
| 1872 |
} |
| 1873 |
|
| 1874 |
if (input_getscancodejustpressed(SDL_SCANCODE_TAB)) { |
| 1875 |
|
| 1876 |
//they hit tab, lets toggle what mode they are in |
| 1877 |
if (sp_mode == 0) sp_mode = 1; else if (sp_mode == 1) sp_mode = 2; else if (sp_mode == 2) sp_mode = 0; |
| 1878 |
|
| 1879 |
|
| 1880 |
} |
| 1881 |
if (input_getcharjustpressed(SDLK_s)) { |
| 1882 |
|
| 1883 |
//they hit tab, lets toggle what mode they are in |
| 1884 |
char death[150]; |
| 1885 |
char filename[10]; |
| 1886 |
|
| 1887 |
sprintf(death, "SET_SPRITE_INFO %d %d %d %d %d %d %d %d\n", |
| 1888 |
sp_seq,sp_frame, k[seq[sp_seq].frame[sp_frame]].xoffset, k[seq[sp_seq].frame[sp_frame]].yoffset, |
| 1889 |
|
| 1890 |
k[seq[sp_seq].frame[sp_frame]].hardbox.left, k[seq[sp_seq].frame[sp_frame]].hardbox.top, |
| 1891 |
k[seq[sp_seq].frame[sp_frame]].hardbox.right,k[seq[sp_seq].frame[sp_frame]].hardbox.bottom); |
| 1892 |
|
| 1893 |
strcpy(filename, "dink.ini"); |
| 1894 |
add_text(death,filename); |
| 1895 |
EditorSoundPlayEffect( SOUND_JUMP ); |
| 1896 |
} |
| 1897 |
|
| 1898 |
|
| 1899 |
int modif = 1; |
| 1900 |
if (SDL_GetModState()&KMOD_SHIFT) |
| 1901 |
modif += 9; |
| 1902 |
|
| 1903 |
|
| 1904 |
if (sp_mode == 0) { |
| 1905 |
|
| 1906 |
//ok, we are editing depth dot |
| 1907 |
|
| 1908 |
if (SDL_GetModState()&KMOD_CTRL) { |
| 1909 |
if (input_getscancodejustpressed(SDL_SCANCODE_RIGHT)) { |
| 1910 |
k[seq[sp_seq].frame[sp_frame]].xoffset += modif; |
| 1911 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1912 |
} |
| 1913 |
|
| 1914 |
if (input_getscancodejustpressed(SDL_SCANCODE_LEFT)) { |
| 1915 |
|
| 1916 |
k[seq[sp_seq].frame[sp_frame]].xoffset -= modif; |
| 1917 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1918 |
} |
| 1919 |
if (input_getscancodejustpressed(SDL_SCANCODE_UP)) { |
| 1920 |
k[seq[sp_seq].frame[sp_frame]].yoffset -= modif; |
| 1921 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1922 |
} |
| 1923 |
|
| 1924 |
if (input_getscancodejustpressed(SDL_SCANCODE_DOWN)) { |
| 1925 |
k[seq[sp_seq].frame[sp_frame]].yoffset += modif; |
| 1926 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1927 |
} |
| 1928 |
|
| 1929 |
} else { |
| 1930 |
if (sjoy.right) { |
| 1931 |
k[seq[sp_seq].frame[sp_frame]].xoffset += modif; |
| 1932 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1933 |
} |
| 1934 |
|
| 1935 |
if (sjoy.left) { |
| 1936 |
k[seq[sp_seq].frame[sp_frame]].xoffset -= modif; |
| 1937 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1938 |
} |
| 1939 |
if (sjoy.up) { |
| 1940 |
k[seq[sp_seq].frame[sp_frame]].yoffset -= modif; |
| 1941 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1942 |
} |
| 1943 |
|
| 1944 |
if (sjoy.down) { |
| 1945 |
k[seq[sp_seq].frame[sp_frame]].yoffset += modif; |
| 1946 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1947 |
} |
| 1948 |
|
| 1949 |
|
| 1950 |
} |
| 1951 |
|
| 1952 |
} |
| 1953 |
|
| 1954 |
|
| 1955 |
|
| 1956 |
if (sp_mode == 2) { |
| 1957 |
|
| 1958 |
//ok, we are top left hardness |
| 1959 |
|
| 1960 |
if (SDL_GetModState()&KMOD_CTRL) { |
| 1961 |
if (input_getscancodejustpressed(SDL_SCANCODE_RIGHT)) { |
| 1962 |
k[seq[sp_seq].frame[sp_frame]].hardbox.right += modif; |
| 1963 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1964 |
} |
| 1965 |
|
| 1966 |
if (input_getscancodejustpressed(SDL_SCANCODE_LEFT)) { |
| 1967 |
|
| 1968 |
k[seq[sp_seq].frame[sp_frame]].hardbox.right -= modif; |
| 1969 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1970 |
} |
| 1971 |
if (input_getscancodejustpressed(SDL_SCANCODE_UP)) { |
| 1972 |
k[seq[sp_seq].frame[sp_frame]].hardbox.bottom -= modif; |
| 1973 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1974 |
} |
| 1975 |
|
| 1976 |
if (input_getscancodejustpressed(SDL_SCANCODE_DOWN)) { |
| 1977 |
k[seq[sp_seq].frame[sp_frame]].hardbox.bottom += modif; |
| 1978 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1979 |
} |
| 1980 |
|
| 1981 |
} else { |
| 1982 |
if (sjoy.right) { |
| 1983 |
k[seq[sp_seq].frame[sp_frame]].hardbox.right += modif; |
| 1984 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1985 |
} |
| 1986 |
|
| 1987 |
if (sjoy.left) { |
| 1988 |
k[seq[sp_seq].frame[sp_frame]].hardbox.right -= modif; |
| 1989 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1990 |
} |
| 1991 |
if (sjoy.up) { |
| 1992 |
k[seq[sp_seq].frame[sp_frame]].hardbox.bottom -= modif; |
| 1993 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1994 |
} |
| 1995 |
|
| 1996 |
if (sjoy.down) { |
| 1997 |
k[seq[sp_seq].frame[sp_frame]].hardbox.bottom += modif; |
| 1998 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 1999 |
} |
| 2000 |
|
| 2001 |
|
| 2002 |
} |
| 2003 |
|
| 2004 |
|
| 2005 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.right <= k[seq[sp_seq].frame[sp_frame]].hardbox.left) |
| 2006 |
k[seq[sp_seq].frame[sp_frame]].hardbox.left = k[seq[sp_seq].frame[sp_frame]].hardbox.right -1; |
| 2007 |
|
| 2008 |
|
| 2009 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.bottom <= k[seq[sp_seq].frame[sp_frame]].hardbox.top) |
| 2010 |
k[seq[sp_seq].frame[sp_frame]].hardbox.top = k[seq[sp_seq].frame[sp_frame]].hardbox.bottom -1; |
| 2011 |
|
| 2012 |
|
| 2013 |
} |
| 2014 |
|
| 2015 |
|
| 2016 |
if (sp_mode == 1) { |
| 2017 |
|
| 2018 |
//ok, we are top left hardness |
| 2019 |
|
| 2020 |
if (SDL_GetModState()&KMOD_CTRL) { |
| 2021 |
if (input_getscancodejustpressed(SDL_SCANCODE_RIGHT)) { |
| 2022 |
k[seq[sp_seq].frame[sp_frame]].hardbox.left += modif; |
| 2023 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2024 |
} |
| 2025 |
|
| 2026 |
if (input_getscancodejustpressed(SDL_SCANCODE_LEFT)) { |
| 2027 |
|
| 2028 |
k[seq[sp_seq].frame[sp_frame]].hardbox.left -= modif; |
| 2029 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2030 |
} |
| 2031 |
if (input_getscancodejustpressed(SDL_SCANCODE_UP)) { |
| 2032 |
k[seq[sp_seq].frame[sp_frame]].hardbox.top -= modif; |
| 2033 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2034 |
} |
| 2035 |
|
| 2036 |
if (input_getscancodejustpressed(SDL_SCANCODE_DOWN)) { |
| 2037 |
k[seq[sp_seq].frame[sp_frame]].hardbox.top += modif; |
| 2038 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2039 |
} |
| 2040 |
|
| 2041 |
} else { |
| 2042 |
if (sjoy.right) { |
| 2043 |
k[seq[sp_seq].frame[sp_frame]].hardbox.left += modif; |
| 2044 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2045 |
} |
| 2046 |
|
| 2047 |
if (sjoy.left) { |
| 2048 |
k[seq[sp_seq].frame[sp_frame]].hardbox.left -= modif; |
| 2049 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2050 |
} |
| 2051 |
if (sjoy.up) { |
| 2052 |
k[seq[sp_seq].frame[sp_frame]].hardbox.top -= modif; |
| 2053 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2054 |
} |
| 2055 |
|
| 2056 |
if (sjoy.down) { |
| 2057 |
k[seq[sp_seq].frame[sp_frame]].hardbox.top += modif; |
| 2058 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2059 |
} |
| 2060 |
|
| 2061 |
|
| 2062 |
} |
| 2063 |
|
| 2064 |
|
| 2065 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.left >= k[seq[sp_seq].frame[sp_frame]].hardbox.right) |
| 2066 |
k[seq[sp_seq].frame[sp_frame]].hardbox.right = k[seq[sp_seq].frame[sp_frame]].hardbox.left +1; |
| 2067 |
|
| 2068 |
|
| 2069 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.top >= k[seq[sp_seq].frame[sp_frame]].hardbox.bottom) |
| 2070 |
k[seq[sp_seq].frame[sp_frame]].hardbox.bottom = k[seq[sp_seq].frame[sp_frame]].hardbox.bottom +1; |
| 2071 |
|
| 2072 |
|
| 2073 |
|
| 2074 |
|
| 2075 |
} |
| 2076 |
|
| 2077 |
|
| 2078 |
|
| 2079 |
|
| 2080 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.top > 200 ) k[seq[sp_seq].frame[sp_frame]].hardbox.top = 200; |
| 2081 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.top <-200 ) k[seq[sp_seq].frame[sp_frame]].hardbox.top = -200; |
| 2082 |
|
| 2083 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.left > 316) k[seq[sp_seq].frame[sp_frame]].hardbox.left = 316; |
| 2084 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.left < -320) k[seq[sp_seq].frame[sp_frame]].hardbox.left = -320; |
| 2085 |
|
| 2086 |
|
| 2087 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.bottom > 200) k[seq[sp_seq].frame[sp_frame]].hardbox.bottom = 200; |
| 2088 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.bottom <-200 ) k[seq[sp_seq].frame[sp_frame]].hardbox.bottom = -200; |
| 2089 |
|
| 2090 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.right > 316) k[seq[sp_seq].frame[sp_frame]].hardbox.right = 316; |
| 2091 |
if (k[seq[sp_seq].frame[sp_frame]].hardbox.right < -320) k[seq[sp_seq].frame[sp_frame]].hardbox.right = -320; |
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
return 0; |
| 2096 |
|
| 2097 |
} |
| 2098 |
|
| 2099 |
|
| 2100 |
if (g_editorMode == EDITOR_MODE_SCREEN_SPRITES) { |
| 2101 |
// place sprite |
| 2102 |
if ( (input_getcharjustpressed(SDLK_v)) ) { |
| 2103 |
in_master = INPUT_SCREEN_VISION; // Set screen vision? |
| 2104 |
} |
| 2105 |
|
| 2106 |
int modif = 0; |
| 2107 |
if (SDL_GetModState()&KMOD_SHIFT) |
| 2108 |
modif = 9; |
| 2109 |
|
| 2110 |
if (input_getcharjustpressed(SDLK_m)) { |
| 2111 |
if (sp_screenmatch) |
| 2112 |
sp_screenmatch = /*false*/0; |
| 2113 |
else |
| 2114 |
sp_screenmatch = /*true*/1; |
| 2115 |
} |
| 2116 |
|
| 2117 |
|
| 2118 |
if (SDL_GetModState()&KMOD_ALT) { |
| 2119 |
//alt is held down 87 |
| 2120 |
if (input_getcharjustpressed(SDLK_w)) { |
| 2121 |
//pressed W |
| 2122 |
if (((spr[1].pseq == 10) && (spr[1].pframe == 8))) { |
| 2123 |
//a sprite is not chosen |
| 2124 |
hold_warp_map = cur_map; |
| 2125 |
hold_warp_x = spr[1].x; |
| 2126 |
hold_warp_y= spr[1].y; |
| 2127 |
EditorSoundPlayEffect(SOUND_JUMP); |
| 2128 |
} |
| 2129 |
else { |
| 2130 |
sp_warp_map = hold_warp_map ; |
| 2131 |
sp_warp_x = hold_warp_x; |
| 2132 |
sp_warp_y = hold_warp_y; |
| 2133 |
EditorSoundPlayEffect(SOUND_JUMP); |
| 2134 |
} |
| 2135 |
} |
| 2136 |
} |
| 2137 |
|
| 2138 |
/** |
| 2139 |
* Edit sprite properties |
| 2140 |
*/ |
| 2141 |
if (!((spr[1].pseq == 10) && (spr[1].pframe == 8))) { |
| 2142 |
//they are wheeling around a sprite |
| 2143 |
if (spr[1].x > 1500) spr[1].x = 1500; |
| 2144 |
if (spr[1].y > 1500) spr[1].y = 1500; |
| 2145 |
|
| 2146 |
if (spr[1].size > 1500) spr[1].size = 1500; |
| 2147 |
|
| 2148 |
/* if (GetKeyboard(VK_OEM_4 /\* 219 *\/)) // '[' for US */ |
| 2149 |
if (input_getscancodestate(SDL_SCANCODE_PAGEDOWN) || input_getscancodestate(SDL_SCANCODE_LEFTBRACKET)) |
| 2150 |
spr[1].size -= 1+modif; |
| 2151 |
/* if (GetKeyboard(VK_OEM_6 /\* 221 *\/)) // ']' for US */ |
| 2152 |
if (input_getscancodestate(SDL_SCANCODE_PAGEUP) || input_getscancodestate(SDL_SCANCODE_RIGHTBRACKET)) |
| 2153 |
spr[1].size += 1+modif; |
| 2154 |
|
| 2155 |
|
| 2156 |
if (SDL_GetModState()&KMOD_SHIFT) { |
| 2157 |
//shift is being held down |
| 2158 |
if (input_getscancodestate(SDL_SCANCODE_1) || input_getscancodestate(SDL_SCANCODE_KP_1) || input_getscancodestate(SDL_SCANCODE_F1)) in_master = 11; |
| 2159 |
if (input_getscancodestate(SDL_SCANCODE_2) || input_getscancodestate(SDL_SCANCODE_KP_2) || input_getscancodestate(SDL_SCANCODE_F2)) in_master = 12; |
| 2160 |
if (input_getscancodestate(SDL_SCANCODE_3) || input_getscancodestate(SDL_SCANCODE_KP_3) || input_getscancodestate(SDL_SCANCODE_F3)) in_master = 13; |
| 2161 |
if (input_getscancodestate(SDL_SCANCODE_4) || input_getscancodestate(SDL_SCANCODE_KP_4) || input_getscancodestate(SDL_SCANCODE_F4)) in_master = 14; |
| 2162 |
if (input_getscancodestate(SDL_SCANCODE_5) || input_getscancodestate(SDL_SCANCODE_KP_5) || input_getscancodestate(SDL_SCANCODE_F5)) in_master = 15; |
| 2163 |
|
| 2164 |
if (input_getscancodestate(SDL_SCANCODE_6) || input_getscancodestate(SDL_SCANCODE_KP_6) || input_getscancodestate(SDL_SCANCODE_F6)) in_master = 16; |
| 2165 |
if (input_getscancodestate(SDL_SCANCODE_7) || input_getscancodestate(SDL_SCANCODE_KP_7) || input_getscancodestate(SDL_SCANCODE_F7)) in_master = 17; |
| 2166 |
if (input_getscancodestate(SDL_SCANCODE_8) || input_getscancodestate(SDL_SCANCODE_KP_8) || input_getscancodestate(SDL_SCANCODE_F8)) in_master = 18; |
| 2167 |
if (input_getscancodestate(SDL_SCANCODE_9) || input_getscancodestate(SDL_SCANCODE_KP_9) || input_getscancodestate(SDL_SCANCODE_F9)) in_master = 19; |
| 2168 |
|
| 2169 |
|
| 2170 |
|
| 2171 |
} |
| 2172 |
else if (SDL_GetModState()&KMOD_ALT) { |
| 2173 |
//alt is being held down |
| 2174 |
if (input_getscancodestate(SDL_SCANCODE_1) || input_getscancodestate(SDL_SCANCODE_KP_1) || input_getscancodestate(SDL_SCANCODE_F1)) in_master = 20; |
| 2175 |
if (input_getscancodestate(SDL_SCANCODE_2) || input_getscancodestate(SDL_SCANCODE_KP_2) || input_getscancodestate(SDL_SCANCODE_F2)) in_master = 21; |
| 2176 |
if (input_getscancodestate(SDL_SCANCODE_3) || input_getscancodestate(SDL_SCANCODE_KP_3) || input_getscancodestate(SDL_SCANCODE_F3)) in_master = 22; |
| 2177 |
/*(getkeystate('4' /\* 52 *\/)) in_master = 14; |
| 2178 |
if (getkeystate(53)) in_master = 15; |
| 2179 |
|
| 2180 |
if (getkeystate(54)) in_master = 16; |
| 2181 |
if (getkeystate(55)) in_master = 17; |
| 2182 |
if (getkeystate(56)) in_master = 18; |
| 2183 |
if (getkeystate(57)) in_master = 19; |
| 2184 |
|
| 2185 |
*/ |
| 2186 |
} |
| 2187 |
else { |
| 2188 |
//shift is not being held down |
| 2189 |
if (input_getscancodestate(SDL_SCANCODE_1) || input_getscancodestate(SDL_SCANCODE_KP_1) || input_getscancodestate(SDL_SCANCODE_F1)) in_master = 1; |
| 2190 |
if (input_getscancodestate(SDL_SCANCODE_2) || input_getscancodestate(SDL_SCANCODE_KP_2) || input_getscancodestate(SDL_SCANCODE_F2)) in_master = 2; |
| 2191 |
if (input_getscancodestate(SDL_SCANCODE_3) || input_getscancodestate(SDL_SCANCODE_KP_3) || input_getscancodestate(SDL_SCANCODE_F3)) in_master = 3; |
| 2192 |
if (input_getscancodestate(SDL_SCANCODE_4) || input_getscancodestate(SDL_SCANCODE_KP_4) || input_getscancodestate(SDL_SCANCODE_F4)) in_master = 4; |
| 2193 |
if (input_getscancodestate(SDL_SCANCODE_5) || input_getscancodestate(SDL_SCANCODE_KP_5) || input_getscancodestate(SDL_SCANCODE_F5)) in_master = 5; |
| 2194 |
if (input_getscancodestate(SDL_SCANCODE_6) || input_getscancodestate(SDL_SCANCODE_KP_6) || input_getscancodestate(SDL_SCANCODE_F6)) in_master = 6; |
| 2195 |
if (input_getscancodestate(SDL_SCANCODE_7) || input_getscancodestate(SDL_SCANCODE_KP_7) || input_getscancodestate(SDL_SCANCODE_F7)) in_master = 7; |
| 2196 |
if (input_getscancodestate(SDL_SCANCODE_8) || input_getscancodestate(SDL_SCANCODE_KP_8) || input_getscancodestate(SDL_SCANCODE_F8)) in_master = 8; |
| 2197 |
if (input_getscancodestate(SDL_SCANCODE_9) || input_getscancodestate(SDL_SCANCODE_KP_9) || input_getscancodestate(SDL_SCANCODE_F9)) in_master = 9; |
| 2198 |
if (input_getscancodestate(SDL_SCANCODE_0) || input_getscancodestate(SDL_SCANCODE_KP_0) || input_getscancodestate(SDL_SCANCODE_F10)) in_master = 10; |
| 2199 |
} |
| 2200 |
|
| 2201 |
|
| 2202 |
if (input_getcharjustpressed(SDLK_s)) { |
| 2203 |
smart_add(); |
| 2204 |
|
| 2205 |
draw_screen_editor(); |
| 2206 |
} |
| 2207 |
|
| 2208 |
if ( (sjoy.button[EDITOR_ACTION_RETURN]) | (mouse1) ) { |
| 2209 |
smart_add(); |
| 2210 |
draw_screen_editor(); |
| 2211 |
spr[1].pseq = 10; |
| 2212 |
spr[1].pframe = 8; |
| 2213 |
spr[1].size = 100; |
| 2214 |
rect_set(&spr[1].alt,0,0,0,0); |
| 2215 |
|
| 2216 |
} |
| 2217 |
|
| 2218 |
if (input_getscancodejustpressed(SDL_SCANCODE_DELETE)) { |
| 2219 |
|
| 2220 |
spr[1].pseq = 10; |
| 2221 |
spr[1].pframe = 8; |
| 2222 |
spr[1].size = 100; |
| 2223 |
rect_set(&spr[1].alt,0,0,0,0); |
| 2224 |
|
| 2225 |
} |
| 2226 |
|
| 2227 |
} else { |
| 2228 |
//no sprite is currently selected |
| 2229 |
|
| 2230 |
int max_spr = 0; |
| 2231 |
int jj; |
| 2232 |
|
| 2233 |
write_moves(); |
| 2234 |
|
| 2235 |
|
| 2236 |
|
| 2237 |
for (jj=1; jj < 100; jj++) { |
| 2238 |
if ( cur_ed_screen.sprite[jj].active) if (cur_ed_screen.sprite[jj].vision == map_vision) max_spr++; |
| 2239 |
} |
| 2240 |
|
| 2241 |
|
| 2242 |
if (max_spr > 0) { |
| 2243 |
|
| 2244 |
/* if (sjoy.keyjustpressed[VK_OEM_4 /\* 219 *\/]) // '[' for US */ |
| 2245 |
if (input_getscancodejustpressed(SDL_SCANCODE_PAGEUP) || input_getscancodejustpressed(SDL_SCANCODE_LEFTBRACKET)) { |
| 2246 |
sp_cycle--; |
| 2247 |
if (sp_cycle < 1) |
| 2248 |
sp_cycle = max_spr; |
| 2249 |
} |
| 2250 |
|
| 2251 |
if (input_getscancodejustpressed(SDL_SCANCODE_PAGEDOWN) || input_getscancodejustpressed(SDL_SCANCODE_RIGHTBRACKET)) { |
| 2252 |
sp_cycle++; |
| 2253 |
if (sp_cycle > max_spr) |
| 2254 |
sp_cycle = 1; |
| 2255 |
} |
| 2256 |
} |
| 2257 |
|
| 2258 |
|
| 2259 |
|
| 2260 |
//Msg("Cycle is %d", sp_cycle); |
| 2261 |
int realpic = 0; |
| 2262 |
|
| 2263 |
if (sp_cycle > 0) { |
| 2264 |
//lets draw a frame around the sprite we want |
| 2265 |
int dumbpic = 0; |
| 2266 |
int jh; |
| 2267 |
realpic = 0; |
| 2268 |
for (jh = 1; dumbpic != sp_cycle; jh++) { |
| 2269 |
if (cur_ed_screen.sprite[jh].active) if ( cur_ed_screen.sprite[jh].vision == map_vision) { |
| 2270 |
dumbpic++; |
| 2271 |
realpic = jh; |
| 2272 |
} |
| 2273 |
if (jh == 99) goto fail; |
| 2274 |
|
| 2275 |
} |
| 2276 |
|
| 2277 |
last_sprite_added = realpic; |
| 2278 |
|
| 2279 |
|
| 2280 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 2281 |
/* ddbltfx.dwFillColor = 235; */ |
| 2282 |
|
| 2283 |
int sprite = add_sprite_dumb(cur_ed_screen.sprite[realpic].x,cur_ed_screen.sprite[realpic].y,0, |
| 2284 |
cur_ed_screen.sprite[realpic].seq, cur_ed_screen.sprite[realpic].frame, |
| 2285 |
cur_ed_screen.sprite[realpic].size); |
| 2286 |
rect_copy(&spr[sprite].alt , &cur_ed_screen.sprite[realpic].alt); |
| 2287 |
get_box(sprite, &box_crap, &box_real, skip_screen_clipping()); |
| 2288 |
|
| 2289 |
|
| 2290 |
|
| 2291 |
|
| 2292 |
get_box(sprite, &box_crap, &box_real, skip_screen_clipping()); |
| 2293 |
box_crap.bottom = box_crap.top + 5; |
| 2294 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL,NULL, DDBLT_COLORFILL| DDBLT_WAIT, &ddbltfx); */ |
| 2295 |
// GFX |
| 2296 |
{ |
| 2297 |
SDL_Rect dst; |
| 2298 |
dst.x = box_crap.left; |
| 2299 |
dst.y = box_crap.top; |
| 2300 |
dst.w = box_crap.right - box_crap.left; |
| 2301 |
dst.h = 5; |
| 2302 |
IOGFX_backbuffer->fillRect(&dst, 33,41,16); |
| 2303 |
} |
| 2304 |
|
| 2305 |
get_box(sprite, &box_crap, &box_real, skip_screen_clipping()); |
| 2306 |
box_crap.right = box_crap.left + 5; |
| 2307 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL,NULL, DDBLT_COLORFILL| DDBLT_WAIT, &ddbltfx); */ |
| 2308 |
// GFX |
| 2309 |
{ |
| 2310 |
SDL_Rect dst; |
| 2311 |
dst.x = box_crap.left; |
| 2312 |
dst.y = box_crap.top; |
| 2313 |
dst.w = 5; |
| 2314 |
dst.h = box_crap.bottom - box_crap.top; |
| 2315 |
IOGFX_backbuffer->fillRect(&dst, 33,41,16); |
| 2316 |
} |
| 2317 |
|
| 2318 |
get_box(sprite, &box_crap, &box_real, skip_screen_clipping()); |
| 2319 |
box_crap.left = box_crap.right - 5; |
| 2320 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL,NULL, DDBLT_COLORFILL| DDBLT_WAIT, &ddbltfx); */ |
| 2321 |
// GFX |
| 2322 |
{ |
| 2323 |
SDL_Rect dst; |
| 2324 |
dst.x = box_crap.right - 5; |
| 2325 |
dst.y = box_crap.top; |
| 2326 |
dst.w = 5; |
| 2327 |
dst.h = box_crap.bottom - box_crap.top; |
| 2328 |
IOGFX_backbuffer->fillRect(&dst, 33,41,16); |
| 2329 |
} |
| 2330 |
|
| 2331 |
get_box(sprite, &box_crap, &box_real, skip_screen_clipping()); |
| 2332 |
box_crap.top = box_crap.bottom - 5; |
| 2333 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL,NULL, DDBLT_COLORFILL| DDBLT_WAIT, &ddbltfx); */ |
| 2334 |
// GFX |
| 2335 |
{ |
| 2336 |
SDL_Rect dst; |
| 2337 |
dst.x = box_crap.left; |
| 2338 |
dst.y = box_crap.bottom - 5; |
| 2339 |
dst.w = box_crap.right - box_crap.left; |
| 2340 |
dst.h = 5; |
| 2341 |
IOGFX_backbuffer->fillRect(&dst, 33,41,16); |
| 2342 |
} |
| 2343 |
|
| 2344 |
// if (ddrval != DD_OK) dderror(ddrval); |
| 2345 |
|
| 2346 |
lsm_remove_sprite(sprite); |
| 2347 |
|
| 2348 |
} |
| 2349 |
|
| 2350 |
fail: |
| 2351 |
if ( (sjoy.button[EDITOR_ACTION_RETURN]) | (mouse1)) { |
| 2352 |
//pick up a sprite already placed by hitting enter |
| 2353 |
int uu; |
| 2354 |
|
| 2355 |
for (uu = 100; uu > 0; uu--) { |
| 2356 |
if ( cur_ed_screen.sprite[uu].active) if ( ( cur_ed_screen.sprite[uu].vision == 0) || (cur_ed_screen.sprite[uu].vision == map_vision)) { |
| 2357 |
|
| 2358 |
int sprite = add_sprite_dumb(cur_ed_screen.sprite[uu].x,cur_ed_screen.sprite[uu].y,0, |
| 2359 |
cur_ed_screen.sprite[uu].seq, cur_ed_screen.sprite[uu].frame, |
| 2360 |
cur_ed_screen.sprite[uu].size); |
| 2361 |
rect_copy(&spr[sprite].alt , &cur_ed_screen.sprite[uu].alt); |
| 2362 |
get_box(sprite, &box_crap, &box_real, skip_screen_clipping()); |
| 2363 |
if (realpic > 0) goto spwarp; |
| 2364 |
//Msg("Got sprite %d's info. X%d Y %d.",uu,box_crap.left,box_crap.right); |
| 2365 |
|
| 2366 |
if (inside_box(spr[1].x,spr[1].y,box_crap)) { |
| 2367 |
//this is the sprite they want to edit, lets convert them into it |
| 2368 |
// Msg("FOUND SPRITE! It's %d, huh.",uu); |
| 2369 |
|
| 2370 |
if (false) { |
| 2371 |
spwarp: |
| 2372 |
log_debug("Ah yeah, using %d!", realpic); |
| 2373 |
uu = realpic; |
| 2374 |
} |
| 2375 |
|
| 2376 |
spr[1].x = cur_ed_screen.sprite[uu].x; |
| 2377 |
spr[1].y = cur_ed_screen.sprite[uu].y; |
| 2378 |
spr[1].size = cur_ed_screen.sprite[uu].size; |
| 2379 |
sp_type = cur_ed_screen.sprite[uu].type; |
| 2380 |
sp_brain = cur_ed_screen.sprite[uu].brain; |
| 2381 |
sp_speed = cur_ed_screen.sprite[uu].speed; |
| 2382 |
sp_base_walk = cur_ed_screen.sprite[uu].base_walk; |
| 2383 |
sp_base_idle = cur_ed_screen.sprite[uu].base_idle; |
| 2384 |
sp_base_attack = cur_ed_screen.sprite[uu].base_attack; |
| 2385 |
sp_base_hit = cur_ed_screen.sprite[uu].base_hit; |
| 2386 |
sp_timer = cur_ed_screen.sprite[uu].timing; |
| 2387 |
sp_que = cur_ed_screen.sprite[uu].que; |
| 2388 |
sp_seq = cur_ed_screen.sprite[uu].seq; |
| 2389 |
sp_hard = cur_ed_screen.sprite[uu].hard; |
| 2390 |
rect_copy(&spr[1].alt , &cur_ed_screen.sprite[uu].alt); |
| 2391 |
sp_frame = cur_ed_screen.sprite[uu].frame; |
| 2392 |
spr[1].pseq = cur_ed_screen.sprite[uu].seq; |
| 2393 |
spr[1].pframe = cur_ed_screen.sprite[uu].frame; |
| 2394 |
|
| 2395 |
sp_is_warp = cur_ed_screen.sprite[uu].is_warp; |
| 2396 |
|
| 2397 |
sp_warp_map = cur_ed_screen.sprite[uu].warp_map; |
| 2398 |
sp_warp_x = cur_ed_screen.sprite[uu].warp_x; |
| 2399 |
sp_warp_y = cur_ed_screen.sprite[uu].warp_y; |
| 2400 |
sp_parm_seq = cur_ed_screen.sprite[uu].parm_seq; |
| 2401 |
strcpy(sp_script, cur_ed_screen.sprite[uu].script); |
| 2402 |
|
| 2403 |
sp_base_die = cur_ed_screen.sprite[uu].base_die; |
| 2404 |
sp_gold = cur_ed_screen.sprite[uu].gold; |
| 2405 |
sp_hitpoints = cur_ed_screen.sprite[uu].hitpoints; |
| 2406 |
|
| 2407 |
sp_exp = cur_ed_screen.sprite[uu].exp; |
| 2408 |
sp_nohit = cur_ed_screen.sprite[uu].nohit; |
| 2409 |
sp_touch_damage = cur_ed_screen.sprite[uu].touch_damage; |
| 2410 |
sp_defense = cur_ed_screen.sprite[uu].defense; |
| 2411 |
sp_strength = cur_ed_screen.sprite[uu].strength; |
| 2412 |
sp_sound = cur_ed_screen.sprite[uu].sound; |
| 2413 |
|
| 2414 |
cur_ed_screen.sprite[uu].active = /*false*/0; //erase sprite |
| 2415 |
draw_screen_editor(); |
| 2416 |
lsm_remove_sprite(sprite); |
| 2417 |
break; |
| 2418 |
} |
| 2419 |
lsm_remove_sprite(sprite); |
| 2420 |
|
| 2421 |
} |
| 2422 |
} |
| 2423 |
|
| 2424 |
|
| 2425 |
} |
| 2426 |
|
| 2427 |
|
| 2428 |
if ((SDL_GetModState()&KMOD_ALT) && (input_getscancodestate(SDL_SCANCODE_DELETE))) { |
| 2429 |
int ll; |
| 2430 |
for (ll = 1; ll < 100; ll++) { |
| 2431 |
cur_ed_screen.sprite[ll].active = /*false*/0; |
| 2432 |
} |
| 2433 |
draw_screen_editor(); |
| 2434 |
rect_set(&spr[h].alt,0,0,0,0); |
| 2435 |
} |
| 2436 |
} |
| 2437 |
|
| 2438 |
/** Trim a sprite **/ |
| 2439 |
if (input_getcharstate(SDLK_z) || (input_getcharstate(SDLK_x))) { |
| 2440 |
if ((spr[h].alt.right == 0) && (spr[h].alt.left == 0) |
| 2441 |
&& (spr[h].alt.top == 0) && (spr[h].alt.bottom == 0)) |
| 2442 |
rect_copy(&spr[h].alt, &k[getpic(h)].box); |
| 2443 |
} |
| 2444 |
|
| 2445 |
if (input_getcharstate(SDLK_z)) { |
| 2446 |
|
| 2447 |
if (input_getscancodejustpressed(SDL_SCANCODE_RIGHT)) { |
| 2448 |
spr[h].alt.left += spr[h].speed + modif; |
| 2449 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2450 |
} |
| 2451 |
|
| 2452 |
if (input_getscancodejustpressed(SDL_SCANCODE_LEFT)) { |
| 2453 |
spr[h].alt.left -= spr[h].speed +modif; |
| 2454 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2455 |
} |
| 2456 |
if (input_getscancodejustpressed(SDL_SCANCODE_DOWN)) { |
| 2457 |
spr[h].alt.top += spr[h].speed + modif; |
| 2458 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2459 |
} |
| 2460 |
|
| 2461 |
if (input_getscancodejustpressed(SDL_SCANCODE_UP)) { |
| 2462 |
spr[h].alt.top -= spr[h].speed + modif; |
| 2463 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2464 |
} |
| 2465 |
|
| 2466 |
|
| 2467 |
if (spr[h].alt.top < 0) spr[h].alt.top = 0; |
| 2468 |
if (spr[h].alt.left < 0) spr[h].alt.left = 0; |
| 2469 |
return 0; |
| 2470 |
} |
| 2471 |
|
| 2472 |
|
| 2473 |
|
| 2474 |
if (input_getcharstate(SDLK_x)) { |
| 2475 |
if (input_getscancodejustpressed(SDL_SCANCODE_RIGHT)) { |
| 2476 |
spr[h].alt.right += spr[h].speed + modif; |
| 2477 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2478 |
} |
| 2479 |
|
| 2480 |
if (input_getscancodejustpressed(SDL_SCANCODE_LEFT)) { |
| 2481 |
spr[h].alt.right -= spr[h].speed +modif; |
| 2482 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2483 |
} |
| 2484 |
if (input_getscancodejustpressed(SDL_SCANCODE_DOWN)) { |
| 2485 |
spr[h].alt.bottom += spr[h].speed + modif; |
| 2486 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2487 |
} |
| 2488 |
if (input_getscancodejustpressed(SDL_SCANCODE_UP)) { |
| 2489 |
spr[h].alt.bottom -= spr[h].speed + modif; |
| 2490 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2491 |
|
| 2492 |
// Msg("Bottom is %d..",spr[h].alt.bottom); |
| 2493 |
|
| 2494 |
} |
| 2495 |
if (spr[h].alt.bottom > k[getpic(h)].box.bottom) spr[h].alt.bottom = k[getpic(h)].box.bottom; |
| 2496 |
if (spr[h].alt.right > k[getpic(h)].box.right) spr[h].alt.right = k[getpic(h)].box.right; |
| 2497 |
|
| 2498 |
return 0; |
| 2499 |
|
| 2500 |
} |
| 2501 |
|
| 2502 |
|
| 2503 |
if (spr[1].size < 1) |
| 2504 |
spr[1].size = 1; |
| 2505 |
|
| 2506 |
/* Precise positionning: move the sprite just |
| 2507 |
1 pixel left/right/up/down, then don't do |
| 2508 |
move until an arrow key is released and |
| 2509 |
pressed again. */ |
| 2510 |
if (SDL_GetModState()&KMOD_CTRL) { |
| 2511 |
if (input_getscancodejustpressed(SDL_SCANCODE_RIGHT)) { |
| 2512 |
|
| 2513 |
sp_cycle = 0; |
| 2514 |
|
| 2515 |
spr[h].x += spr[h].speed + modif; |
| 2516 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2517 |
} |
| 2518 |
|
| 2519 |
if (input_getscancodejustpressed(SDL_SCANCODE_LEFT)) { |
| 2520 |
spr[h].x -= spr[h].speed +modif; |
| 2521 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2522 |
sp_cycle = 0; |
| 2523 |
} |
| 2524 |
if (input_getscancodejustpressed(SDL_SCANCODE_UP)) { |
| 2525 |
spr[h].y -= spr[h].speed + modif; |
| 2526 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2527 |
sp_cycle = 0; |
| 2528 |
} |
| 2529 |
|
| 2530 |
if (input_getscancodejustpressed(SDL_SCANCODE_DOWN)) { |
| 2531 |
spr[h].y += spr[h].speed + modif; |
| 2532 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2533 |
sp_cycle = 0; |
| 2534 |
} |
| 2535 |
|
| 2536 |
} else { |
| 2537 |
if (sjoy.right) { |
| 2538 |
spr[h].x += spr[h].speed + modif; |
| 2539 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2540 |
sp_cycle = 0; |
| 2541 |
} |
| 2542 |
|
| 2543 |
if (sjoy.left) { |
| 2544 |
spr[h].x -= spr[h].speed +modif; |
| 2545 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2546 |
sp_cycle = 0; |
| 2547 |
} |
| 2548 |
if (sjoy.up) { |
| 2549 |
spr[h].y -= spr[h].speed + modif; |
| 2550 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2551 |
sp_cycle = 0; |
| 2552 |
} |
| 2553 |
|
| 2554 |
if (sjoy.down) { |
| 2555 |
spr[h].y += spr[h].speed + modif; |
| 2556 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2557 |
sp_cycle = 0; |
| 2558 |
|
| 2559 |
} |
| 2560 |
|
| 2561 |
|
| 2562 |
} |
| 2563 |
|
| 2564 |
|
| 2565 |
|
| 2566 |
|
| 2567 |
|
| 2568 |
if ( (sjoy.button[EDITOR_ACTION_ESCAPE]) ) { |
| 2569 |
//return to edit mode or drop sprite, depending.. |
| 2570 |
if (((spr[1].pseq == 10) && (spr[1].pframe == 8)) ) { |
| 2571 |
|
| 2572 |
rect_set(&spr[1].alt,0,0,0,0); |
| 2573 |
|
| 2574 |
spr[1].size = 100; |
| 2575 |
g_editorMode = EDITOR_MODE_SCREEN_TILES; |
| 2576 |
spr[1].x = m4x; |
| 2577 |
spr[1].y = m4y; |
| 2578 |
spr[1].seq = 3; |
| 2579 |
spr[1].speed = 50; |
| 2580 |
} else { |
| 2581 |
smart_add(); |
| 2582 |
draw_screen_editor(); |
| 2583 |
rect_set(&spr[1].alt,0,0,0,0); |
| 2584 |
|
| 2585 |
spr[1].pseq = 10; |
| 2586 |
spr[1].pframe = 8; |
| 2587 |
spr[1].size = 100; |
| 2588 |
|
| 2589 |
} |
| 2590 |
} |
| 2591 |
|
| 2592 |
|
| 2593 |
if (input_getcharjustpressed(SDLK_e)) { |
| 2594 |
//they hit E, go to sprite picker |
| 2595 |
rect_set(&spr[1].alt,0,0,0,0); |
| 2596 |
|
| 2597 |
spr[1].size = 100; |
| 2598 |
//mode = 5; |
| 2599 |
g_editorMode = EDITOR_MODE_SPRITE_PICKER; |
| 2600 |
m6x = spr[h].x; |
| 2601 |
m6y = spr[h].y; |
| 2602 |
spr[h].x = m5x; |
| 2603 |
spr[h].y = m5y; |
| 2604 |
|
| 2605 |
spr[1].seq = 3; |
| 2606 |
spr[1].speed = 50; |
| 2607 |
if (sp_seq == 0) draw15(sp_picker); else draw96(sp_frame); |
| 2608 |
goto sp_edit_end; |
| 2609 |
|
| 2610 |
} |
| 2611 |
if (sjoy.button[EDITOR_ACTION_TAB]) { |
| 2612 |
//they hit tab, return to tile edit mode |
| 2613 |
if ( !((spr[1].pseq == 10) && (spr[1].pframe == 8)) ) { |
| 2614 |
smart_add(); |
| 2615 |
rect_set(&spr[1].alt,0,0,0,0); |
| 2616 |
|
| 2617 |
draw_screen_editor(); |
| 2618 |
} |
| 2619 |
spr[1].size = 100; |
| 2620 |
g_editorMode = EDITOR_MODE_SCREEN_TILES; |
| 2621 |
spr[h].x = m4x; |
| 2622 |
spr[h].y = m4y; |
| 2623 |
|
| 2624 |
spr[1].seq = 3; |
| 2625 |
spr[1].speed = 50; |
| 2626 |
// if (sp_seq == 0) draw15(); else draw96(); |
| 2627 |
goto sp_edit_end; |
| 2628 |
|
| 2629 |
} |
| 2630 |
|
| 2631 |
|
| 2632 |
return 0; |
| 2633 |
|
| 2634 |
} |
| 2635 |
|
| 2636 |
|
| 2637 |
if ( (g_editorMode == EDITOR_MODE_SCREEN_TILES) |
| 2638 |
&& (sjoy.button[EDITOR_ACTION_TAB])) { |
| 2639 |
|
| 2640 |
//they chose sprite picker mode |
| 2641 |
//lsm_kill_all_nonlive_sprites(); |
| 2642 |
|
| 2643 |
|
| 2644 |
g_editorMode = EDITOR_MODE_SCREEN_SPRITES; |
| 2645 |
|
| 2646 |
spr[1].pseq = 10; |
| 2647 |
spr[1].pframe = 8; |
| 2648 |
|
| 2649 |
spr[1].speed = 1; |
| 2650 |
selx = 1; |
| 2651 |
sely = 1; |
| 2652 |
m4x = spr[h].x; |
| 2653 |
m4y = spr[h].y; |
| 2654 |
//spr[h].x = m5x; |
| 2655 |
//spr[h].y = m5y; |
| 2656 |
|
| 2657 |
//if (sp_seq == 0) |
| 2658 |
// draw15(); else draw96(); |
| 2659 |
|
| 2660 |
} else if (g_editorMode == EDITOR_MODE_SPRITE_PICKER) { |
| 2661 |
//picking a sprite |
| 2662 |
if (sp_seq != 0) { |
| 2663 |
//they are in select sprite phase 2 |
| 2664 |
|
| 2665 |
if (input_getcharjustpressed(SDLK_e)) { |
| 2666 |
//they want to 'edit' the sprite |
| 2667 |
g_editorMode = EDITOR_MODE_SPRITE_HARDNESS; |
| 2668 |
m5x = spr[h].x; |
| 2669 |
m5y = spr[h].y; |
| 2670 |
|
| 2671 |
//lets blank the screen |
| 2672 |
/* ZeroMemory(&ddbltfx, sizeof(ddbltfx)); */ |
| 2673 |
/* ddbltfx.dwSize = sizeof( ddbltfx); */ |
| 2674 |
/* ddbltfx.dwFillColor = 255; */ |
| 2675 |
/* crap = lpDDSTwo->Blt(NULL ,NULL,NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); */ |
| 2676 |
// GFX |
| 2677 |
IOGFX_background->fillRect(NULL, 255,255,255); |
| 2678 |
|
| 2679 |
holdx = (spr[1].x / 50); |
| 2680 |
int holdy = (spr[1].y / 50)+1; |
| 2681 |
holdx = holdx * 8; |
| 2682 |
if (seq[sp_seq].frame[holdx + holdy] == 0) goto sp_fin; |
| 2683 |
|
| 2684 |
add_sprite_dumb(320,200 , 0,sp_seq,holdx + holdy,100 ); |
| 2685 |
|
| 2686 |
sp_frame = holdx + holdy; |
| 2687 |
spr[1].pseq = 10; |
| 2688 |
spr[1].pframe = 8; |
| 2689 |
|
| 2690 |
|
| 2691 |
spr[1].speed = 1; |
| 2692 |
goto sp_edit_end; |
| 2693 |
|
| 2694 |
} |
| 2695 |
|
| 2696 |
if ((sjoy.button[EDITOR_ACTION_ESCAPE])) { |
| 2697 |
|
| 2698 |
|
| 2699 |
//returning to main sprite picker mode |
| 2700 |
sp_seq = 0; |
| 2701 |
|
| 2702 |
draw15(sp_picker); |
| 2703 |
spr[h].x = m5ax; |
| 2704 |
spr[h].y = m5ay; |
| 2705 |
|
| 2706 |
goto sp_edit_end; |
| 2707 |
} |
| 2708 |
|
| 2709 |
if (sjoy.button[EDITOR_ACTION_TAB]) { |
| 2710 |
//leave to screen editor |
| 2711 |
sp_fin: |
| 2712 |
m5x = spr[h].x; |
| 2713 |
m5y = spr[h].y; |
| 2714 |
|
| 2715 |
draw_screen_editor(); |
| 2716 |
spr[h].x = m6x; |
| 2717 |
spr[h].y = m6y; |
| 2718 |
|
| 2719 |
spr[1].pseq = 10; |
| 2720 |
spr[1].pframe = 8; |
| 2721 |
|
| 2722 |
spr[h].speed = 1; |
| 2723 |
g_editorMode = EDITOR_MODE_SCREEN_SPRITES; |
| 2724 |
goto sp_edit_end; |
| 2725 |
|
| 2726 |
} |
| 2727 |
|
| 2728 |
if (sjoy.button[EDITOR_ACTION_RETURN]) { |
| 2729 |
|
| 2730 |
// go to mode 6, sprite placement |
| 2731 |
m5x = spr[h].x; |
| 2732 |
m5y = spr[h].y; |
| 2733 |
|
| 2734 |
|
| 2735 |
holdx = (spr[1].x / 50); |
| 2736 |
int holdy = (spr[1].y / 50)+1; |
| 2737 |
holdx = holdx * 8; |
| 2738 |
if (seq[sp_seq].frame[holdx + holdy] == 0) goto sp_fin; |
| 2739 |
spr[1].pseq = sp_seq; |
| 2740 |
spr[1].pframe = holdx + holdy; |
| 2741 |
sp_frame = holdx + holdy; |
| 2742 |
draw_screen_editor(); |
| 2743 |
spr[h].x = m6x; |
| 2744 |
spr[h].y = m6y; |
| 2745 |
g_editorMode = EDITOR_MODE_SCREEN_SPRITES; |
| 2746 |
spr[h].speed = 1; |
| 2747 |
goto sp_edit_end; |
| 2748 |
|
| 2749 |
} |
| 2750 |
|
| 2751 |
|
| 2752 |
goto sp_edit_end; |
| 2753 |
} |
| 2754 |
|
| 2755 |
|
| 2756 |
if (sjoy.button[EDITOR_ACTION_TAB] || sjoy.button[EDITOR_ACTION_ESCAPE]) { |
| 2757 |
|
| 2758 |
//exit to main editor |
| 2759 |
/*m5x = spr[h].x; |
| 2760 |
m5y = spr[h].y; |
| 2761 |
draw_screen_editor(); |
| 2762 |
spr[h].x = m4x; |
| 2763 |
spr[h].y = m4y; |
| 2764 |
mode = 3; |
| 2765 |
return 0; |
| 2766 |
*/ |
| 2767 |
m5x = spr[h].x; |
| 2768 |
m5y = spr[h].y; |
| 2769 |
|
| 2770 |
draw_screen_editor(); |
| 2771 |
spr[h].x = m6x; |
| 2772 |
spr[h].y = m6y; |
| 2773 |
spr[h].pseq = 10; |
| 2774 |
spr[h].pframe = 8; |
| 2775 |
|
| 2776 |
spr[h].speed = 1; |
| 2777 |
g_editorMode = EDITOR_MODE_SCREEN_SPRITES; |
| 2778 |
return 0; |
| 2779 |
//goto sp_edit_end; |
| 2780 |
|
| 2781 |
} |
| 2782 |
|
| 2783 |
/* if (sjoy.keyjustpressed[VK_OEM_4 /\* 219 *\/]) // '[' for US */ |
| 2784 |
if (input_getscancodejustpressed(SDL_SCANCODE_PAGEUP) || input_getscancodejustpressed(SDL_SCANCODE_LEFTBRACKET)) { |
| 2785 |
if (sp_picker > 95) sp_picker -= 96; else { |
| 2786 |
sp_picker = (4 * 96); |
| 2787 |
} |
| 2788 |
draw15(sp_picker); |
| 2789 |
} |
| 2790 |
/* if (sjoy.keyjustpressed[VK_OEM_6 /\* 221 *\/]) // ']' for US */ |
| 2791 |
if (input_getscancodejustpressed(SDL_SCANCODE_PAGEDOWN) || input_getscancodejustpressed(SDL_SCANCODE_RIGHTBRACKET)) { |
| 2792 |
if (sp_picker < 400) sp_picker += 96; |
| 2793 |
draw15(sp_picker); |
| 2794 |
} |
| 2795 |
|
| 2796 |
if (sjoy.button[EDITOR_ACTION_RETURN]) { |
| 2797 |
|
| 2798 |
//they chose a catagory, switch to phase 2, it will know cuz sp_seq > 0. |
| 2799 |
holdx = (spr[1].x / 50); |
| 2800 |
int holdy = (spr[1].y / 50)+1; |
| 2801 |
holdx = holdx * 8; |
| 2802 |
m5ax = spr[1].x; |
| 2803 |
m5ay = spr[1].y; |
| 2804 |
spr[1].x = 0; |
| 2805 |
spr[1].y = 0; |
| 2806 |
sp_seq = sp_get(sp_picker+ (holdx + holdy)); |
| 2807 |
// Msg("Sp_seq is %d",sp_seq); |
| 2808 |
draw96(0); |
| 2809 |
|
| 2810 |
} |
| 2811 |
|
| 2812 |
|
| 2813 |
} |
| 2814 |
sp_edit_end: |
| 2815 |
|
| 2816 |
|
| 2817 |
|
| 2818 |
|
| 2819 |
if (g_editorMode == EDITOR_MODE_SCREEN_TILES) draw_current(); |
| 2820 |
|
| 2821 |
|
| 2822 |
if (g_editorMode == EDITOR_MODE_INIT) { |
| 2823 |
|
| 2824 |
spr[h].seq = 2; |
| 2825 |
spr[h].seq_orig = 2; |
| 2826 |
draw_minimap(); |
| 2827 |
spr[1].que = 20000; |
| 2828 |
g_editorMode = EDITOR_MODE_MINIMAP; |
| 2829 |
spr[2].active = false; |
| 2830 |
spr[3].active = false; |
| 2831 |
spr[4].active = false; |
| 2832 |
} |
| 2833 |
|
| 2834 |
if (g_editorMode == EDITOR_MODE_INIT) return 0; |
| 2835 |
|
| 2836 |
|
| 2837 |
|
| 2838 |
|
| 2839 |
//mode equals 4, they are in hardness edit mode, so lets do this thang |
| 2840 |
|
| 2841 |
if (g_editorMode == EDITOR_MODE_TILE_HARDNESS) { |
| 2842 |
if (spr[h].seq == 0) { |
| 2843 |
if ((SDL_GetModState()&KMOD_SHIFT) && (input_getscancodestate(SDL_SCANCODE_RIGHT))) { |
| 2844 |
spr[h].seq = 4; |
| 2845 |
spr[h].frame = 1; |
| 2846 |
if (selx < 8) selx++; |
| 2847 |
goto b1fun; |
| 2848 |
} |
| 2849 |
|
| 2850 |
if ((SDL_GetModState()&KMOD_SHIFT) && (input_getscancodestate(SDL_SCANCODE_LEFT))) { |
| 2851 |
spr[h].seq = 4; |
| 2852 |
spr[h].frame = 1; |
| 2853 |
if (selx > 1) selx--; |
| 2854 |
goto b1fun; |
| 2855 |
} |
| 2856 |
|
| 2857 |
if ((SDL_GetModState()&KMOD_SHIFT) && (input_getscancodestate(SDL_SCANCODE_UP))) { |
| 2858 |
spr[h].seq = 4; |
| 2859 |
spr[h].frame = 1; |
| 2860 |
if (sely > 1) sely--; |
| 2861 |
goto b1fun; |
| 2862 |
} |
| 2863 |
|
| 2864 |
if ((SDL_GetModState()&KMOD_SHIFT) && (input_getscancodestate(SDL_SCANCODE_DOWN))) { |
| 2865 |
spr[h].seq = 4; |
| 2866 |
spr[h].frame = 1; |
| 2867 |
if (sely < 8) sely++; |
| 2868 |
goto b1fun; |
| 2869 |
} |
| 2870 |
|
| 2871 |
|
| 2872 |
if (sjoy.right) { |
| 2873 |
spr[h].x += 9; |
| 2874 |
spr[h].seq = 4; |
| 2875 |
spr[h].frame = 1; |
| 2876 |
EditorSoundPlayEffect(SOUND_STOP); |
| 2877 |
} |
| 2878 |
if (sjoy.left) { |
| 2879 |
spr[h].x -= 9; |
| 2880 |
spr[h].seq = 4; |
| 2881 |
spr[h].frame = 1; |
| 2882 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2883 |
} |
| 2884 |
if (sjoy.up) { |
| 2885 |
spr[h].y -= 9; |
| 2886 |
spr[h].seq = 4; |
| 2887 |
spr[h].frame = 1; |
| 2888 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2889 |
} |
| 2890 |
if (sjoy.down) { |
| 2891 |
spr[h].y += 9; |
| 2892 |
spr[h].seq = 4; |
| 2893 |
spr[h].frame = 1; |
| 2894 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 2895 |
} |
| 2896 |
} |
| 2897 |
|
| 2898 |
|
| 2899 |
b1fun: |
| 2900 |
|
| 2901 |
//make sure they didn't go past the boundrys |
| 2902 |
if (g_editorMode != 1) { |
| 2903 |
|
| 2904 |
if (spr[h].x + (9 * (selx -1))> 95+441) spr[h].x = (95+441) - (9 * (selx-1)); |
| 2905 |
if (spr[h].x < 95) spr[h].x = 95; |
| 2906 |
if (spr[h].y < 0) spr[h].y = 0; |
| 2907 |
if (spr[h].y + (9 * (sely -1))> 441) spr[h].y = 441 - (9 * (sely-1)); |
| 2908 |
} |
| 2909 |
|
| 2910 |
//change a piece to hard |
| 2911 |
if (input_getcharstate(SDLK_z)) { |
| 2912 |
int y; |
| 2913 |
for (y = 0; y < sely; y++) { |
| 2914 |
int x; |
| 2915 |
for (x = 0; x < selx; x++) { |
| 2916 |
hmap.htile[hard_tile].hm[((spr[h].x) + (x*9) - 95) / 9][(spr[h].y + (y *9)) / 9] = 1; |
| 2917 |
|
| 2918 |
} |
| 2919 |
} |
| 2920 |
} |
| 2921 |
|
| 2922 |
|
| 2923 |
//change a piece to soft |
| 2924 |
if (input_getcharstate(SDLK_x)) { |
| 2925 |
int y; |
| 2926 |
for (y = 0; y < sely; y++) { |
| 2927 |
int x; |
| 2928 |
for (x = 0; x < selx; x++) { |
| 2929 |
hmap.htile[hard_tile].hm[((spr[h].x) + (x*9) - 95) / 9][(spr[h].y + (y *9)) / 9] = 0; |
| 2930 |
|
| 2931 |
} |
| 2932 |
} |
| 2933 |
} |
| 2934 |
|
| 2935 |
|
| 2936 |
if ( (input_getcharstate(SDLK_a)) && (SDL_GetModState()&KMOD_ALT ) ) { |
| 2937 |
//change ALL to 'low hard' |
| 2938 |
change_tile(hard_tile, 2); |
| 2939 |
log_debug("Changing whole tile to 2"); |
| 2940 |
|
| 2941 |
return 2; |
| 2942 |
} |
| 2943 |
|
| 2944 |
if ( (input_getcharstate(SDLK_s)) && (SDL_GetModState()&KMOD_ALT ) ) { |
| 2945 |
//change ALL to 'low hard' |
| 2946 |
change_tile(hard_tile, 3); |
| 2947 |
log_debug("Changing whole tile to 3"); |
| 2948 |
|
| 2949 |
return 2; |
| 2950 |
} |
| 2951 |
if ( (input_getcharstate(SDLK_x)) && (SDL_GetModState()&KMOD_ALT ) ) { |
| 2952 |
//change ALL to 'low hard' |
| 2953 |
change_tile(hard_tile, 1); |
| 2954 |
log_debug("Changing whole tile to 1"); |
| 2955 |
|
| 2956 |
return 2; |
| 2957 |
} |
| 2958 |
|
| 2959 |
|
| 2960 |
if (input_getcharstate(SDLK_a)) { |
| 2961 |
int y; |
| 2962 |
for (y = 0; y < sely; y++) { |
| 2963 |
int x; |
| 2964 |
for (x = 0; x < selx; x++) { |
| 2965 |
hmap.htile[hard_tile].hm[((spr[h].x) + (x*9) - 95) / 9][(spr[h].y + (y *9)) / 9] = 2; |
| 2966 |
|
| 2967 |
} |
| 2968 |
} |
| 2969 |
|
| 2970 |
} |
| 2971 |
if (input_getcharstate(SDLK_s)) { |
| 2972 |
int y; |
| 2973 |
for (y = 0; y < sely; y++) { |
| 2974 |
int x; |
| 2975 |
for (x = 0; x < selx; x++) { |
| 2976 |
hmap.htile[hard_tile].hm[((spr[h].x) + (x*9) - 95) / 9][(spr[h].y + (y *9)) / 9] = 3; |
| 2977 |
|
| 2978 |
} |
| 2979 |
} |
| 2980 |
|
| 2981 |
} |
| 2982 |
|
| 2983 |
|
| 2984 |
//update frame with current hard blocks, slow |
| 2985 |
|
| 2986 |
draw_hard(); |
| 2987 |
|
| 2988 |
if (sjoy.button[EDITOR_ACTION_ESCAPE] == 1 |
| 2989 |
|| sjoy.button[EDITOR_ACTION_RETURN] == 1) { |
| 2990 |
//quit hardness edit |
| 2991 |
|
| 2992 |
spr[h].seq = 3; |
| 2993 |
spr[h].seq_orig = 3; |
| 2994 |
|
| 2995 |
if (last_modereal == 8) { |
| 2996 |
//return to alt hardness editor |
| 2997 |
draw_screen_editor(); |
| 2998 |
last_modereal = 0; |
| 2999 |
spr[h].x = m4x; |
| 3000 |
spr[h].y = m4y; |
| 3001 |
|
| 3002 |
selx = 1; |
| 3003 |
sely = 1; |
| 3004 |
|
| 3005 |
g_editorMode = EDITOR_MODE_SCREEN_HARDNESS_INIT; |
| 3006 |
return 2; |
| 3007 |
} |
| 3008 |
|
| 3009 |
if (last_mode > 0) { |
| 3010 |
loadtile(last_mode); |
| 3011 |
selx = 1; |
| 3012 |
sely = 1; |
| 3013 |
return 0; |
| 3014 |
} |
| 3015 |
fill_whole_hard(); |
| 3016 |
|
| 3017 |
draw_screen_editor(); |
| 3018 |
spr[h].x = m4x; |
| 3019 |
spr[h].y = m4y; |
| 3020 |
g_editorMode = EDITOR_MODE_SCREEN_TILES; |
| 3021 |
selx = 1; |
| 3022 |
sely = 1; |
| 3023 |
} |
| 3024 |
|
| 3025 |
return 0; |
| 3026 |
} |
| 3027 |
|
| 3028 |
|
| 3029 |
//THEY WANT TO EDIT HARDNESS |
| 3030 |
|
| 3031 |
if ( (input_getcharjustpressed(SDLK_b)) ) { |
| 3032 |
in_master = 31; |
| 3033 |
|
| 3034 |
|
| 3035 |
} |
| 3036 |
|
| 3037 |
if ( (input_getcharjustpressed(SDLK_v)) ) { |
| 3038 |
in_master = INPUT_SCREEN_VISION; |
| 3039 |
} |
| 3040 |
|
| 3041 |
|
| 3042 |
|
| 3043 |
if (((g_editorMode == EDITOR_MODE_SCREEN_TILES) && (sjoy.button[EDITOR_ACTION_RETURN])) |
| 3044 |
|| ((g_editorMode == EDITOR_MODE_TILE_PICKER) && (input_getscancodestate(SDL_SCANCODE_SPACE)))) { |
| 3045 |
|
| 3046 |
if (g_editorMode == EDITOR_MODE_SCREEN_TILES) |
| 3047 |
cur_tile = cur_ed_screen.t[(((spr[1].y+1)*12) / 50)+(spr[1].x / 50)].square_full_idx0; |
| 3048 |
|
| 3049 |
if (g_editorMode == EDITOR_MODE_TILE_PICKER) { |
| 3050 |
cur_tile = (((spr[1].y+1)*12) / 50)+(spr[1].x / 50); |
| 3051 |
cur_tile += (cur_tileset * 128) - 128; |
| 3052 |
} |
| 3053 |
|
| 3054 |
lsm_kill_all_nonlive_sprites(); |
| 3055 |
draw_current(); |
| 3056 |
|
| 3057 |
if (cur_tile > 0) { |
| 3058 |
if (hmap.btile_default[cur_tile] == 0) { |
| 3059 |
int j; |
| 3060 |
for (j = 1; j < 799; j++) { |
| 3061 |
if (hmap.htile[j].used == /*FALSE*/0) { |
| 3062 |
hmap.btile_default[cur_tile] = j; |
| 3063 |
hmap.htile[j].used = /*TRUE*/1; |
| 3064 |
hard_tile = j; |
| 3065 |
goto tilesel; |
| 3066 |
} |
| 3067 |
} |
| 3068 |
} |
| 3069 |
else |
| 3070 |
hard_tile = hmap.btile_default[cur_tile]; |
| 3071 |
|
| 3072 |
tilesel: |
| 3073 |
xx = cur_tile % 128; |
| 3074 |
/* Rect.left = (xx * 50- (xx / 12) * 600); */ |
| 3075 |
/* Rect.top = (xx / 12) * 50; */ |
| 3076 |
/* Rect.right = Rect.left + 50; */ |
| 3077 |
/* Rect.bottom = Rect.top + 50; */ |
| 3078 |
|
| 3079 |
/* crapRec.top = 0; */ |
| 3080 |
/* crapRec.left = 95; */ |
| 3081 |
/* crapRec.bottom = 450; */ |
| 3082 |
/* crapRec.right = 95+450; */ |
| 3083 |
|
| 3084 |
/* ZeroMemory(&ddbltfx, sizeof(ddbltfx)); */ |
| 3085 |
/* ddbltfx.dwSize = sizeof( ddbltfx); */ |
| 3086 |
|
| 3087 |
spr[1].seq = 0; |
| 3088 |
spr[1].pseq = 10; |
| 3089 |
spr[1].pframe = 1; |
| 3090 |
|
| 3091 |
|
| 3092 |
|
| 3093 |
// Display the given tile square fullscreen, for hardness editing |
| 3094 |
/* lpDDSTwo->Blt(&crapRec , tiles[cool+1], */ |
| 3095 |
/* &Rect, DDBLT_DDFX | DDBLT_WAIT,&ddbltfx ); */ |
| 3096 |
// GFX |
| 3097 |
/* Generic scaling */ |
| 3098 |
/* Not perfectly accurate yet: move a 200% sprite to the |
| 3099 |
border of the screen to it is clipped: it's scaled size |
| 3100 |
will slighly vary. Maybe we need to clip the source zone |
| 3101 |
before scaling it.. */ |
| 3102 |
{ |
| 3103 |
SDL_Rect src, dst; |
| 3104 |
src.x = (xx % 12) * 50; |
| 3105 |
src.y = (xx / 12) * 50; |
| 3106 |
src.w = 50; |
| 3107 |
src.h = 50; |
| 3108 |
dst.x = 95; |
| 3109 |
dst.y = 0; |
| 3110 |
dst.w = 450; |
| 3111 |
dst.h = 450; |
| 3112 |
|
| 3113 |
cool = cur_tile / 128; |
| 3114 |
IOGFX_background->blitStretch(g_dmod.bgTilesets.slots[cool+1], &src, &dst); |
| 3115 |
} |
| 3116 |
|
| 3117 |
m4x = spr[h].x; |
| 3118 |
m4y = spr[h].y; |
| 3119 |
|
| 3120 |
spr[1].x = 95; |
| 3121 |
spr[1].y = 0; |
| 3122 |
selx = 1; |
| 3123 |
sely = 1; |
| 3124 |
|
| 3125 |
g_editorMode = EDITOR_MODE_TILE_HARDNESS; |
| 3126 |
} |
| 3127 |
} |
| 3128 |
|
| 3129 |
|
| 3130 |
if ((g_editorMode == EDITOR_MODE_TILE_PICKER) || (g_editorMode == EDITOR_MODE_SCREEN_TILES)) { |
| 3131 |
//resizing the box |
| 3132 |
|
| 3133 |
if ((SDL_GetModState()&KMOD_SHIFT) && (input_getscancodestate(SDL_SCANCODE_RIGHT)) ) { |
| 3134 |
spr[h].seq = 3; |
| 3135 |
spr[h].seq_orig = 3; |
| 3136 |
if (selx < 8) selx++; |
| 3137 |
return 0; |
| 3138 |
} |
| 3139 |
|
| 3140 |
if ((SDL_GetModState()&KMOD_SHIFT) && (input_getscancodestate(SDL_SCANCODE_LEFT)) ) { |
| 3141 |
spr[h].seq = 3; |
| 3142 |
spr[h].seq_orig = 3; |
| 3143 |
if (selx > 1) selx--; |
| 3144 |
return 0; |
| 3145 |
|
| 3146 |
} |
| 3147 |
|
| 3148 |
if ((SDL_GetModState()&KMOD_SHIFT) && (input_getscancodestate(SDL_SCANCODE_UP)) ) { |
| 3149 |
spr[h].seq = 3; |
| 3150 |
spr[h].seq_orig = 3; |
| 3151 |
if (sely > 1) sely--; |
| 3152 |
return 0; |
| 3153 |
} |
| 3154 |
|
| 3155 |
if ((SDL_GetModState()&KMOD_SHIFT) && (input_getscancodestate(SDL_SCANCODE_DOWN)) ) { |
| 3156 |
spr[h].seq = 3; |
| 3157 |
spr[h].seq_orig = 3; |
| 3158 |
if (sely < 8) sely++; |
| 3159 |
return 0; |
| 3160 |
} |
| 3161 |
|
| 3162 |
} |
| 3163 |
|
| 3164 |
|
| 3165 |
if (input_getscancodestate(SDL_SCANCODE_RIGHT)) { |
| 3166 |
spr[h].x += spr[h].speed; |
| 3167 |
spr[h].seq = spr[h].seq_orig; |
| 3168 |
EditorSoundPlayEffect( SOUND_STOP ); |
| 3169 |
} |
| 3170 |
|
| 3171 |
|
| 3172 |
if ((input_getcharstate(SDLK_s)) && (g_editorMode == EDITOR_MODE_SCREEN_TILES)) { |
| 3173 |
int y; |
| 3174 |
spr[h].seq = 3; |
| 3175 |
spr[h].seq_orig = 3; |
| 3176 |
//EditorSoundPlayEffect( SOUND_JUMP ); |
| 3177 |
|
| 3178 |
|
| 3179 |
cur_ed_screen.t[(((spr[1].y+1)*12) / 50)+(spr[1].x / 50)].square_full_idx0 = cur_tile; |
| 3180 |
|
| 3181 |
for (y = 0; y < sely; y++) { |
| 3182 |
int x; |
| 3183 |
for (x = 0; x < selx; x++) { |
| 3184 |
holdx = (((spr[1].y+1)*12) / 50)+(spr[1].x / 50); |
| 3185 |
holdx += (y * 12); |
| 3186 |
holdx += x; |
| 3187 |
cur_ed_screen.t[holdx].square_full_idx0 = (cur_tile + (y * 12) + x); |
| 3188 |
|
| 3189 |
} |
| 3190 |
} |
| 3191 |
|
| 3192 |
draw_screen_editor(); |
| 3193 |
} |
| 3194 |
|
| 3195 |
|
| 3196 |
|
| 3197 |
if ((input_getcharstate(SDLK_c)) && (g_editorMode == EDITOR_MODE_SCREEN_TILES)) { |
| 3198 |
spr[h].seq = 3; |
| 3199 |
spr[h].seq_orig = 3; |
| 3200 |
//SoundPlayEffect( SOUND_JUMP ); |
| 3201 |
cur_tile = cur_ed_screen.t[(((spr[1].y+1)*12) / 50)+(spr[1].x / 50)].square_full_idx0; |
| 3202 |
draw_screen_editor(); |
| 3203 |
} |
| 3204 |
|
| 3205 |
/* Tile selection */ |
| 3206 |
if (g_editorMode == EDITOR_MODE_SCREEN_TILES || g_editorMode == EDITOR_MODE_TILE_PICKER) { |
| 3207 |
int unit = 0, tile_no = 0; |
| 3208 |
if (input_getscancodestate(SDL_SCANCODE_1) || input_getscancodestate(SDL_SCANCODE_KP_1) || input_getscancodestate(SDL_SCANCODE_F1)) unit = 1; |
| 3209 |
if (input_getscancodestate(SDL_SCANCODE_2) || input_getscancodestate(SDL_SCANCODE_KP_2) || input_getscancodestate(SDL_SCANCODE_F2)) unit = 2; |
| 3210 |
if (input_getscancodestate(SDL_SCANCODE_3) || input_getscancodestate(SDL_SCANCODE_KP_3) || input_getscancodestate(SDL_SCANCODE_F3)) unit = 3; |
| 3211 |
if (input_getscancodestate(SDL_SCANCODE_4) || input_getscancodestate(SDL_SCANCODE_KP_4) || input_getscancodestate(SDL_SCANCODE_F4)) unit = 4; |
| 3212 |
if (input_getscancodestate(SDL_SCANCODE_5) || input_getscancodestate(SDL_SCANCODE_KP_5) || input_getscancodestate(SDL_SCANCODE_F5)) unit = 5; |
| 3213 |
if (input_getscancodestate(SDL_SCANCODE_6) || input_getscancodestate(SDL_SCANCODE_KP_6) || input_getscancodestate(SDL_SCANCODE_F6)) unit = 6; |
| 3214 |
if (input_getscancodestate(SDL_SCANCODE_7) || input_getscancodestate(SDL_SCANCODE_KP_7) || input_getscancodestate(SDL_SCANCODE_F7)) unit = 7; |
| 3215 |
if (input_getscancodestate(SDL_SCANCODE_8) || input_getscancodestate(SDL_SCANCODE_KP_8) || input_getscancodestate(SDL_SCANCODE_F8)) unit = 8; |
| 3216 |
if (input_getscancodestate(SDL_SCANCODE_9) || input_getscancodestate(SDL_SCANCODE_KP_9) || input_getscancodestate(SDL_SCANCODE_F9)) unit = 9; |
| 3217 |
if (input_getscancodestate(SDL_SCANCODE_0) || input_getscancodestate(SDL_SCANCODE_KP_0) || input_getscancodestate(SDL_SCANCODE_F10)) unit = 10; |
| 3218 |
|
| 3219 |
tile_no = unit; |
| 3220 |
if (SDL_GetModState()&KMOD_SHIFT) |
| 3221 |
tile_no = 10 + unit; |
| 3222 |
if (SDL_GetModState()&KMOD_CTRL) |
| 3223 |
tile_no = 20 + unit; |
| 3224 |
if (SDL_GetModState()&KMOD_ALT) |
| 3225 |
tile_no = 30 + unit; |
| 3226 |
|
| 3227 |
if (unit > 0) /* make sure one key was pressed */ |
| 3228 |
loadtile(tile_no); |
| 3229 |
|
| 3230 |
/* Exception: tile #41 = Alt+[top-left key below escape] */ |
| 3231 |
if ((SDL_GetModState()&KMOD_ALT) |
| 3232 |
&& input_getscancodestate(SDL_SCANCODE_GRAVE)) |
| 3233 |
loadtile(41); |
| 3234 |
/* alternatives */ |
| 3235 |
if (input_getscancodestate(SDL_SCANCODE_F11) || input_getscancodestate(SDL_SCANCODE_KP_PERIOD)) |
| 3236 |
loadtile(41); |
| 3237 |
} |
| 3238 |
|
| 3239 |
//if ( (GetKeyboard(48)) && ( (mode == 3) | (mode ==2)) ) loadtile(11); |
| 3240 |
|
| 3241 |
|
| 3242 |
if ((sjoy.button[EDITOR_ACTION_RETURN]) && (g_editorMode == EDITOR_MODE_TILE_PICKER)) { |
| 3243 |
// cut to map editer from tile selection |
| 3244 |
spr[h].seq = 3; |
| 3245 |
spr[h].seq_orig = 3; |
| 3246 |
cur_tile = (((spr[1].y+1)*12) / 50)+(spr[1].x / 50); |
| 3247 |
cur_tile += (cur_tileset * 128) - 128; |
| 3248 |
//SoundPlayEffect( SOUND_JUMP ); |
| 3249 |
m2x = spr[h].x; |
| 3250 |
m2y = spr[h].y; |
| 3251 |
spr[h].x = m3x; |
| 3252 |
spr[h].y = m3y; |
| 3253 |
|
| 3254 |
g_editorMode = EDITOR_MODE_SCREEN_TILES; |
| 3255 |
spr[h].speed = 50; |
| 3256 |
draw_screen_editor(); |
| 3257 |
last_mode = 0; |
| 3258 |
} |
| 3259 |
|
| 3260 |
|
| 3261 |
|
| 3262 |
if (sjoy.button[EDITOR_ACTION_ESCAPE] && (g_editorMode == EDITOR_MODE_TILE_PICKER)) { |
| 3263 |
// cut to map editer from tile selection |
| 3264 |
spr[h].seq = 3; |
| 3265 |
spr[h].seq_orig = 3; |
| 3266 |
//cur_tile = (((spr[1].y+1)*12) / 50)+(spr[1].x / 50); |
| 3267 |
//SoundPlayEffect( SOUND_JUMP ); |
| 3268 |
m2x = spr[h].x; |
| 3269 |
m2y = spr[h].y; |
| 3270 |
spr[h].x = m3x; |
| 3271 |
spr[h].y = m3y; |
| 3272 |
|
| 3273 |
g_editorMode = EDITOR_MODE_SCREEN_TILES; |
| 3274 |
draw_screen_editor(); |
| 3275 |
last_mode = 0; |
| 3276 |
return 0; |
| 3277 |
} |
| 3278 |
|
| 3279 |
|
| 3280 |
if ( (input_getscancodejustpressed(SDL_SCANCODE_SPACE)) && (g_editorMode == EDITOR_MODE_MINIMAP)) { |
| 3281 |
//make_map_tiny(); |
| 3282 |
draw_screen_tiny = 0; |
| 3283 |
|
| 3284 |
} |
| 3285 |
|
| 3286 |
if ( (input_getcharjustpressed(SDLK_l)) && (g_editorMode == EDITOR_MODE_MINIMAP)) { |
| 3287 |
|
| 3288 |
//if (g_dmod.map.loc[(((spr[1].y+1)*32) / 20)+(spr[1].x / 20)] != 0) |
| 3289 |
//{ |
| 3290 |
buf_map = (((spr[1].y+1)*32) / 20)+(spr[1].x / 20); |
| 3291 |
in_master = INPUT_MINIMAP_LOAD; |
| 3292 |
//} |
| 3293 |
|
| 3294 |
} |
| 3295 |
|
| 3296 |
|
| 3297 |
if ( (input_getscancodejustpressed(SDL_SCANCODE_ESCAPE)) && (g_editorMode == EDITOR_MODE_MINIMAP)) { |
| 3298 |
g_dmod.map.load(); |
| 3299 |
draw_minimap(); |
| 3300 |
buf_mode = /*false*/0; |
| 3301 |
|
| 3302 |
} |
| 3303 |
|
| 3304 |
|
| 3305 |
if ( (input_getcharjustpressed(SDLK_m)) && (g_editorMode == EDITOR_MODE_MINIMAP)) { |
| 3306 |
//set music # for this block |
| 3307 |
in_int = &g_dmod.map.music[(((spr[1].y+1)*32) / 20)+(spr[1].x / 20)]; |
| 3308 |
in_master = INPUT_SCREEN_MIDI; |
| 3309 |
} |
| 3310 |
|
| 3311 |
if ( (input_getcharjustpressed(SDLK_s)) && (g_editorMode == EDITOR_MODE_MINIMAP)) { |
| 3312 |
//set music # for this block |
| 3313 |
in_int = &g_dmod.map.indoor[(((spr[1].y+1)*32) / 20)+(spr[1].x / 20)]; |
| 3314 |
in_master = INPUT_SCREEN_TYPE; |
| 3315 |
} |
| 3316 |
|
| 3317 |
if ( (input_getcharjustpressed(SDLK_q)) && (g_editorMode == EDITOR_MODE_MINIMAP)) { |
| 3318 |
save_hard(); |
| 3319 |
log_info("Info saved."); |
| 3320 |
SDL_Event ev; |
| 3321 |
ev.type = SDL_QUIT; |
| 3322 |
SDL_PushEvent(&ev); |
| 3323 |
return 2; |
| 3324 |
} |
| 3325 |
|
| 3326 |
if ( (sjoy.button[EDITOR_ACTION_RETURN]) && (g_editorMode == EDITOR_MODE_MINIMAP)) { |
| 3327 |
|
| 3328 |
if (buf_mode) { |
| 3329 |
//lets replace this screen |
| 3330 |
|
| 3331 |
buf_mode = /*false*/0; |
| 3332 |
|
| 3333 |
|
| 3334 |
if (!load_screen_buf(buffmap.loc[(((spr[1].y+1)*32) / 20)+(spr[1].x / 20)])) { |
| 3335 |
draw_minimap(); |
| 3336 |
sjoy.button[EDITOR_ACTION_RETURN] = /*false*/0; |
| 3337 |
return 2; |
| 3338 |
} |
| 3339 |
|
| 3340 |
|
| 3341 |
g_dmod.map.load(); |
| 3342 |
|
| 3343 |
if (g_dmod.map.loc[(((spr[1].y+1)*32) / 20)+(spr[1].x / 20)] == 0) { |
| 3344 |
|
| 3345 |
( |
| 3346 |
g_dmod.map.loc[(((spr[1].y+1)*32) / 20)+(spr[1].x / 20)]) = add_new_map(); |
| 3347 |
//wrongo, let's add the map |
| 3348 |
|
| 3349 |
//draw_minimap(); |
| 3350 |
|
| 3351 |
|
| 3352 |
} |
| 3353 |
|
| 3354 |
g_dmod.map.indoor[buf_map] = buffmap.indoor[(((spr[1].y+1)*32) / 20)+(spr[1].x / 20)]; |
| 3355 |
g_dmod.map.music[buf_map] = buffmap.music[(((spr[1].y+1)*32) / 20)+(spr[1].x / 20)]; |
| 3356 |
|
| 3357 |
editor_save_screen(g_dmod.map.loc[buf_map]); |
| 3358 |
|
| 3359 |
g_dmod.map.save(); |
| 3360 |
draw_minimap(); |
| 3361 |
return 2; |
| 3362 |
} |
| 3363 |
|
| 3364 |
g_dmod.map.load(); |
| 3365 |
|
| 3366 |
cur_map = (((spr[1].y+1)*32) / 20)+(spr[1].x / 20); |
| 3367 |
if (g_dmod.map.loc[cur_map] == 0) { |
| 3368 |
//new map screen |
| 3369 |
g_dmod.map.loc[cur_map] = add_new_map(); |
| 3370 |
g_dmod.map.save(); |
| 3371 |
} |
| 3372 |
else { |
| 3373 |
editor_load_screen(g_dmod.map.loc[cur_map]); |
| 3374 |
} |
| 3375 |
|
| 3376 |
spr[h].seq = 3; |
| 3377 |
spr[h].seq_orig = 3; |
| 3378 |
k[seq[3].frame[1]].xoffset = -playl; |
| 3379 |
//SoundPlayEffect( SOUND_JUMP ); |
| 3380 |
|
| 3381 |
log_debug("Y is %d X is %d", spr[h].y, spr[h].x); |
| 3382 |
|
| 3383 |
m1x = spr[h].x; |
| 3384 |
m1y = spr[h].y; |
| 3385 |
spr[h].x = m3x; |
| 3386 |
spr[h].y = m3y; |
| 3387 |
|
| 3388 |
|
| 3389 |
g_editorMode = EDITOR_MODE_SCREEN_TILES; |
| 3390 |
|
| 3391 |
spr[h].speed = 50; |
| 3392 |
draw_screen_editor(); |
| 3393 |
} |
| 3394 |
|
| 3395 |
|
| 3396 |
|
| 3397 |
/* Cycle the current tile square (displayed at the bottom-right) */ |
| 3398 |
if ((g_editorMode == EDITOR_MODE_SCREEN_TILES) |
| 3399 |
&& (input_getscancodestate(SDL_SCANCODE_PAGEUP) || input_getscancodestate(SDL_SCANCODE_MINUS))) { |
| 3400 |
spr[h].seq = 3; |
| 3401 |
spr[h].seq_orig = 3; |
| 3402 |
cur_tile--; |
| 3403 |
if (cur_tile < 0) cur_tile = 0; |
| 3404 |
} |
| 3405 |
if ((g_editorMode == EDITOR_MODE_SCREEN_TILES) |
| 3406 |
&& (input_getscancodestate(SDL_SCANCODE_PAGEDOWN) || input_getscancodestate(SDL_SCANCODE_EQUALS))) { |
| 3407 |
spr[h].seq = 3; |
| 3408 |
spr[h].seq_orig = 3; |
| 3409 |
|
| 3410 |
cur_tile++; |
| 3411 |
//if (cur_tile > 127) cur_tile = 127; |
| 3412 |
} |
| 3413 |
|
| 3414 |
|
| 3415 |
if ((g_editorMode == EDITOR_MODE_SCREEN_TILES) && (input_getcharjustpressed(SDLK_h))) { |
| 3416 |
//start althard mode |
| 3417 |
|
| 3418 |
g_editorMode = EDITOR_MODE_SCREEN_HARDNESS_INIT; |
| 3419 |
return 1; // goto skip_draw; |
| 3420 |
} |
| 3421 |
|
| 3422 |
if (g_editorMode == EDITOR_MODE_SCREEN_HARDNESS) { |
| 3423 |
//mode for it |
| 3424 |
if (input_getscancodejustpressed(SDL_SCANCODE_ESCAPE)) { |
| 3425 |
//exit mode 8 |
| 3426 |
g_editorMode = EDITOR_MODE_SCREEN_TILES; |
| 3427 |
spr[h].seq = 3; |
| 3428 |
spr[h].seq_orig = 3; |
| 3429 |
draw_screen_editor(); |
| 3430 |
return 0; |
| 3431 |
} |
| 3432 |
|
| 3433 |
/* if (sjoy.keyjustpressed[/\* VK_OEM_4 *\/ 219]) // '[' for US */ |
| 3434 |
if (input_getscancodejustpressed(SDL_SCANCODE_PAGEUP) || input_getscancodejustpressed(SDL_SCANCODE_LEFTBRACKET)) { |
| 3435 |
hard_tile--; |
| 3436 |
if (hard_tile < 0) hard_tile = 799; |
| 3437 |
} |
| 3438 |
/* if (sjoy.keyjustpressed[/\* VK_OEM_6 *\/ 221]) // ']' for US */ |
| 3439 |
if (input_getscancodejustpressed(SDL_SCANCODE_PAGEDOWN) || input_getscancodejustpressed(SDL_SCANCODE_RIGHTBRACKET)) { |
| 3440 |
hard_tile++; |
| 3441 |
if (hard_tile > 799) hard_tile = 0; |
| 3442 |
} |
| 3443 |
|
| 3444 |
if (input_getcharjustpressed(SDLK_c)) { |
| 3445 |
//copy tile hardness from current block |
| 3446 |
hard_tile = realhard(xy2screentile(spr[1].x, spr[1].y)); |
| 3447 |
} |
| 3448 |
|
| 3449 |
if (input_getcharjustpressed(SDLK_s)) { |
| 3450 |
//stamp tile hardness to selected |
| 3451 |
cur_ed_screen.t[(((spr[1].y+1)*12) / 50)+(spr[1].x / 50)].althard = hard_tile; |
| 3452 |
draw_screen_editor(); |
| 3453 |
g_editorMode = EDITOR_MODE_SCREEN_HARDNESS_INIT; |
| 3454 |
|
| 3455 |
return 2; |
| 3456 |
} |
| 3457 |
|
| 3458 |
if (input_getscancodejustpressed(SDL_SCANCODE_DELETE)) { |
| 3459 |
//stamp tile hardness to selected |
| 3460 |
cur_ed_screen.t[(((spr[1].y+1)*12) / 50)+(spr[1].x / 50)].althard = 0; |
| 3461 |
draw_screen_editor(); |
| 3462 |
g_editorMode = EDITOR_MODE_SCREEN_HARDNESS_INIT; |
| 3463 |
|
| 3464 |
return 2; |
| 3465 |
} |
| 3466 |
|
| 3467 |
/* Display the hard tile in the clipboard */ |
| 3468 |
char crapa[20]; |
| 3469 |
sprintf(crapa, "Copy: %d",hard_tile); |
| 3470 |
SaySmall(crapa, 580,400, 255,255,255); |
| 3471 |
|
| 3472 |
draw_hard_tile(spr[1].x,spr[1].y, hard_tile); |
| 3473 |
|
| 3474 |
if (input_getscancodejustpressed(SDL_SCANCODE_RETURN)) { |
| 3475 |
//they want to edit this alt hardness, let's do it |
| 3476 |
cur_tile = cur_ed_screen.t[xy2screentile(spr[1].x, spr[1].y)].square_full_idx0; |
| 3477 |
|
| 3478 |
xx = cur_tile - (cool * 128); |
| 3479 |
Rect.left = spr[1].x+20; |
| 3480 |
Rect.top = spr[1].y; |
| 3481 |
Rect.right = Rect.left + 50; |
| 3482 |
Rect.bottom = Rect.top + 50; |
| 3483 |
|
| 3484 |
/* crapRec.top = 0; */ |
| 3485 |
/* crapRec.left = 95; */ |
| 3486 |
/* crapRec.bottom = 450; */ |
| 3487 |
/* crapRec.right = 95+450; */ |
| 3488 |
|
| 3489 |
/* ZeroMemory(&ddbltfx, sizeof(ddbltfx)); */ |
| 3490 |
/* ddbltfx.dwSize = sizeof( ddbltfx); */ |
| 3491 |
spr[1].seq = 0; |
| 3492 |
spr[1].pseq = 10; |
| 3493 |
spr[1].pframe = 1; |
| 3494 |
|
| 3495 |
|
| 3496 |
/* lpDDSTwo->Blt(&crapRec , lpDDSBack, */ |
| 3497 |
/* &Rect, DDBLT_DDFX | DDBLT_WAIT,&ddbltfx ); */ |
| 3498 |
// GFX |
| 3499 |
/* In this particular case, we're scaling |
| 3500 |
the whole screen backbuffer by 900% |
| 3501 |
just to scale a single 50x50 square of |
| 3502 |
it... */ |
| 3503 |
{ |
| 3504 |
SDL_Rect src, dst; |
| 3505 |
src.x = spr[1].x+20; |
| 3506 |
src.y = spr[1].y; |
| 3507 |
src.w = 50; |
| 3508 |
src.h = 50; |
| 3509 |
dst.x = 95; |
| 3510 |
dst.y = 0; |
| 3511 |
dst.w = 450; |
| 3512 |
dst.h = 450; |
| 3513 |
IOGFX_background->blitStretch(IOGFX_backbuffer, &src, &dst); |
| 3514 |
} |
| 3515 |
|
| 3516 |
m4x = spr[h].x; |
| 3517 |
m4y = spr[h].y; |
| 3518 |
|
| 3519 |
spr[1].x = 95; |
| 3520 |
spr[1].y = 0; |
| 3521 |
selx = 1; |
| 3522 |
sely = 1; |
| 3523 |
|
| 3524 |
g_editorMode = EDITOR_MODE_TILE_HARDNESS; |
| 3525 |
|
| 3526 |
hmap.htile[hard_tile].used = /*true*/1; |
| 3527 |
last_modereal = 8; |
| 3528 |
} |
| 3529 |
} |
| 3530 |
|
| 3531 |
if ((g_editorMode == EDITOR_MODE_SCREEN_TILES) |
| 3532 |
&& (SDL_GetModState()&KMOD_ALT) |
| 3533 |
&& input_getcharjustpressed(SDLK_x)) { |
| 3534 |
spr[h].seq = 2; |
| 3535 |
spr[h].seq_orig = 2; |
| 3536 |
m3x = spr[h].x; |
| 3537 |
m3y = spr[h].y; |
| 3538 |
spr[h].x = m1x; |
| 3539 |
spr[h].y = m1y; |
| 3540 |
g_editorMode = EDITOR_MODE_MINIMAP; |
| 3541 |
spr[h].speed = 20; |
| 3542 |
g_dmod.map.load(); |
| 3543 |
draw_minimap(); |
| 3544 |
lsm_kill_all_nonlive_sprites(); |
| 3545 |
return 2; |
| 3546 |
} |
| 3547 |
|
| 3548 |
if ((g_editorMode == EDITOR_MODE_SCREEN_TILES) && (sjoy.button[EDITOR_ACTION_ESCAPE])) { |
| 3549 |
// jump to map selector selector from map mode |
| 3550 |
editor_save_screen(g_dmod.map.loc[cur_map]); |
| 3551 |
spr[h].seq = 2; |
| 3552 |
spr[h].seq_orig = 2; |
| 3553 |
//SoundPlayEffect( SOUND_JUMP ); |
| 3554 |
m3x = spr[h].x; |
| 3555 |
m3y = spr[h].y; |
| 3556 |
//Msg("m1y is %d, math is %d",m1y, (20 * (m1y / 20)) < m1y); |
| 3557 |
spr[h].x = m1x; |
| 3558 |
spr[h].y = m1y; |
| 3559 |
g_editorMode = EDITOR_MODE_MINIMAP; |
| 3560 |
spr[h].speed = 20; |
| 3561 |
g_dmod.map.load(); |
| 3562 |
draw_minimap(); |
| 3563 |
lsm_kill_all_nonlive_sprites(); |
| 3564 |
return 2; |
| 3565 |
} |
| 3566 |
|
| 3567 |
|
| 3568 |
if (input_getscancodestate(SDL_SCANCODE_LEFT)) { |
| 3569 |
spr[h].x -= spr[h].speed; |
| 3570 |
spr[h].seq = spr[h].seq_orig; |
| 3571 |
EditorSoundPlayEffect(SOUND_STOP); |
| 3572 |
} |
| 3573 |
|
| 3574 |
if (input_getscancodestate(SDL_SCANCODE_DOWN)) { |
| 3575 |
spr[h].y += spr[h].speed; |
| 3576 |
spr[h].seq = spr[h].seq_orig; |
| 3577 |
EditorSoundPlayEffect(SOUND_STOP); |
| 3578 |
} |
| 3579 |
|
| 3580 |
if (input_getscancodestate(SDL_SCANCODE_UP)) { |
| 3581 |
spr[h].y -= spr[h].speed; |
| 3582 |
spr[h].seq = spr[h].seq_orig; |
| 3583 |
EditorSoundPlayEffect(SOUND_STOP); |
| 3584 |
} |
| 3585 |
|
| 3586 |
if (spr[h].speed < 1) |
| 3587 |
spr[h].speed = 1; |
| 3588 |
if (spr[h].y > (y - k[getpic(h)].box.bottom)) |
| 3589 |
spr[h].y = y - k[getpic(h)].box.bottom; |
| 3590 |
if (spr[h].x > (x - k[getpic(h)].box.right)) |
| 3591 |
spr[h].x = x - k[getpic(h)].box.right; |
| 3592 |
if (spr[h].x < 0) |
| 3593 |
spr[h].x = 0; |
| 3594 |
if (spr[h].y < 0) |
| 3595 |
spr[h].y = 0; |
| 3596 |
|
| 3597 |
// end human brain (1) |
| 3598 |
|
| 3599 |
|
| 3600 |
if ((g_editorMode == EDITOR_MODE_TILE_PICKER) || (g_editorMode == EDITOR_MODE_SCREEN_TILES) |
| 3601 |
|| (g_editorMode == EDITOR_MODE_SPRITE_PICKER) || (g_editorMode == EDITOR_MODE_SCREEN_HARDNESS)) { |
| 3602 |
if ((selx * 50 + spr[1].x) > 600) { |
| 3603 |
spr[1].x = 600 - (selx * 50); |
| 3604 |
} |
| 3605 |
} |
| 3606 |
|
| 3607 |
if ((g_editorMode == EDITOR_MODE_TILE_PICKER)) { |
| 3608 |
if ((sely * 50 + spr[1].y) > 450) { |
| 3609 |
spr[1].y = 450 - (sely * 50); |
| 3610 |
} |
| 3611 |
} |
| 3612 |
if ((g_editorMode == EDITOR_MODE_SCREEN_TILES) || (g_editorMode == EDITOR_MODE_SPRITE_PICKER) |
| 3613 |
|| (g_editorMode == EDITOR_MODE_SCREEN_HARDNESS)) { |
| 3614 |
if ((sely * 50 + spr[1].y) > 400) { |
| 3615 |
spr[1].y = 400 - (sely * 50); |
| 3616 |
} |
| 3617 |
} |
| 3618 |
} //end if seq is 0 |
| 3619 |
return 0; |
| 3620 |
} |
| 3621 |
|
| 3622 |
/** |
| 3623 |
* updateFrame |
| 3624 |
* |
| 3625 |
* Decide what needs to be blitted next, wait for flip to complete, |
| 3626 |
* then flip the buffers. |
| 3627 |
*/ |
| 3628 |
void AppFreeDinkedit::logic(void) |
| 3629 |
{ |
| 3630 |
// static DWORD lastTickCount[4] = {0,0,0,0}; |
| 3631 |
// static int currentFrame[3] = {0,0,0}; |
| 3632 |
// char buffer[20]; |
| 3633 |
rect rcRect; |
| 3634 |
/* rect rcRectSrc; */ |
| 3635 |
/* rect rcRectDest; */ |
| 3636 |
rect box_crap,box_real; |
| 3637 |
/* POINT p; */ |
| 3638 |
char msg[500]; |
| 3639 |
char buff[200]; |
| 3640 |
// DWORD delay[4] = {0, 0, 0, 20}; |
| 3641 |
/* HDC hdc; */ |
| 3642 |
int in_crap2 = 0; |
| 3643 |
//PALETTEENTRY pe[256]; |
| 3644 |
/* HRESULT ddrval; */ |
| 3645 |
/* DDBLTFX ddbltfx; */ |
| 3646 |
/*BOOL*/int bs[MAX_SPRITES_AT_ONCE]; |
| 3647 |
|
| 3648 |
int rank[MAX_SPRITES_AT_ONCE]; |
| 3649 |
int highest_sprite; |
| 3650 |
|
| 3651 |
int jj; |
| 3652 |
|
| 3653 |
SDL_framerateDelay(&framerate_manager); |
| 3654 |
|
| 3655 |
// Decide which frame will be blitted next |
| 3656 |
Uint32 thisTickCount = SDL_GetTicks(); |
| 3657 |
strcpy(buff,"Nothing"); |
| 3658 |
check_joystick(); |
| 3659 |
//Scrawl_OnMouseInput(); |
| 3660 |
rcRect.left = 0; |
| 3661 |
rcRect.top = 0; |
| 3662 |
rcRect.right = x; |
| 3663 |
rcRect.bottom = y; |
| 3664 |
|
| 3665 |
if (draw_screen_tiny != -1) |
| 3666 |
{ |
| 3667 |
|
| 3668 |
tiny_again: |
| 3669 |
if (draw_screen_tiny == 769) |
| 3670 |
{ |
| 3671 |
draw_screen_tiny = -1; |
| 3672 |
lsm_kill_all_nonlive_sprites(); |
| 3673 |
//all done |
| 3674 |
} else |
| 3675 |
{ |
| 3676 |
|
| 3677 |
|
| 3678 |
draw_screen_tiny++; |
| 3679 |
|
| 3680 |
copy_front_to_two(); |
| 3681 |
|
| 3682 |
|
| 3683 |
if (g_dmod.map.loc[draw_screen_tiny] != 0) |
| 3684 |
{ |
| 3685 |
//a map exists here |
| 3686 |
editor_load_screen(g_dmod.map.loc[draw_screen_tiny]); |
| 3687 |
//map loaded, lets display it |
| 3688 |
draw_screen_editor(); |
| 3689 |
|
| 3690 |
goto pass_flip; |
| 3691 |
} else goto tiny_again; |
| 3692 |
|
| 3693 |
|
| 3694 |
|
| 3695 |
} |
| 3696 |
|
| 3697 |
} |
| 3698 |
|
| 3699 |
|
| 3700 |
/* while( 1 ) */ |
| 3701 |
/* { */ |
| 3702 |
/* ddrval = lpDDSBack->BltFast( 0, 0, lpDDSTwo, */ |
| 3703 |
/* &rcRect, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); */ |
| 3704 |
// GFX |
| 3705 |
IOGFX_backbuffer->blit(IOGFX_background, NULL, NULL); |
| 3706 |
|
| 3707 |
|
| 3708 |
/* if( ddrval == DD_OK ) */ |
| 3709 |
/* { */ |
| 3710 |
/* break; */ |
| 3711 |
/* } */ |
| 3712 |
/* if( ddrval == DDERR_SURFACELOST ) */ |
| 3713 |
/* { */ |
| 3714 |
/* ddrval = restoreAll(); */ |
| 3715 |
/* if( ddrval != DD_OK ) */ |
| 3716 |
/* { */ |
| 3717 |
/* return; */ |
| 3718 |
/* } */ |
| 3719 |
/* } */ |
| 3720 |
/* if( ddrval != DDERR_WASSTILLDRAWING ) */ |
| 3721 |
/* { */ |
| 3722 |
/* return; */ |
| 3723 |
/* } */ |
| 3724 |
|
| 3725 |
/* } */ |
| 3726 |
|
| 3727 |
pass_flip: |
| 3728 |
|
| 3729 |
memset(&bs,0,sizeof(bs)); |
| 3730 |
|
| 3731 |
int max_s = 105; |
| 3732 |
|
| 3733 |
//max_sprites_at_once; |
| 3734 |
|
| 3735 |
/*for (int r2 = 1; r2 < max_sprites_at_once; r2++) |
| 3736 |
{ |
| 3737 |
if (spr[r2].active) max_s = r2+1; |
| 3738 |
} |
| 3739 |
*/ |
| 3740 |
int height; |
| 3741 |
|
| 3742 |
|
| 3743 |
|
| 3744 |
spr[1].que = 20000; |
| 3745 |
if (g_editorMode == EDITOR_MODE_SCREEN_SPRITES) if ( ! ((spr[1].pseq == 10) && (spr[1].pframe == 8)) ) spr[1].que = sp_que; |
| 3746 |
|
| 3747 |
if (!in_enabled) |
| 3748 |
{ |
| 3749 |
int r1; |
| 3750 |
for (r1 = 1; r1 < max_s+1; r1++) |
| 3751 |
{ |
| 3752 |
int h1; |
| 3753 |
highest_sprite = 22024; //more than it could ever be |
| 3754 |
|
| 3755 |
rank[r1] = 0; |
| 3756 |
|
| 3757 |
for (h1 = 1; h1 < max_s+1; h1++) |
| 3758 |
{ |
| 3759 |
if (spr[h1].active) |
| 3760 |
{ |
| 3761 |
if (bs[h1] == /*FALSE*/0) |
| 3762 |
{ |
| 3763 |
//Msg( "Ok, %d is %d", h1,(spr[h1].y + k[spr[h1].pic].yoffset) ); |
| 3764 |
if (spr[h1].que != 0) height = spr[h1].que; else height = spr[h1].y; |
| 3765 |
if ( height < highest_sprite ) |
| 3766 |
{ |
| 3767 |
highest_sprite = height; |
| 3768 |
rank[r1] = h1; |
| 3769 |
} |
| 3770 |
|
| 3771 |
} |
| 3772 |
|
| 3773 |
} |
| 3774 |
|
| 3775 |
} |
| 3776 |
if (rank[r1] != 0) |
| 3777 |
bs[rank[r1]] = /*TRUE*/1; |
| 3778 |
} |
| 3779 |
} |
| 3780 |
|
| 3781 |
|
| 3782 |
|
| 3783 |
|
| 3784 |
|
| 3785 |
if (!in_enabled) |
| 3786 |
|
| 3787 |
for (jj = 1; jj < max_s; jj++) |
| 3788 |
{ |
| 3789 |
|
| 3790 |
int h = rank[jj]; |
| 3791 |
//Msg("Studying %d.,",h); |
| 3792 |
|
| 3793 |
if (spr[h].active) |
| 3794 |
{ |
| 3795 |
|
| 3796 |
// Msg("Sprite %d is active.",h); |
| 3797 |
|
| 3798 |
int greba = 0; |
| 3799 |
|
| 3800 |
if (spr[h].brain == 1) |
| 3801 |
{ |
| 3802 |
int state = gui_logic(h); |
| 3803 |
if (state == 1) |
| 3804 |
goto skip_draw; |
| 3805 |
else if (state == 2) |
| 3806 |
return; |
| 3807 |
} //real end of human brain |
| 3808 |
|
| 3809 |
|
| 3810 |
if (spr[h].brain == 2) |
| 3811 |
{ |
| 3812 |
if (spr[h].y > (y-k[getpic(h)].box.bottom)) |
| 3813 |
{ |
| 3814 |
spr[h].my -= (spr[h].my * 2); |
| 3815 |
// SoundPlayEffect( SOUND_JUMP ); |
| 3816 |
} |
| 3817 |
|
| 3818 |
if (spr[h].x > (x-k[getpic(h)].box.right)) |
| 3819 |
{ |
| 3820 |
spr[h].mx -= (spr[h].mx * 2); |
| 3821 |
//SoundPlayEffect( SOUND_JUMP ); |
| 3822 |
} |
| 3823 |
|
| 3824 |
if (spr[h].y < 0) |
| 3825 |
{ |
| 3826 |
spr[h].my -= (spr[h].my * 2); |
| 3827 |
//SoundPlayEffect( SOUND_JUMP ); |
| 3828 |
} |
| 3829 |
|
| 3830 |
|
| 3831 |
if (spr[h].x < 0) |
| 3832 |
{ |
| 3833 |
spr[h].mx -= (spr[h].mx * 2); |
| 3834 |
//SoundPlayEffect( SOUND_JUMP ); |
| 3835 |
} |
| 3836 |
|
| 3837 |
|
| 3838 |
spr[h].x += spr[h].mx; |
| 3839 |
spr[h].y += spr[h].my; |
| 3840 |
|
| 3841 |
|
| 3842 |
} |
| 3843 |
// end robot(2) |
| 3844 |
|
| 3845 |
|
| 3846 |
// Cursor speed through game-compatible, 3-frames seq |
| 3847 |
if (spr[h].seq > 0) |
| 3848 |
{ |
| 3849 |
if (spr[h].frame < 1) |
| 3850 |
{ |
| 3851 |
// Cursor change |
| 3852 |
spr[h].pseq = spr[h].seq; |
| 3853 |
spr[h].pframe = 1; |
| 3854 |
|
| 3855 |
spr[h].frame = 1; |
| 3856 |
spr[h].delay = (thisTickCount + seq[spr[h].seq].delay[1]); |
| 3857 |
} |
| 3858 |
else |
| 3859 |
{ |
| 3860 |
// not new anim |
| 3861 |
//is it time? |
| 3862 |
if (thisTickCount > spr[h].delay) |
| 3863 |
{ |
| 3864 |
spr[h].frame++; |
| 3865 |
spr[h].delay = (thisTickCount + seq[spr[h].seq].delay[spr[h].frame]); |
| 3866 |
|
| 3867 |
spr[h].pseq = spr[h].seq; |
| 3868 |
spr[h].pframe = spr[h].frame; |
| 3869 |
|
| 3870 |
if (seq[spr[h].seq].frame[spr[h].frame] == -1) |
| 3871 |
{ |
| 3872 |
spr[h].frame = 1; |
| 3873 |
spr[h].pseq = spr[h].seq; |
| 3874 |
spr[h].pframe = spr[h].frame; |
| 3875 |
spr[h].delay = (thisTickCount + seq[spr[h].seq].delay[spr[h].frame]); |
| 3876 |
} |
| 3877 |
|
| 3878 |
if (seq[spr[h].seq].frame[spr[h].frame] == 0) |
| 3879 |
{ |
| 3880 |
spr[h].pseq = spr[h].seq; |
| 3881 |
spr[h].pframe = spr[h].frame-1; |
| 3882 |
|
| 3883 |
spr[h].frame = 0; |
| 3884 |
spr[h].seq = 0; |
| 3885 |
} |
| 3886 |
} |
| 3887 |
} |
| 3888 |
} |
| 3889 |
|
| 3890 |
|
| 3891 |
if (g_editorMode == EDITOR_MODE_SCREEN_TILES) |
| 3892 |
{ |
| 3893 |
//need offset to look right |
| 3894 |
k[seq[3].frame[1]].xoffset = -20; |
| 3895 |
greba = 20; |
| 3896 |
} |
| 3897 |
if (g_editorMode == EDITOR_MODE_TILE_PICKER || g_editorMode == EDITOR_MODE_SPRITE_PICKER) |
| 3898 |
{ |
| 3899 |
//pick a tile, needs no offset |
| 3900 |
k[seq[3].frame[1]].xoffset = 0; |
| 3901 |
greba = 0; |
| 3902 |
} |
| 3903 |
|
| 3904 |
// if ( !(( h == 1) & (mode == 9)) ) |
| 3905 |
if (!((h == 1) && (g_editorMode == EDITOR_MODE_SCREEN_HARDNESS_INIT))) |
| 3906 |
{ |
| 3907 |
if (draw_screen_tiny == -1) |
| 3908 |
draw_sprite(IOGFX_backbuffer, h); |
| 3909 |
else |
| 3910 |
draw_sprite(IOGFX_background, h); |
| 3911 |
} |
| 3912 |
|
| 3913 |
//Msg("Drew %d.",h); |
| 3914 |
|
| 3915 |
skip_draw: |
| 3916 |
if (spr[h].brain == 1) |
| 3917 |
{ |
| 3918 |
if (g_editorMode == EDITOR_MODE_SCREEN_TILES || g_editorMode == EDITOR_MODE_TILE_PICKER) |
| 3919 |
{ |
| 3920 |
/* Draw the tile squares selector, an expandable |
| 3921 |
array of white non-filled squares */ |
| 3922 |
int y; |
| 3923 |
for (y = 0; y < sely; y++) |
| 3924 |
{ |
| 3925 |
int x; |
| 3926 |
for (x = 0; x < selx; x++) |
| 3927 |
{ |
| 3928 |
/* ddrval = lpDDSBack->BltFast( (spr[h].x+(50 *x))+greba,spr[h].y+(50 * y), k[getpic(h)].k, */ |
| 3929 |
/* &k[getpic(h)].box , DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT ); */ |
| 3930 |
// GFX |
| 3931 |
{ |
| 3932 |
SDL_Rect dst; |
| 3933 |
dst.x = spr[h].x + 50*x + greba; |
| 3934 |
dst.y = spr[h].y + 50*y; |
| 3935 |
IOGFX_backbuffer->blit(GFX_k[getpic(h)].k, NULL, &dst); |
| 3936 |
} |
| 3937 |
} |
| 3938 |
} |
| 3939 |
} |
| 3940 |
|
| 3941 |
|
| 3942 |
if ((g_editorMode == EDITOR_MODE_TILE_HARDNESS)) |
| 3943 |
{ |
| 3944 |
/* Display the current "pencil"/square to draw hardness with */ |
| 3945 |
int yy; |
| 3946 |
for (yy = 0; yy < sely; yy++) |
| 3947 |
{ |
| 3948 |
int xx; |
| 3949 |
for (xx = 0; xx < selx; xx++) |
| 3950 |
{ |
| 3951 |
/* ddrval = lpDDSBack->BltFast( spr[h].x+(9 * xx),spr[h].y+(9 * yy), k[getpic(h)].k, */ |
| 3952 |
/* &k[getpic(h)].box , DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT ); */ |
| 3953 |
// GFX |
| 3954 |
{ |
| 3955 |
SDL_Rect dst; |
| 3956 |
dst.x = spr[h].x + 9*xx; |
| 3957 |
dst.y = spr[h].y + 9*yy; |
| 3958 |
IOGFX_backbuffer->blit(GFX_k[getpic(h)].k, NULL, &dst); |
| 3959 |
} |
| 3960 |
} |
| 3961 |
} |
| 3962 |
} |
| 3963 |
} |
| 3964 |
} |
| 3965 |
} |
| 3966 |
|
| 3967 |
|
| 3968 |
if (g_editorMode == EDITOR_MODE_SCREEN_HARDNESS_INIT) |
| 3969 |
{ |
| 3970 |
g_editorMode = EDITOR_MODE_SCREEN_HARDNESS; |
| 3971 |
|
| 3972 |
fill_whole_hard(); |
| 3973 |
lsm_kill_all_nonlive_sprites(); |
| 3974 |
place_sprites(); |
| 3975 |
|
| 3976 |
/* draw_screen_editor(); |
| 3977 |
|
| 3978 |
|
| 3979 |
rcRect.top = 0; |
| 3980 |
rcRect.right = x; |
| 3981 |
rcRect.bottom = y; |
| 3982 |
ddrval = lpDDSBack->BltFast( 0, 0, lpDDSTwo, |
| 3983 |
&rcRect, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); |
| 3984 |
*/ |
| 3985 |
drawallhard(); |
| 3986 |
|
| 3987 |
rcRect.left = 0; |
| 3988 |
rcRect.right = 640; |
| 3989 |
rcRect.top = 0; |
| 3990 |
rcRect.bottom = 400; |
| 3991 |
/* ddrval = lpDDSTwo->BltFast( 0, 0, lpDDSBack, */ |
| 3992 |
/* &rcRect, DDBLTFAST_NOCOLORKEY | DDBLTFAST_WAIT); */ |
| 3993 |
/* if (ddrval != DD_OK) dderror(ddrval); */ |
| 3994 |
// GFX |
| 3995 |
IOGFX_background->blit(IOGFX_backbuffer, NULL, NULL); |
| 3996 |
|
| 3997 |
lsm_kill_all_nonlive_sprites(); |
| 3998 |
} |
| 3999 |
|
| 4000 |
|
| 4001 |
//sprintf(msg, "k[1] top is %d",k[1].box.top); |
| 4002 |
|
| 4003 |
//prepare to display misc messages for debug purposes |
| 4004 |
|
| 4005 |
/* if (lpDDSBack->GetDC(&hdc) == DD_OK) */ |
| 4006 |
/* { */ |
| 4007 |
/* SetBkMode(hdc, TRANSPARENT); */ |
| 4008 |
|
| 4009 |
/* // SetBkMode(hdc, OPAQUE); */ |
| 4010 |
/* SetBkColor(hdc, 1); */ |
| 4011 |
/* SetTextColor(hdc,RGB(200,200,200)); */ |
| 4012 |
FONTS_SetTextColor(200, 200, 200); |
| 4013 |
|
| 4014 |
// TextOut(hdc,0,0, msg,lstrlen(msg)); |
| 4015 |
// if (mode == 0) strcpy(msg,""); |
| 4016 |
if (g_editorMode == EDITOR_MODE_INIT) |
| 4017 |
strcpy(msg,""); |
| 4018 |
|
| 4019 |
if (g_editorMode == EDITOR_MODE_MINIMAP) |
| 4020 |
{ |
| 4021 |
if (20 * (spr[1].y / 20) != spr[1].y) |
| 4022 |
{ |
| 4023 |
spr[1].y += 10; |
| 4024 |
} |
| 4025 |
sprintf(msg, |
| 4026 |
"Map # %d - Press ENTER to edit, SPACE to detail map. (%d) (Q) to quit and save. L to replace a " |
| 4027 |
"screen from another map file. Z to toggle this help text. S to modify screentype. M to modify midi.", |
| 4028 |
g_editorMode, |
| 4029 |
(((spr[1].y+1)*32) / 20)+(spr[1].x / 20)); |
| 4030 |
/* g_dmod.map.loc[(((spr[1].y+1)*32) / 20)+(spr[1].x / 20) ]); */ |
| 4031 |
} |
| 4032 |
if (g_editorMode == EDITOR_MODE_SCREEN_TILES) |
| 4033 |
{ |
| 4034 |
//((x-1) - (x / 12))*50, (x / 12) * 50, |
| 4035 |
sprintf(msg, |
| 4036 |
"Map # %d, (C)opy or (S)tamp tile. ESC to exit to map picker. ENTER to edit hardness. TAB for sprite edit mode. 1-10 for tilescreens. (hold alt, crtl or shift for more) SPACE to show hardness of screen. (I)nfo on sprites." |
| 4037 |
" V to change vision, B to change maps base .C file, H to edit tile hardness.", |
| 4038 |
g_editorMode); |
| 4039 |
/* cur_map, */ |
| 4040 |
/* cur_tile, */ |
| 4041 |
/* cur_ed_screen.t[crap].num); */ |
| 4042 |
} |
| 4043 |
if (g_editorMode == EDITOR_MODE_TILE_PICKER) |
| 4044 |
sprintf(msg, |
| 4045 |
"Map # %d - Current tile # %d - ENTER to choose, SPACE to edit hardness.", |
| 4046 |
g_editorMode, |
| 4047 |
cur_map); |
| 4048 |
/* (((spr[1].y+1)*12) / 50)+(spr[1].x / 50)); */ |
| 4049 |
if (g_editorMode == EDITOR_MODE_TILE_HARDNESS) |
| 4050 |
{ |
| 4051 |
sprintf(msg, "X:%d Y:%d: Density index %d Z to harden, X to soften, A for low-hard, S for ???.\n" |
| 4052 |
"Alt+X/A/S to fill hardness. Shift+direction for larger brush. ENTER or ESC to exit.", |
| 4053 |
(spr[1].x / 9) -9,(spr[1].y / 9) +1, hard_tile); |
| 4054 |
} |
| 4055 |
|
| 4056 |
if (g_editorMode == EDITOR_MODE_SPRITE_PICKER) |
| 4057 |
{ |
| 4058 |
|
| 4059 |
if (sp_seq == 0) |
| 4060 |
{ |
| 4061 |
sprintf(msg, "Choose sequence and press ENTER. PageDown for next page, PageUp for previous. ESC or TAB to exit. (now on page %d)", |
| 4062 |
1+(sp_picker / 96)); |
| 4063 |
} else |
| 4064 |
{ |
| 4065 |
sprintf(msg, "Choose a sprite from sequence %d. Enter to place sprite, TAB to exit or ESC to return to previous screen." |
| 4066 |
" E to edit depth dot and hardbox", |
| 4067 |
sp_seq); |
| 4068 |
|
| 4069 |
} |
| 4070 |
} |
| 4071 |
|
| 4072 |
if (g_editorMode == EDITOR_MODE_SCREEN_SPRITES) |
| 4073 |
{ |
| 4074 |
|
| 4075 |
char crap7[80]; |
| 4076 |
if (sp_screenmatch) strcpy(crap7, "ScreenMatch is ON."); else strcpy(crap7, "ScreenMatch is OFF"); |
| 4077 |
|
| 4078 |
sprintf(msg, "Press ENTER to pickup/putdown sprite. Space to show hardness. E to edit/pick new sprite. SHIFT to move fast. (S)tamp sprite. PageUp&" |
| 4079 |
"PageDown to scale (now at %d). DEL to erase sprite. Press 1 through 9 to change sprite attributes. (hold alt or shift for more) Last sprite touched: %d %s (M to toggle)" |
| 4080 |
"Hold Z or X + arrow keys to trim a sprite. V to change Vision mode. X: %d Y: %d", |
| 4081 |
spr[1].size,last_sprite_added,crap7, spr[1].x, spr[1].y); |
| 4082 |
|
| 4083 |
//lets draw the depth dot |
| 4084 |
|
| 4085 |
|
| 4086 |
|
| 4087 |
|
| 4088 |
} |
| 4089 |
|
| 4090 |
|
| 4091 |
if (g_editorMode == EDITOR_MODE_SPRITE_HARDNESS) |
| 4092 |
{ |
| 4093 |
|
| 4094 |
|
| 4095 |
if (sp_mode == 0) |
| 4096 |
{ |
| 4097 |
sprintf(msg, "Editing depth dot for Seq %d, frame %d. SHIFT to move fast. Control to move one" |
| 4098 |
" pixel. TAB for next edit option. ESC to return to sprite picker. S to save to dink.ini.", |
| 4099 |
sp_seq,sp_frame); |
| 4100 |
|
| 4101 |
} |
| 4102 |
|
| 4103 |
if ( (sp_mode == 1) ) |
| 4104 |
|
| 4105 |
{ |
| 4106 |
sprintf(msg, "Editing hardbox up left cordinate for Seq %d, frame %d. SHIFT to move fast. Control to move one" |
| 4107 |
" pixel. TAB for next edit option. ESC to return to sprite picker. S to save to dink.ini. X: %d Y: %d", |
| 4108 |
sp_seq,sp_frame, k[seq[sp_seq].frame[sp_frame]].hardbox.left, |
| 4109 |
k[seq[sp_seq].frame[sp_frame]].hardbox.top); |
| 4110 |
|
| 4111 |
} |
| 4112 |
|
| 4113 |
if ( (sp_mode == 2) ) |
| 4114 |
|
| 4115 |
{ |
| 4116 |
sprintf(msg, "Editing hardbox down right cordinate for Seq %d, frame %d. SHIFT to move fast. Control to move one" |
| 4117 |
" pixel. TAB for next edit option. ESC to return to sprite picker. S to save to dink.ini. X: %d Y: %d", |
| 4118 |
sp_seq,sp_frame, k[seq[sp_seq].frame[sp_frame]].hardbox.right, |
| 4119 |
k[seq[sp_seq].frame[sp_frame]].hardbox.bottom); |
| 4120 |
|
| 4121 |
} |
| 4122 |
|
| 4123 |
|
| 4124 |
|
| 4125 |
|
| 4126 |
|
| 4127 |
|
| 4128 |
} |
| 4129 |
|
| 4130 |
|
| 4131 |
if (g_editorMode == EDITOR_MODE_SCREEN_HARDNESS) |
| 4132 |
{ |
| 4133 |
int screentile = xy2screentile(spr[1].x, spr[1].y); |
| 4134 |
int sourcetile = cur_ed_screen.t[screentile].square_full_idx0; |
| 4135 |
int defaulthardness = hmap.btile_default[sourcetile]; |
| 4136 |
int curhardness = realhard(screentile); |
| 4137 |
char str[100]; |
| 4138 |
if (defaulthardness == curhardness) |
| 4139 |
sprintf(str, "Current %03d (default %03d tile %03d)", curhardness, defaulthardness, sourcetile); |
| 4140 |
else |
| 4141 |
sprintf(str, "Current %03d (default %03d tile %03d) (alternate)", curhardness, defaulthardness, sourcetile); |
| 4142 |
|
| 4143 |
sprintf(msg, "Alternative Tile Hardness Selector: Press S to stamp this tiles hardness." |
| 4144 |
" DEL to remove alternate hardness." |
| 4145 |
" C to copy from current block." |
| 4146 |
" PageUp&PageDown to cycle.\n" |
| 4147 |
"ESCAPE to exit.\n" |
| 4148 |
"%s", str); |
| 4149 |
} |
| 4150 |
|
| 4151 |
{ |
| 4152 |
int x; |
| 4153 |
for (x = 0; x < 256; x++) |
| 4154 |
{ |
| 4155 |
if (input_getscancodestate((SDL_Scancode)x)) |
| 4156 |
{ |
| 4157 |
sprintf(msg + strlen(msg), " (Scancode %i '%s')", |
| 4158 |
x, |
| 4159 |
//SDL_GetScancodeName(x), |
| 4160 |
SDL_GetKeyName(SDL_GetKeyFromScancode((SDL_Scancode)x))); |
| 4161 |
} |
| 4162 |
} |
| 4163 |
} |
| 4164 |
|
| 4165 |
rcRect.left = 0; |
| 4166 |
rcRect.top = 400; |
| 4167 |
if (g_editorMode == EDITOR_MODE_TILE_HARDNESS) rcRect.top = 450; |
| 4168 |
rcRect.right = 590; |
| 4169 |
rcRect.bottom = 480; |
| 4170 |
if (show_display) |
| 4171 |
{ |
| 4172 |
/* Display help message at the bottom of the screen */ |
| 4173 |
/* DrawText(hdc,msg,lstrlen(msg),&rcRect,DT_WORDBREAK); */ |
| 4174 |
// FONTS |
| 4175 |
print_text_wrap(msg, &rcRect, 0, 0, FONT_SYSTEM); |
| 4176 |
} |
| 4177 |
|
| 4178 |
/* lpDDSBack->ReleaseDC(hdc); */ |
| 4179 |
|
| 4180 |
/* } /\* GetDC(&hdc) *\/ */ |
| 4181 |
|
| 4182 |
|
| 4183 |
if ((g_editorMode == EDITOR_MODE_MINIMAP)) |
| 4184 |
{ |
| 4185 |
if (input_getcharjustpressed(SDLK_z)) |
| 4186 |
{ |
| 4187 |
if (show_display) show_display = /*false*/0; |
| 4188 |
else show_display = /*true*/1; |
| 4189 |
} |
| 4190 |
} |
| 4191 |
|
| 4192 |
|
| 4193 |
if ( (g_editorMode == EDITOR_MODE_SCREEN_SPRITES) | (g_editorMode == EDITOR_MODE_SCREEN_TILES) ) |
| 4194 |
{ |
| 4195 |
/* Show sprites info */ |
| 4196 |
if (input_getcharstate(SDLK_i)) |
| 4197 |
{ |
| 4198 |
int j; |
| 4199 |
for (j = 1; j < 100; j++) |
| 4200 |
{ |
| 4201 |
if (cur_ed_screen.sprite[j].active == /*true*/1) |
| 4202 |
{ |
| 4203 |
|
| 4204 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 4205 |
/* ddbltfx.dwFillColor = 230; */ |
| 4206 |
|
| 4207 |
//info on the sprites sprite info |
| 4208 |
/* int temp = s_index[cur_ed_screen.sprite[j].seq].s + cur_ed_screen.sprite[j].frame; */ |
| 4209 |
|
| 4210 |
|
| 4211 |
int sprite2 = add_sprite_dumb(cur_ed_screen.sprite[j].x,cur_ed_screen.sprite[j].y,0, |
| 4212 |
cur_ed_screen.sprite[j].seq,cur_ed_screen.sprite[j].frame, |
| 4213 |
cur_ed_screen.sprite[j].size); |
| 4214 |
rect_copy(&spr[sprite2].alt , &cur_ed_screen.sprite[j].alt); |
| 4215 |
|
| 4216 |
get_box(sprite2, &box_crap, &box_real, skip_screen_clipping()); |
| 4217 |
|
| 4218 |
lsm_remove_sprite(sprite2); |
| 4219 |
|
| 4220 |
//box_crap.top = box_crap.sprite[j].y - 25; |
| 4221 |
box_crap.bottom = box_crap.top + 50; |
| 4222 |
box_crap.left = box_crap.left + ( (box_crap.right - box_crap.left) / 2); |
| 4223 |
box_crap.right = box_crap.left+ 50; |
| 4224 |
|
| 4225 |
/* ddrval = lpDDSBack->Blt(&box_crap ,k[seq[10].frame[5]].k,&k[seq[10].frame[5]].box, DDBLT_WAIT, &ddbltfx); */ |
| 4226 |
// if (ddrval != DD_OK) dderror(ddrval); |
| 4227 |
// GFX |
| 4228 |
{ |
| 4229 |
SDL_Rect dst; |
| 4230 |
dst.x = box_crap.left; |
| 4231 |
dst.y = box_crap.top; |
| 4232 |
/* Simplified blit, no scaling, the sprite is already 50x50 */ |
| 4233 |
/* We need to avoid transparency though */ |
| 4234 |
IOGFX_backbuffer->blitNoColorKey(GFX_k[seq[10].frame[5]].k, NULL, &dst); |
| 4235 |
} |
| 4236 |
|
| 4237 |
char crap5[200]; |
| 4238 |
|
| 4239 |
char crap6[20]; |
| 4240 |
|
| 4241 |
strcpy(crap6,""); |
| 4242 |
if (cur_ed_screen.sprite[j].hard == 0) strcpy(crap6,"HARD"); |
| 4243 |
|
| 4244 |
sprintf(crap5, "B: %d %s",cur_ed_screen.sprite[j].brain,crap6); |
| 4245 |
|
| 4246 |
if (cur_ed_screen.sprite[j].type == 0) |
| 4247 |
{ |
| 4248 |
|
| 4249 |
SaySmall(crap5,box_crap.left+3,box_crap.top+3,255,255,255); |
| 4250 |
} |
| 4251 |
|
| 4252 |
if (cur_ed_screen.sprite[j].type > 0) |
| 4253 |
{ |
| 4254 |
SaySmall(crap5,box_crap.left+3,box_crap.top+3,255,0,0); |
| 4255 |
} |
| 4256 |
if (strlen(cur_ed_screen.sprite[j].script) > 1) |
| 4257 |
SaySmall(cur_ed_screen.sprite[j].script,box_crap.left+3,box_crap.top+35,255,0,0); |
| 4258 |
|
| 4259 |
sprintf(crap6,"%d",j); |
| 4260 |
|
| 4261 |
SaySmall(crap6,box_crap.left+20,box_crap.top-15,0,255,0); |
| 4262 |
|
| 4263 |
|
| 4264 |
} |
| 4265 |
} |
| 4266 |
} |
| 4267 |
|
| 4268 |
} |
| 4269 |
if (g_editorMode == EDITOR_MODE_SPRITE_HARDNESS) |
| 4270 |
{ |
| 4271 |
/* ddbltfx.dwSize = sizeof(ddbltfx); */ |
| 4272 |
/* ddbltfx.dwFillColor = 230; */ |
| 4273 |
|
| 4274 |
if (sp_mode == 0) |
| 4275 |
{ |
| 4276 |
//draw depth dot for sprite attribute edit |
| 4277 |
|
| 4278 |
/* box_crap.top = spr[2].y; */ |
| 4279 |
/* box_crap.bottom = spr[2].y+1; */ |
| 4280 |
/* box_crap.left = spr[2].x - 20; */ |
| 4281 |
/* box_crap.right = spr[2].x + 20; */ |
| 4282 |
|
| 4283 |
|
| 4284 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL,NULL, DDBLT_COLORFILL| DDBLT_WAIT, &ddbltfx); */ |
| 4285 |
/* if (ddrval != DD_OK) dderror(ddrval); */ |
| 4286 |
// GFX |
| 4287 |
{ |
| 4288 |
SDL_Rect dst; |
| 4289 |
dst.x = spr[2].x - 20; |
| 4290 |
dst.y = spr[2].y; |
| 4291 |
dst.w = 40; |
| 4292 |
dst.h = 1; |
| 4293 |
IOGFX_backbuffer->fillRect(&dst, 41, 0, 49); |
| 4294 |
} |
| 4295 |
|
| 4296 |
/* box_crap.top = spr[2].y-20; */ |
| 4297 |
/* box_crap.bottom = spr[2].y+20; */ |
| 4298 |
/* box_crap.left = spr[2].x; */ |
| 4299 |
/* box_crap.right = spr[2].x +1; */ |
| 4300 |
|
| 4301 |
|
| 4302 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL,NULL, DDBLT_COLORFILL| DDBLT_WAIT, &ddbltfx); */ |
| 4303 |
/* if (ddrval != DD_OK) dderror(ddrval); */ |
| 4304 |
// GFX |
| 4305 |
{ |
| 4306 |
SDL_Rect dst; |
| 4307 |
dst.x = spr[2].x; |
| 4308 |
dst.y = spr[2].y - 20; |
| 4309 |
dst.w = 1; |
| 4310 |
dst.h = 40; |
| 4311 |
IOGFX_backbuffer->fillRect(&dst, 41, 0, 49); |
| 4312 |
} |
| 4313 |
} |
| 4314 |
|
| 4315 |
if ((sp_mode == 1) | (sp_mode == 2) ) |
| 4316 |
{ |
| 4317 |
//draw hardbox dot for sprite attribute edit |
| 4318 |
|
| 4319 |
/* box_crap = k[seq[sp_seq].frame[sp_frame]].hardbox; */ |
| 4320 |
|
| 4321 |
/* OffsetRect(&box_crap,320,200); */ |
| 4322 |
|
| 4323 |
|
| 4324 |
/* ddrval = lpDDSBack->Blt(&box_crap ,NULL,NULL, DDBLT_COLORFILL| DDBLT_WAIT, &ddbltfx); */ |
| 4325 |
/* if (ddrval != DD_OK) Msg("Error with drawing hard block... you know why."); */ |
| 4326 |
// GFX |
| 4327 |
{ |
| 4328 |
SDL_Rect dst; |
| 4329 |
dst.x = k[seq[sp_seq].frame[sp_frame]].hardbox.left + 320; |
| 4330 |
dst.y = k[seq[sp_seq].frame[sp_frame]].hardbox.top + 200; |
| 4331 |
dst.w = k[seq[sp_seq].frame[sp_frame]].hardbox.right - k[seq[sp_seq].frame[sp_frame]].hardbox.left; |
| 4332 |
dst.h = k[seq[sp_seq].frame[sp_frame]].hardbox.bottom - k[seq[sp_seq].frame[sp_frame]].hardbox.top; |
| 4333 |
IOGFX_backbuffer->fillRect(&dst, 41, 0, 49); |
| 4334 |
} |
| 4335 |
} |
| 4336 |
} |
| 4337 |
|
| 4338 |
|
| 4339 |
if (in_enabled) |
| 4340 |
{ |
| 4341 |
//text box is open, lets act accordingly |
| 4342 |
//check_joystick(); |
| 4343 |
if (input_getscancodestate(SDL_SCANCODE_RETURN) || input_getscancodestate(SDL_SCANCODE_KP_ENTER)) |
| 4344 |
{ |
| 4345 |
//exit text mode |
| 4346 |
|
| 4347 |
if (in_command == 2) |
| 4348 |
{ |
| 4349 |
if (in_string != NULL) |
| 4350 |
strcpy(in_string, in_temp); |
| 4351 |
else |
| 4352 |
log_error("Error, in_char pointer not set, can't issue a value."); |
| 4353 |
} |
| 4354 |
|
| 4355 |
if (in_command == 1) |
| 4356 |
{ |
| 4357 |
if (in_int != NULL) |
| 4358 |
{ |
| 4359 |
char *stop; |
| 4360 |
int in_crap = strtol(in_temp, &stop,10); |
| 4361 |
|
| 4362 |
in_crap2 = in_crap; |
| 4363 |
|
| 4364 |
if ((old_command == INPUT_SCREEN_MIDI) || (old_command == INPUT_SCREEN_TYPE)) |
| 4365 |
g_dmod.map.load(); |
| 4366 |
|
| 4367 |
*in_int = in_crap2; |
| 4368 |
|
| 4369 |
if ((old_command == INPUT_SCREEN_MIDI) || (old_command == INPUT_SCREEN_TYPE)) |
| 4370 |
g_dmod.map.save(); |
| 4371 |
} |
| 4372 |
else |
| 4373 |
{ |
| 4374 |
log_error("in_int pointer not set, can't issue a value."); |
| 4375 |
} |
| 4376 |
} |
| 4377 |
|
| 4378 |
in_command = 0; |
| 4379 |
|
| 4380 |
if (in_huh == 3) |
| 4381 |
{ |
| 4382 |
if (in_crap2 == 3) |
| 4383 |
{ |
| 4384 |
//default duck settings |
| 4385 |
sp_speed = 1; |
| 4386 |
sp_base_walk = 20; |
| 4387 |
sp_base_idle = -1; |
| 4388 |
sp_base_hit = -1; |
| 4389 |
sp_base_attack = -1; |
| 4390 |
sp_timer = 33; |
| 4391 |
sp_type = 1; |
| 4392 |
sp_que = 0; |
| 4393 |
sp_hard = 1; |
| 4394 |
} |
| 4395 |
|
| 4396 |
if (in_crap2 == 4) |
| 4397 |
{ |
| 4398 |
//default pig settings |
| 4399 |
sp_speed = 1; |
| 4400 |
sp_base_walk = 40; |
| 4401 |
sp_base_idle = -1; |
| 4402 |
sp_base_hit = -1; |
| 4403 |
sp_base_attack = -1; |
| 4404 |
sp_timer = 66; |
| 4405 |
sp_type = 1; |
| 4406 |
sp_que = 0; |
| 4407 |
sp_hard = 1; |
| 4408 |
} |
| 4409 |
|
| 4410 |
if (in_crap2 == 9) |
| 4411 |
{ |
| 4412 |
//default diag settings |
| 4413 |
sp_speed = 1; |
| 4414 |
sp_base_walk = (sp_seq / 10) * 10; |
| 4415 |
sp_base_idle = -1; |
| 4416 |
sp_base_hit = -1; |
| 4417 |
sp_base_attack = -1; |
| 4418 |
sp_timer = 66; |
| 4419 |
sp_type = 1; |
| 4420 |
strcpy(sp_script, ""); |
| 4421 |
sp_que = 0; |
| 4422 |
sp_hard = 1; |
| 4423 |
} |
| 4424 |
|
| 4425 |
if (in_crap2 == 10) |
| 4426 |
{ |
| 4427 |
//default diag settings |
| 4428 |
sp_speed = 1; |
| 4429 |
sp_base_walk = (sp_seq / 10) * 10; |
| 4430 |
sp_base_idle = -1; |
| 4431 |
sp_base_hit = -1; |
| 4432 |
sp_base_attack = -1; |
| 4433 |
sp_timer = 66; |
| 4434 |
sp_type = 1; |
| 4435 |
strcpy(sp_script, ""); |
| 4436 |
sp_que = 0; |
| 4437 |
sp_hard = 1; |
| 4438 |
} |
| 4439 |
} |
| 4440 |
|
| 4441 |
show_text_box(0); |
| 4442 |
} |
| 4443 |
else if (input_getscancodejustpressed(SDL_SCANCODE_ESCAPE)) |
| 4444 |
{ |
| 4445 |
show_text_box(0); |
| 4446 |
} |
| 4447 |
else if (input_getscancodejustpressed(SDL_SCANCODE_BACKSPACE)) |
| 4448 |
// if (getkey(8)) //this is a much faster backspace than the above |
| 4449 |
{ |
| 4450 |
if (strlen(in_temp) > 0) |
| 4451 |
in_temp[strlen(in_temp)-1] = 0; |
| 4452 |
|
| 4453 |
} |
| 4454 |
|
| 4455 |
if (in_enabled) |
| 4456 |
{ |
| 4457 |
Say(in_temp,260,200); |
| 4458 |
} |
| 4459 |
else |
| 4460 |
{ |
| 4461 |
/* Redraw last mode */ |
| 4462 |
if (g_editorMode == EDITOR_MODE_MINIMAP) |
| 4463 |
{ |
| 4464 |
if (old_command == INPUT_MINIMAP_LOAD) |
| 4465 |
draw_minimap_buff(); |
| 4466 |
else |
| 4467 |
draw_minimap(); |
| 4468 |
} |
| 4469 |
else |
| 4470 |
{ |
| 4471 |
draw_screen_editor(); |
| 4472 |
} |
| 4473 |
} |
| 4474 |
} |
| 4475 |
|
| 4476 |
|
| 4477 |
if (in_master != 0) check_in(); |
| 4478 |
|
| 4479 |
|
| 4480 |
//open a text window? |
| 4481 |
|
| 4482 |
if (in_onflag) |
| 4483 |
{ |
| 4484 |
//start it up |
| 4485 |
|
| 4486 |
//copy screen to Two |
| 4487 |
/* SetRect(&rcRect, 0, 0, 640, 480); */ |
| 4488 |
/* ddrval = lpDDSTwo->Blt( &rcRect, lpDDSBack, &rcRect, DDBLT_WAIT, NULL); */ |
| 4489 |
/* if (ddrval != DD_OK) dderror(ddrval); */ |
| 4490 |
// GFX |
| 4491 |
// TODO: use copy_front_to_two() |
| 4492 |
IOGFX_background->blit(IOGFX_backbuffer, NULL, NULL); |
| 4493 |
|
| 4494 |
|
| 4495 |
strcpy(in_temp,in_default); |
| 4496 |
in_x = 270; |
| 4497 |
in_y = 190; |
| 4498 |
in_onflag = /*false*/0; |
| 4499 |
show_text_box(1); |
| 4500 |
|
| 4501 |
|
| 4502 |
|
| 4503 |
} |
| 4504 |
|
| 4505 |
|
| 4506 |
|
| 4507 |
//MAIN PAGE FLIP DONE HERE |
| 4508 |
|
| 4509 |
|
| 4510 |
if (input_getscancodestate(SDL_SCANCODE_SPACE) && (g_editorMode != 1)) |
| 4511 |
{ |
| 4512 |
drawallhard(); |
| 4513 |
|
| 4514 |
} |
| 4515 |
|
| 4516 |
|
| 4517 |
|
| 4518 |
|
| 4519 |
if (draw_screen_tiny != -1) |
| 4520 |
{ |
| 4521 |
|
| 4522 |
int huh = 0; |
| 4523 |
//if (draw_screen_tiny > 32) huh = 1; |
| 4524 |
shrink_screen_to_these_cords( (draw_screen_tiny-1) * 20 - ((((draw_screen_tiny-1) / 32) * 640) ) , ((((draw_screen_tiny-1) / 32)- huh) * 20)); |
| 4525 |
//Msg("Just flipped # %d", draw_screen_tiny); |
| 4526 |
|
| 4527 |
} |
| 4528 |
|
| 4529 |
|
| 4530 |
|
| 4531 |
/* if (!windowed) */ |
| 4532 |
/* { */ |
| 4533 |
|
| 4534 |
/* while( 1 ) */ |
| 4535 |
/* { */ |
| 4536 |
/* ddrval = lpDDSPrimary->Flip(NULL,DDFLIP_WAIT ); */ |
| 4537 |
/* if( ddrval == DD_OK ) */ |
| 4538 |
/* { */ |
| 4539 |
/* break; */ |
| 4540 |
/* } */ |
| 4541 |
/* if( ddrval == DDERR_SURFACELOST ) */ |
| 4542 |
/* { */ |
| 4543 |
/* ddrval = restoreAll(); */ |
| 4544 |
/* if( ddrval != DD_OK ) */ |
| 4545 |
/* { */ |
| 4546 |
/* break; */ |
| 4547 |
/* } */ |
| 4548 |
/* } */ |
| 4549 |
/* if( ddrval != DDERR_WASSTILLDRAWING ) */ |
| 4550 |
/* { */ |
| 4551 |
|
| 4552 |
/* dderror(ddrval); */ |
| 4553 |
/* } */ |
| 4554 |
/* } */ |
| 4555 |
|
| 4556 |
/* if (draw_screen_tiny != -1) */ |
| 4557 |
/* { */ |
| 4558 |
//extra flip |
| 4559 |
|
| 4560 |
/* ddrval = lpDDSPrimary->Flip(NULL,DDFLIP_WAIT ); */ |
| 4561 |
/* } */ |
| 4562 |
|
| 4563 |
|
| 4564 |
/* } else */ |
| 4565 |
/* { */ |
| 4566 |
g_display->clear(); |
| 4567 |
g_display->flipStretch(IOGFX_backbuffer); |
| 4568 |
/* |
| 4569 |
//windowed mode, no flipping |
| 4570 |
p.x = 0; p.y = 0; |
| 4571 |
ClientToScreen(hWndMain, &p); |
| 4572 |
GetClientRect(hWndMain, &rcRectDest); |
| 4573 |
|
| 4574 |
//rcRectDest.top += winoffset; |
| 4575 |
rcRectDest.bottom = 480; |
| 4576 |
rcRectDest.right = 640; |
| 4577 |
|
| 4578 |
OffsetRect(&rcRectDest, p.x, p.y); |
| 4579 |
SetRect(&rcRectSrc, 0, 0, 640, 480); |
| 4580 |
|
| 4581 |
|
| 4582 |
|
| 4583 |
|
| 4584 |
ddbltfx.dwSize = sizeof(ddbltfx); |
| 4585 |
|
| 4586 |
ddbltfx.dwDDFX = DDBLTFX_NOTEARING; |
| 4587 |
ddrval = lpDDSPrimary->Blt( &rcRectDest, lpDDSBack, &rcRectSrc, DDBLT_DDFX | DDBLT_WAIT, &ddbltfx); |
| 4588 |
*/ |
| 4589 |
/* } */ |
| 4590 |
} /* updateFrame */ |
| 4591 |
|
| 4592 |
|
| 4593 |
int load_editor_sounds() |
| 4594 |
{ |
| 4595 |
int i; |
| 4596 |
|
| 4597 |
/* |
| 4598 |
* Load all sounds |
| 4599 |
*/ |
| 4600 |
for(i = 0; i < NUM_SOUND_EFFECTS; i++) |
| 4601 |
{ |
| 4602 |
char *filename = szSoundEffects[i]; |
| 4603 |
log_info("Loading sound %s [%d]", filename, i); |
| 4604 |
|
| 4605 |
/* Try from resources */ |
| 4606 |
SDL_RWops* rwops; |
| 4607 |
rwops = find_resource_as_rwops(filename); |
| 4608 |
if (rwops != NULL) |
| 4609 |
CreateBufferFromWaveFile_RW(rwops, 1, i); |
| 4610 |
else |
| 4611 |
log_error("Cannot load sound effect %s, from resources or from %s", |
| 4612 |
filename, paths_getpkgdatadir()); |
| 4613 |
} |
| 4614 |
return 1; |
| 4615 |
} |
| 4616 |
|
| 4617 |
|
| 4618 |
AppFreeDinkedit::AppFreeDinkedit() { |
| 4619 |
description = _("Edit the Dink Smallwood game or one of its D-Mods."); |
| 4620 |
splash_path = "Tiles/esplash.bmp"; |
| 4621 |
} |
| 4622 |
|
| 4623 |
/* |
| 4624 |
* doInit - do work required for every instance of the application: |
| 4625 |
* create the window, initialize data |
| 4626 |
*/ |
| 4627 |
void AppFreeDinkedit::init() |
| 4628 |
{ |
| 4629 |
/** SETUP **/ |
| 4630 |
/* Manually setup basic sequences */ |
| 4631 |
{ |
| 4632 |
int i = 1; |
| 4633 |
for (; i <= 4; i++) |
| 4634 |
{ |
| 4635 |
spr[i].active = false; |
| 4636 |
spr[i].x = 10; |
| 4637 |
spr[i].y = 10; |
| 4638 |
spr[i].my = (rand() % 3)+1; |
| 4639 |
spr[i].mx = (rand() % 3)+1; |
| 4640 |
spr[i].seq = 1; |
| 4641 |
spr[i].speed = (rand() % 40)+1; |
| 4642 |
spr[i].brain = 2; |
| 4643 |
spr[i].pseq = 10; |
| 4644 |
spr[i].pframe = 3; |
| 4645 |
spr[i].size = 100; |
| 4646 |
} |
| 4647 |
} |
| 4648 |
|
| 4649 |
spr[1].active = true; |
| 4650 |
spr[1].x = 0; |
| 4651 |
spr[1].y = 0; |
| 4652 |
spr[1].speed = 20; |
| 4653 |
spr[1].brain = 1; |
| 4654 |
rect_set(&spr[1].alt,0,0,0,0); |
| 4655 |
spr[1].pseq = 10; |
| 4656 |
spr[1].pframe = 3; |
| 4657 |
spr[1].seq = 0; |
| 4658 |
spr[1].seq = 2; |
| 4659 |
|
| 4660 |
//sprite sequence setup |
| 4661 |
seq[1].frame[1] = seq[10].frame[1]; |
| 4662 |
seq[1].frame[2] = seq[10].frame[2]; |
| 4663 |
seq[1].frame[3] = seq[10].frame[3]; |
| 4664 |
// FIX: end of sequence is 0, not -1. This made the editor crash. |
| 4665 |
// seq[1].frame[4] = -1; |
| 4666 |
seq[1].frame[4] = 0; |
| 4667 |
|
| 4668 |
seq[1].delay[1] = 50; |
| 4669 |
seq[1].delay[2] = 50; |
| 4670 |
seq[1].delay[3] = 50; |
| 4671 |
seq[1].delay[4] = 50; |
| 4672 |
|
| 4673 |
seq[2].frame[1] = seq[10].frame[4]; |
| 4674 |
seq[2].frame[2] = seq[10].frame[4]; |
| 4675 |
seq[2].frame[3] = seq[10].frame[4]; |
| 4676 |
seq[2].frame[4] = 0; |
| 4677 |
|
| 4678 |
seq[2].delay[1] = 10; |
| 4679 |
seq[2].delay[2] = 10; |
| 4680 |
seq[2].delay[3] = 10; |
| 4681 |
seq[2].delay[4] = 10; |
| 4682 |
|
| 4683 |
seq[3].frame[1] = seq[10].frame[5]; |
| 4684 |
seq[3].frame[2] = seq[10].frame[5]; |
| 4685 |
seq[3].frame[3] = seq[10].frame[5]; |
| 4686 |
seq[3].frame[4] = 0; |
| 4687 |
|
| 4688 |
seq[3].delay[1] = 5; |
| 4689 |
seq[3].delay[2] = 5; |
| 4690 |
seq[3].delay[3] = 5; |
| 4691 |
seq[3].delay[4] = 5; |
| 4692 |
|
| 4693 |
seq[4].frame[1] = seq[10].frame[1]; |
| 4694 |
seq[4].frame[2] = seq[10].frame[1]; |
| 4695 |
seq[4].frame[3] = 0; |
| 4696 |
seq[4].frame[4] = 0; |
| 4697 |
|
| 4698 |
seq[4].delay[1] = 2; |
| 4699 |
seq[4].delay[2] = 2; |
| 4700 |
seq[4].delay[3] = 2; |
| 4701 |
seq[4].delay[4] = 2; |
| 4702 |
|
| 4703 |
if (sound_on) |
| 4704 |
load_editor_sounds(); |
| 4705 |
|
| 4706 |
g_editorMode = EDITOR_MODE_INIT; |
| 4707 |
cur_tile = 1; |
| 4708 |
|
| 4709 |
playl = 20; |
| 4710 |
playx = 620; |
| 4711 |
playy = 480; |
| 4712 |
sp_seq = 0; |
| 4713 |
|
| 4714 |
/* Relative mode with infinite out-of-screen scrolling */ |
| 4715 |
SDL_SetRelativeMouseMode(SDL_TRUE); |
| 4716 |
} |
| 4717 |
|
| 4718 |
/* Global game shortcuts - just full-screen toggle actually */ |
| 4719 |
bool freedinkedit_input_global_shortcuts(SDL_Event* ev) { |
| 4720 |
if (ev->type != SDL_KEYDOWN) |
| 4721 |
return false; |
| 4722 |
if (ev->key.repeat) |
| 4723 |
return false; |
| 4724 |
|
| 4725 |
if (ev->key.keysym.scancode == SDL_SCANCODE_RETURN) |
| 4726 |
{ |
| 4727 |
g_display->toggleFullScreen(); |
| 4728 |
return true; |
| 4729 |
} |
| 4730 |
return false; |
| 4731 |
} |
| 4732 |
|
| 4733 |
void freedinkedit_input_window(SDL_Event* ev) { |
| 4734 |
if (ev->type == SDL_WINDOWEVENT) { |
| 4735 |
if (ev->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { |
| 4736 |
int w = ev->window.data1; |
| 4737 |
int h = ev->window.data2; |
| 4738 |
g_display->onSizeChange(w, h); |
| 4739 |
} |
| 4740 |
} |
| 4741 |
} |
| 4742 |
|
| 4743 |
void AppFreeDinkedit::input(SDL_Event* ev) { |
| 4744 |
freedinkedit_input_window(ev); |
| 4745 |
if (ev->type == SDL_KEYUP |
| 4746 |
&& input_getscancodestate(ev->key.keysym.scancode) == SDL_PRESSED) { |
| 4747 |
// always tell the game when the player releases a key |
| 4748 |
input_update(ev); |
| 4749 |
} else { |
| 4750 |
int processed = false; |
| 4751 |
if ((ev->type == SDL_KEYDOWN || ev->type == SDL_KEYUP) |
| 4752 |
&& (ev->key.keysym.mod & KMOD_ALT)) { |
| 4753 |
processed = freedinkedit_input_global_shortcuts(ev); |
| 4754 |
} |
| 4755 |
if (!processed) |
| 4756 |
// forward all events to the editor |
| 4757 |
input_update(ev); |
| 4758 |
} |
| 4759 |
|
| 4760 |
if (ev->type == SDL_TEXTINPUT |
| 4761 |
&& strlen(in_temp) < in_max |
| 4762 |
&& isprint(ev->text.text[0])) |
| 4763 |
sprintf(in_temp + strlen(in_temp), "%c", ev->text.text[0]); |
| 4764 |
|
| 4765 |
if (g_editorMode == EDITOR_MODE_SCREEN_SPRITES) |
| 4766 |
freedinkedit_update_cursor_position(ev); |
| 4767 |
} |
| 4768 |
|
| 4769 |
|
| 4770 |
/** |
| 4771 |
* Bootstrap |
| 4772 |
*/ |
| 4773 |
int main(int argc, char *argv[]) |
| 4774 |
{ |
| 4775 |
// Create app |
| 4776 |
// Store it in the heap as Emscripten will trash the stack |
| 4777 |
AppFreeDinkedit* freedinkedit = new AppFreeDinkedit(); |
| 4778 |
int ret = freedinkedit->main(argc, argv); |
| 4779 |
delete freedinkedit; |
| 4780 |
return ret; |
| 4781 |
} |