cheat_screen.cc

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2000-2001  The Exult Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifdef HAVE_CONFIG_H
00020 #  include <config.h>
00021 #endif
00022 
00023 #include "SDL_events.h"
00024 #include "files/U7file.h" 
00025 #include "gamewin.h"
00026 #include "game.h"
00027 #include "cheat_screen.h"
00028 #include "font.h"
00029 #ifndef ALPHA_LINUX_CXX
00030 #  include "cstring"
00031 #endif
00032 #include "actors.h"
00033 #include "cheat.h"
00034 #include "exult.h"
00035 #include "imagewin.h"
00036 #include "vgafile.h"
00037 #include "gameclk.h"
00038 #include "schedule.h"
00039 #include "ucmachine.h"
00040 #include "Configuration.h"
00041 #include "SDL.h"
00042 #include "party.h"
00043 
00044 const char *CheatScreen::schedules[33] = {
00045   "Combat",
00046   "Hor. Pace",
00047   "Ver. Pace",
00048   "Talk",
00049   "Dance",
00050   "Eat",
00051   "Farm",
00052   "Tend Shop",
00053   "Miner",
00054   "Hound",
00055   "Stand",
00056   "Loiter",
00057   "Wander",
00058   "Blacksmith",
00059   "Sleep",
00060   "Wait",
00061   "Major Sit",
00062   "Graze",
00063   "Bake",
00064   "Sew",
00065   "Shy",
00066   "Lab",
00067   "Thief",
00068   "Waiter",
00069   "Special",
00070   "Kid Games",
00071   "Eat at Inn",
00072   "Duel",
00073   "Preach",
00074   "Patrol",
00075   "Desk Work",
00076   "Follow Avt",
00077   "Move2Sched"
00078 };
00079 
00080 const char *CheatScreen::flag_names[64] = {
00081   "invisible",    // 0x00
00082   "asleep",   // 0x01
00083   "charmed",    // 0x02
00084   "cursed",   // 0x03
00085   0,      // 0x04
00086   0,      // 0x05
00087   "in_party",   // 0x06
00088   "paralyzed",    // 0x07
00089 
00090   "poisoned",   // 0x08
00091   "protection",   // 0x09
00092   "on_moving_barge",  // 0x0A
00093   "okay_to_take",   // 0x0B
00094   "tremor",   // 0x0C
00095   "cant_die",   // 0x0D
00096   "dancing",    // 0x0E
00097   "dont_move",    // 0x0F
00098 
00099   0,      // 0x10
00100   "si_on_moving_barge", // 0x11
00101   "is_temporary",   // 0x12
00102   0,      // 0x13
00103   0,      // 0x14
00104   "okay_to_land",   // 0x15
00105   0,      // 0x16
00106   0,      // 0x17
00107 
00108   0,      // 0x18
00109   "confused",   // 0x19
00110   "in_motion",    // 0x1A
00111   0,      // 0x1B
00112   "met",      // 0x1C
00113   "si_tournament",  // 0x1D
00114   "misc",     // 0x1E
00115   0,      // 0x1F
00116 
00117   0,      // 0x20
00118   "tattooed",   // 0x21
00119   "read",     // 0x22
00120   "petra",    // 0x23
00121   0,      // 0x24
00122   0,      // 0x25
00123   0,      // 0x26
00124   0,      // 0x27
00125 
00126   0,      // 0x28
00127   0,      // 0x29
00128   0,      // 0x2A
00129   0,      // 0x2B
00130   0,      // 0x2C
00131   0,      // 0x2D
00132   0,      // 0x2E
00133   0,      // 0x2F
00134 
00135   0,      // 0x30
00136   0,      // 0x31
00137   0,      // 0x32
00138   0,      // 0x33
00139   0,      // 0x34
00140   0,      // 0x35
00141   0,      // 0x36
00142   0,      // 0x37
00143 
00144   0,      // 0x38
00145   0,      // 0x39
00146   0,      // 0x3A
00147   0,      // 0x3B
00148   0,      // 0x3C
00149   0,      // 0x3D
00150   0,      // 0x3E
00151   0,      // 0x3F
00152 };
00153   
00154 CheatScreen::CheatScreen() : grabbed(NULL)
00155   {
00156   }
00157 
00158 CheatScreen::~CheatScreen()
00159   {
00160   }
00161 
00162   
00163 void CheatScreen::show_screen()
00164 {
00165     
00166   gwin = Game_window::get_instance();
00167   ibuf = gwin->get_win()->get_ib8();
00168   font = fontManager.get_font("MENU_FONT");
00169   clock = gwin->get_clock();
00170   maxx = gwin->get_width();
00171   maxy = gwin->get_height();
00172   centerx = maxx/2;
00173   centery = maxy/2;
00174 
00175   // Pause the game
00176   gwin->get_tqueue()->pause(SDL_GetTicks());
00177 
00178   str_int_pair pal_tuple = game->get_resource("palettes/0");
00179   pal.load(pal_tuple.str,pal_tuple.num);
00180 
00181   // Start the loop
00182   NormalLoop();
00183 
00184   // Resume the game clock
00185   gwin->get_tqueue()->resume(SDL_GetTicks());
00186 
00187   // Reset the palette
00188   clock->set_palette();
00189 }
00190 
00191 
00192 //
00193 // DISPLAYS
00194 //
00195 
00196 //
00197 // Shared
00198 //
00199 
00200 void CheatScreen::SharedPrompt (char *input, const Cheat_Prompt &mode)
00201 {
00202   char buf[512];
00203 
00204   font->paint_text_fixedwidth(ibuf, "Select->", 0, maxy-18, 8);
00205 
00206   if (input && std::strlen(input))
00207   {
00208     font->paint_text_fixedwidth(ibuf, input, 64, maxy-18, 8);
00209     font->paint_text_fixedwidth(ibuf, "_", 64+std::strlen(input)*8, maxy-18, 8);
00210   }
00211   else
00212     font->paint_text_fixedwidth(ibuf, "_", 64, maxy-18, 8);
00213 
00214   // ...and Prompt Message
00215   switch (mode)
00216   {
00217     default:
00218     case CP_Command:
00219     font->paint_text_fixedwidth(ibuf, "Enter Command.", 0, maxy-9, 8);
00220     break;
00221 
00222     case CP_HitKey:
00223     font->paint_text_fixedwidth(ibuf, "Hit a key.", 0, maxy-9, 8);
00224     break;
00225 
00226     case CP_NotAvail:
00227     font->paint_text_fixedwidth(ibuf, "Not yet available. Hit a key.", 0, maxy-9, 8);
00228     break;
00229 
00230     case CP_InvalidNPC:
00231     font->paint_text_fixedwidth(ibuf, "Invalid NPC. Hit a key", 0, maxy-9, 8);
00232     break;
00233 
00234     case CP_InvalidCom:
00235     font->paint_text_fixedwidth(ibuf, "Invalid Command. Hit a key.", 0, maxy-9, 8);
00236     break;
00237 
00238     case CP_Canceled:
00239     font->paint_text_fixedwidth(ibuf, "Canceled. Hit a key.", 0, maxy-9, 8);
00240     break;
00241 
00242     case CP_ClockSet:
00243     font->paint_text_fixedwidth(ibuf, "Clock Set. Hit a key.", 0, maxy-9, 8);
00244     break;
00245 
00246     case CP_InvalidTime:
00247     font->paint_text_fixedwidth(ibuf, "Invalid Time. Hit a key.", 0, maxy-9, 8);
00248     break;
00249 
00250     case CP_InvalidShape:
00251     font->paint_text_fixedwidth(ibuf, "Invalid Shape. Hit a key.", 0, maxy-9, 8);
00252     break;
00253 
00254     case CP_InvalidValue:
00255     font->paint_text_fixedwidth(ibuf, "Invalid Value. Hit a key.", 0, maxy-9, 8);
00256     break;
00257 
00258     case CP_Created:
00259     font->paint_text_fixedwidth(ibuf, "Item Created. Hit a key.", 0, maxy-9, 8);
00260     break;
00261 
00262     case CP_ShapeSet:
00263     font->paint_text_fixedwidth(ibuf, "Shape Set. Hit a key.", 0, maxy-9, 8);
00264     break;
00265 
00266     case CP_ValueSet:
00267     font->paint_text_fixedwidth(ibuf, "Clock Set. Hit a key.", 0, maxy-9, 8);
00268     break;
00269 
00270     case CP_NameSet:
00271     font->paint_text_fixedwidth(ibuf, "Name Changed. Hit a key.", 0, maxy-9, 8);
00272     break;
00273 
00274     case CP_WrongShapeFile:
00275     font->paint_text_fixedwidth(ibuf, "Wrong shape file. Must be SHAPES.VGA. Hit a key.", 0, maxy-9, 8);
00276     break;
00277 
00278 
00279     case CP_ChooseNPC:
00280     font->paint_text_fixedwidth(ibuf, "Which NPC? (-1 to cancel.)", 0, maxy-9, 8);
00281     break;
00282 
00283     case CP_EnterValue:
00284     font->paint_text_fixedwidth(ibuf, "Enter Value. (-1 to cancel.)", 0, maxy-9, 8);
00285     break;
00286 
00287     case CP_Minute:
00288     font->paint_text_fixedwidth(ibuf, "Enter Minute. (-1 to cancel.)", 0, maxy-9, 8);
00289     break;
00290 
00291     case CP_Hour:
00292     font->paint_text_fixedwidth(ibuf, "Enter Hour. (-1 to cancel.)", 0, maxy-9, 8);
00293     break;
00294 
00295     case CP_Day:
00296     font->paint_text_fixedwidth(ibuf, "Enter Day. (-1 to cancel.)", 0, maxy-9, 8);
00297     break;
00298 
00299     case CP_Shape:
00300     font->paint_text_fixedwidth(ibuf, "Enter Shape (B=Browse or -1=Cancel)", 0, maxy-9, 8);
00301     break;
00302 
00303     case CP_Activity:
00304     font->paint_text_fixedwidth(ibuf, "Enter Activity 0-31. (-1 to cancel.)", 0, maxy-9, 8);
00305     break;
00306 
00307     case CP_XCoord:
00308     snprintf (buf, 512, "Enter X Coord. Max %i (-1 to cancel.)", c_num_tiles);
00309     font->paint_text_fixedwidth(ibuf, buf, 0, maxy-9, 8);
00310     break;
00311 
00312     case CP_YCoord:
00313     snprintf (buf, 512, "Enter Y Coord. Max %i (-1 to cancel.)", c_num_tiles);
00314     font->paint_text_fixedwidth(ibuf, buf, 0, maxy-9, 8);
00315     break;
00316 
00317     case CP_Lift:
00318     font->paint_text_fixedwidth(ibuf, "Enter Lift. (-1 to cancel.)", 0, maxy-9, 8);
00319     break;
00320 
00321     case CP_GFlagNum:
00322     font->paint_text_fixedwidth(ibuf, "Enter Global Flag 0-1023. (-1 to cancel.)", 0, maxy-9, 8);
00323     break;
00324 
00325     case CP_NFlagNum:
00326     font->paint_text_fixedwidth(ibuf, "Enter NPC Flag 0-63. (-1 to cancel.)", 0, maxy-9, 8);
00327     break;
00328 
00329 
00330     case CP_Name:
00331     font->paint_text_fixedwidth(ibuf, "Enter a new Name...", 0, maxy-9, 8);
00332     break;
00333 
00334   }
00335 }
00336 
00337 bool CheatScreen::SharedInput (char *input, int len, int &command, Cheat_Prompt &mode, bool &activate)
00338 {
00339   SDL_Event event;
00340 
00341     do {
00342     SDL_WaitEvent(&event);
00343   } while (event.type!=SDL_KEYDOWN);
00344 
00345   bool shift = false;
00346   if (event.key.keysym.mod & KMOD_SHIFT)
00347     shift = true;
00348   if ((event.key.keysym.sym == SDLK_s) && (event.key.keysym.mod & KMOD_ALT) && (event.key.keysym.mod & KMOD_CTRL))
00349   {
00350     make_screenshot(true);
00351     return false;
00352   }
00353 
00354 
00355   if (mode >= CP_Name)    // Want Text input (len chars)
00356   {
00357     if (event.key.keysym.sym == SDLK_RETURN)
00358     {
00359       activate = true;
00360     }
00361     else if((event.key.keysym.sym >= '0' && event.key.keysym.sym <= 'z') || event.key.keysym.sym == ' ')
00362     {
00363       int curlen = std::strlen(input);
00364       char chr = event.key.keysym.sym;
00365       if (event.key.keysym.mod & KMOD_SHIFT) {
00366 #if (defined(BEOS) || defined(OPENBSD) || defined(CYGWIN) || defined(__MORPHOS__))
00367         if ((chr >= 'a') && (chr <= 'z')) chr -= 32;
00368 #else
00369         chr = std::toupper(chr);
00370 #endif         
00371       }
00372       if(curlen<(len-1))
00373       {
00374         input[curlen] = chr;
00375         input[curlen+1] = 0;
00376       }
00377     }
00378     else if (event.key.keysym.sym == SDLK_BACKSPACE)
00379     {
00380       int curlen = std::strlen(input);
00381       if (curlen) input[curlen-1] = 0;
00382     }
00383   }
00384   else if (mode >= CP_ChooseNPC)  // Need to grab numerical input
00385   {
00386     // Browse shape
00387     if (mode == CP_Shape && !input[0] && event.key.keysym.sym == 'b')
00388     {
00389       cheat.shape_browser();
00390       input[0] = 'b';
00391       activate = true;
00392     }
00393 
00394     // Activate (if possible)
00395     if (event.key.keysym.sym == SDLK_RETURN)
00396     {
00397       activate = true;
00398     }
00399     else if (event.key.keysym.sym == '-' && !input[0])
00400     {
00401       input[0] = '-';
00402     }
00403     else if (event.key.keysym.sym >= '0' && event.key.keysym.sym <= '9')
00404     {
00405       int curlen = std::strlen(input);
00406       if(curlen<(len-1))
00407       {
00408         input[curlen] = event.key.keysym.sym;
00409         input[curlen+1] = 0;
00410       }
00411     }
00412     else if (event.key.keysym.sym == SDLK_BACKSPACE)
00413     {
00414       int curlen = std::strlen(input);
00415       if (curlen) input[curlen-1] = 0;
00416     }
00417   }
00418   else if (mode)      // Just want a key pressed
00419   {
00420     mode = CP_Command;
00421     for (int i = 0; i < len; i++) input[i] = 0;
00422     command = 0;
00423   }
00424   else        // Need the key pressed
00425   {
00426     command = event.key.keysym.sym;
00427     return true;
00428   }
00429   return false;
00430 }
00431 
00432 
00433 //
00434 // Normal
00435 //
00436 
00437 void CheatScreen::NormalLoop ()
00438 {
00439   bool looping = true;
00440 
00441   // This is for the prompt message
00442   Cheat_Prompt mode = CP_Command;
00443 
00444   // This is the command
00445   char input[5] = { 0, 0, 0, 0, 0 };
00446   int command;
00447   bool activate = false;
00448     
00449   while (looping)
00450   {
00451     gwin->clear_screen();
00452 
00453     // First the display
00454     NormalDisplay();
00455 
00456     // Now the Menu Column
00457     NormalMenu();
00458 
00459     // Finally the Prompt...
00460     SharedPrompt(input, mode);
00461 
00462     // Draw it!
00463     pal.apply();
00464 
00465     // Check to see if we need to change menus
00466     if (activate)
00467     {
00468       NormalActivate(input, command, mode);
00469       activate = false;
00470       continue;     
00471     }
00472 
00473     if (SharedInput (input, 5, command, mode, activate))
00474       looping = NormalCheck(input, command, mode, activate);
00475   }
00476 }
00477 
00478 void CheatScreen::NormalDisplay ()
00479 {
00480   char  buf[512];
00481   Tile_coord t = gwin->get_main_actor()->get_tile();
00482 
00483   font->paint_text_fixedwidth(ibuf, "Colourless' Advanced Option Cheat Screen", 0, 0, 8);
00484 
00485   if (Game::get_game_type() == BLACK_GATE)
00486     snprintf (buf, 512, "Running \"Ultima 7: The Black Gate\"");
00487   else if (Game::get_game_type() == SERPENT_ISLE)
00488     snprintf (buf, 512, "Running \"Ultima 7: Part 2: Serpent Isle\"");
00489   else
00490     snprintf (buf, 512, "Running Unknown Game Type %i", Game::get_game_type());
00491   
00492   font->paint_text_fixedwidth(ibuf, buf, 0, 18, 8);
00493 
00494   snprintf (buf, 512, "Exult Version %s", VERSION);
00495   font->paint_text_fixedwidth(ibuf, buf, 0, 27, 8);
00496 
00497 
00498 
00499   snprintf (buf, 512, "Current time: %i:%02i %s  Day: %i",
00500       ((clock->get_hour()+11)%12)+1,
00501       clock->get_minute(),
00502       clock->get_hour()<12 ? "AM":"PM",
00503       clock->get_day());
00504   font->paint_text_fixedwidth(ibuf, buf, 0, 45, 8);
00505 
00506   snprintf (buf, 512, "Coords in hex (%04x, %04x, %02x)", 
00507               t.tx, t.ty, t.tz);
00508   font->paint_text_fixedwidth(ibuf, buf, 0, 63, 8);
00509 
00510   snprintf (buf, 512, "Coords in dec (%04i, %04i, %02i)",
00511               t.tx, t.ty, t.tz);
00512   font->paint_text_fixedwidth(ibuf, buf, 0, 72, 8);
00513 
00514 }
00515 
00516 void CheatScreen::NormalMenu ()
00517 {
00518   char  buf[512];
00519 
00520   // Left Column
00521 
00522   // Use
00523   Shape_manager *sman = Shape_manager::get_instance();
00524   if (Game::get_game_type() == SERPENT_ISLE || (sman->can_use_paperdolls() && sman->get_bg_paperdolls()))
00525     snprintf (buf, 512, "[P]aperdolls..: Yes");
00526   else
00527     snprintf (buf, 512, "[P]aperdolls..:  No");   
00528   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-99, 8);
00529 
00530   // GodMode
00531   snprintf (buf, 512, "[G]od Mode....: %3s", cheat.in_god_mode()?"On":"Off");
00532   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-90, 8);
00533 
00534   // Archwizzard Mode
00535   snprintf (buf, 512, "[W]izard Mode.: %3s", cheat.in_wizard_mode()?"On":"Off");
00536   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-81, 8);
00537 
00538   // Infravision
00539   snprintf (buf, 512, "[I]nfravision.: %3s", cheat.in_infravision()?"On":"Off");
00540   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-72, 8);
00541 
00542   // Hackmover
00543   snprintf (buf, 512, "[H]ack Mover..: %3s", cheat.in_hack_mover()?"Yes":"No");
00544   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-63, 8);
00545 
00546   // Eggs
00547   snprintf (buf, 512, "[E]ggs Visible: %3s", gwin->paint_eggs?"Yes":"No");
00548   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-54, 8);
00549 
00550   // Set Time
00551   font->paint_text_fixedwidth(ibuf, "[S]et Time", 0, maxy-45, 8);
00552 
00553   // Time Rate
00554   snprintf (buf, 512, "[+-] Time Rate: %3i", clock->get_time_rate());
00555   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-36, 8);
00556 
00557 
00558   // Right Column
00559 
00560   // NPC Tool
00561   font->paint_text_fixedwidth(ibuf, "[N]PC Tool", 160, maxy-99, 8);
00562 
00563   // Global Flag Modify
00564   font->paint_text_fixedwidth(ibuf, "[F]lag Modifier", 160, maxy-90, 8);
00565 
00566 #if 0
00567   // Teleport
00568   font->paint_text_fixedwidth(ibuf, "[T]eleport", 160, maxy-81, 8);
00569 #endif
00570 
00571 #if 0
00572   // Create Item
00573   font->paint_text_fixedwidth(ibuf, "[C]reate Item", 160, maxy-72, 8);
00574 #endif
00575 
00576   // eXit
00577   font->paint_text_fixedwidth(ibuf, "[X]it", 160, maxy-36, 8);
00578 
00579 }
00580 
00581 void CheatScreen::NormalActivate (char *input, int &command, Cheat_Prompt &mode)
00582 {
00583   int npc = std::atoi(input);
00584   Shape_manager *sman = Shape_manager::get_instance();
00585 
00586   mode = CP_Command;
00587 
00588   switch (command)
00589   {
00590     // God Mode
00591     case 'g':
00592     cheat.toggle_god();
00593     break;
00594 
00595     // Wizard Mode
00596     case 'w':
00597     cheat.toggle_wizard();
00598     break;
00599 
00600     // Infravision
00601     case 'i':
00602     cheat.toggle_infravision();
00603     break;
00604 
00605     // Eggs
00606     case 'e':
00607     cheat.toggle_eggs();
00608     break;
00609 
00610     // Hack mover
00611     case 'h':
00612     cheat.toggle_hack_mover();
00613     break;
00614 
00615     // Set Time
00616     case 's':
00617     mode = TimeSetLoop();
00618     break;
00619 
00620     // - Time Rate
00621     case '-':
00622     if (clock->get_time_rate() > 0) 
00623       clock->set_time_rate (clock->get_time_rate()-1);
00624     break;
00625 
00626     // + Time Rate
00627     case '+':
00628     if (clock->get_time_rate() < 20) 
00629       clock->set_time_rate (clock->get_time_rate()+1);
00630     break;
00631 
00632 #if 0
00633     // Teleport
00634     case 't':
00635     mode = CP_NotAvail;
00636     break;
00637 #endif
00638 
00639     // NPC Tool
00640     case 'n':
00641     if (npc < -1) mode = CP_InvalidNPC;
00642     else if (npc == -1) mode = CP_Canceled;
00643     else if (!input[0]) NPCLoop(-1);
00644     else mode = NPCLoop(npc);
00645     break;
00646 
00647 #if 0
00648     // Create
00649     case 'c':
00650     mode = CP_NotAvail;
00651     break;
00652 #endif
00653 
00654     // Global Flag Editor
00655     case 'f':
00656     if (npc < -1) mode = CP_InvalidValue;
00657     else if (npc > 1023) mode = CP_InvalidValue;
00658     else if (npc == -1 || !input[0]) mode = CP_Canceled;
00659     else mode = GlobalFlagLoop(npc);
00660     break;
00661 
00662     // Paperdolls
00663     case 'p':
00664       if (Game::get_game_type() == BLACK_GATE 
00665         && sman->can_use_paperdolls()) {
00666         sman->set_bg_paperdolls (sman->get_bg_paperdolls()?false:true);
00667         config->set("config/gameplay/bg_paperdolls",
00668               sman->get_bg_paperdolls() ? "yes" : "no", true);
00669       }
00670     break;
00671 
00672     default:
00673     break;
00674   }
00675 
00676   input[0] = 0;
00677   input[1] = 0;
00678   input[2] = 0;
00679   input[3] = 0;
00680   command = 0;
00681 }
00682 
00683 // Checks the input
00684 bool CheatScreen::NormalCheck (char *input, int &command, Cheat_Prompt &mode, bool &activate)
00685 {
00686   switch(command)
00687   {
00688     // Simple commands
00689     case 't': // Teleport
00690     case 'g': // God Mode
00691     case 'w': // Wizard
00692     case 'i': // iNfravision
00693     case 's': // Set Time
00694     case 'e': // Eggs
00695     case 'h': // Hack Mover
00696     case 'c': // Create Item
00697     case 'p': // Paperdolls
00698     input[0] = command;
00699     activate = true;
00700     break;
00701 
00702     // - Time
00703     case SDLK_KP_MINUS:
00704     case '-':
00705     command = '-';
00706     input[0] = command;
00707     activate = true;
00708     break;
00709 
00710     // + Time
00711     case SDLK_KP_PLUS:
00712     case '=':
00713     command = '+';
00714     input[0] = command;
00715     activate = true;
00716     break;
00717 
00718     // NPC Tool
00719     case 'n':
00720     mode = CP_ChooseNPC;
00721     break;
00722 
00723     // Global Flag Editor
00724     case 'f':
00725     mode = CP_GFlagNum;
00726     break;
00727 
00728     // X and Escape leave
00729     case SDLK_ESCAPE:
00730     case 'x':
00731     input[0] = command;
00732     return false;
00733 
00734     default:
00735     mode = CP_InvalidCom;
00736     input[0] = command;
00737     command = 0;
00738     break;
00739   }
00740 
00741   return true;
00742 }
00743 
00744 //
00745 // Activity Display
00746 //
00747 
00748 void CheatScreen::ActivityDisplay ()
00749 {
00750   char  buf[512];
00751   int i;
00752 
00753   for (i = 0; i < 11; i++)
00754   {
00755     snprintf (buf, 512, "%2i %s", i, schedules[i]);
00756     font->paint_text_fixedwidth(ibuf, buf, 0, i*9, 8);
00757 
00758     snprintf (buf, 512, "%2i %s", i+11, schedules[i+11]);
00759     font->paint_text_fixedwidth(ibuf, buf, 112, i*9, 8);
00760 
00761     if (i != 10)
00762     {
00763       snprintf (buf, 512, "%2i %s", i+22, schedules[i+22]);
00764       font->paint_text_fixedwidth(ibuf, buf, 224, i*9, 8);
00765     }
00766   }
00767 
00768 }
00769 
00770 
00771 //
00772 // TimeSet
00773 //
00774 
00775 CheatScreen::Cheat_Prompt CheatScreen::TimeSetLoop ()
00776 {
00777   // This is for the prompt message
00778   Cheat_Prompt mode = CP_Day;
00779 
00780   // This is the command
00781   char input[5] = { 0, 0, 0, 0, 0 };
00782   int command;
00783   bool activate = false;
00784   
00785   int day, hour;
00786 
00787   while (1)
00788   {
00789     gwin->clear_screen();
00790 
00791     // First the display
00792     NormalDisplay();
00793 
00794     // Now the Menu Column
00795     NormalMenu();
00796 
00797     // Finally the Prompt...
00798     SharedPrompt(input, mode);
00799 
00800     // Draw it!
00801     pal.apply();
00802 
00803     // Check to see if we need to change menus
00804     if (activate)
00805     {
00806       int val = std::atoi(input);
00807       
00808       if (val == -1)
00809       {
00810         return CP_Canceled;
00811       }
00812       else if (val < -1)
00813       {
00814         return CP_InvalidTime;
00815       }
00816       else if (mode == CP_Day)
00817       {
00818         day = val;
00819         mode = CP_Hour;
00820       }
00821       else if (val > 59)
00822       {
00823         return CP_InvalidTime;
00824       }
00825       else if (mode == CP_Minute)
00826       {
00827         clock->set_day(day);
00828         clock->set_hour(hour);
00829         clock->set_minute(val);
00830         break;
00831       }
00832       else if (val > 23)
00833       {
00834         return CP_InvalidTime;
00835       }
00836       else if (mode == CP_Hour)
00837       {
00838         hour = val;
00839         mode = CP_Minute;
00840       }
00841 
00842       activate = false;
00843       input[0] = 0;
00844       input[1] = 0;
00845       input[2] = 0;
00846       input[3] = 0;
00847       command = 0;
00848       continue;     
00849     }
00850 
00851     SharedInput(input, 5, command, mode, activate);
00852   }
00853 
00854   return CP_ClockSet;
00855 }
00856 
00857 
00858 //
00859 // Global Flags
00860 //
00861 
00862 CheatScreen::Cheat_Prompt CheatScreen::GlobalFlagLoop (int num)
00863 {
00864   bool looping = true;
00865 
00866   // This is for the prompt message
00867   Cheat_Prompt mode = CP_Command;
00868 
00869   // This is the command
00870   char input[17];
00871   int i;
00872   int command;
00873   bool activate = false;
00874   char  buf[512];
00875     
00876   for (i = 0; i < 17; i++) input[i] = 0;
00877 
00878   Usecode_machine *usecode = Game_window::get_instance()->get_usecode();
00879 
00880   while (looping)
00881   {
00882     gwin->clear_screen();
00883 
00884 
00885     NormalDisplay();
00886 
00887 
00888     // First the info
00889     snprintf (buf, 512, "Global Flag %i", num);
00890     font->paint_text_fixedwidth(ibuf, buf, 0, maxy-99, 8);
00891 
00892     snprintf (buf, 512, "Flag is %s", usecode->get_global_flag(num)?"SET":"UNSET");
00893     font->paint_text_fixedwidth(ibuf, buf, 0, maxy-90, 8);
00894 
00895 
00896     // Now the Menu Column
00897     if (!usecode->get_global_flag(num)) font->paint_text_fixedwidth(ibuf, "[S]et Flag", 160, maxy-99, 8);
00898     else font->paint_text_fixedwidth(ibuf, "[U]nset Flag", 160, maxy-99, 8);
00899 
00900     // Change Flag
00901     font->paint_text_fixedwidth(ibuf, "[*] Change Flag", 0, maxy-72, 8);
00902     if (num > 0 && num < 1023) font->paint_text_fixedwidth(ibuf, "[+-] Scroll Flags", 0, maxy-63, 8);
00903     else if (num == 0) font->paint_text_fixedwidth(ibuf, "[+] Scroll Flags", 0, maxy-63, 8);
00904     else font->paint_text_fixedwidth(ibuf, "[-] Scroll Flags", 0, maxy-63, 8);
00905 
00906     font->paint_text_fixedwidth(ibuf, "[X]it", 0, maxy-36, 8);
00907 
00908     // Finally the Prompt...
00909     SharedPrompt(input, mode);
00910 
00911     // Draw it!
00912     pal.apply();
00913 
00914     // Check to see if we need to change menus
00915     if (activate)
00916     {
00917       if (command == '-')   // Decrement
00918       {
00919         num--;
00920         if (num < 0) num = 0;
00921       }
00922       else if (command == '+')  // Increment
00923       {
00924         num++;
00925         if (num > 1023) num = 1023;
00926       }
00927       else if (command == '*')  // Change Flag
00928       {
00929         i = std::atoi(input);
00930         if (i < -1 || i > 1023) mode = CP_InvalidValue;
00931         else if (i == -1) mode = CP_Canceled;
00932         else if (input[0]) num = i;
00933       }
00934       else if (command == 's')  // Set
00935       {
00936         usecode->set_global_flag(num, 1);
00937       }
00938       else if (command == 'u')  // Unset
00939       {
00940         usecode->set_global_flag(num, 0);
00941       }
00942 
00943       for (i = 0; i < 17; i++) input[i] = 0;
00944       mode = CP_Command;
00945       command = 0;
00946       activate = false;
00947       continue;     
00948     }
00949 
00950     if (SharedInput (input, 17, command, mode, activate))
00951     {
00952       switch(command)
00953       {
00954         // Simple commands
00955         case 's': // Set Flag
00956         case 'u': // Unset flag
00957         input[0] = command;
00958         activate = true;
00959         break;
00960 
00961         // Decrement
00962         case SDLK_KP_MINUS:
00963         case '-':
00964         command = '-';
00965         input[0] = command;
00966         activate = true;
00967         break;
00968 
00969         // Increment
00970         case SDLK_KP_PLUS:
00971         case '=':
00972         command = '+';
00973         input[0] = command;
00974         activate = true;
00975         break;
00976 
00977         // * Change Flag
00978         case SDLK_KP_MULTIPLY:
00979         case '8':
00980         command = '*';
00981         input[0] = 0;
00982         mode = CP_GFlagNum;
00983         break;
00984 
00985         // X and Escape leave
00986         case SDLK_ESCAPE:
00987         case 'x':
00988         input[0] = command;
00989         looping = false;
00990         break;
00991 
00992         default:
00993         mode = CP_InvalidCom;
00994         input[0] = command;
00995         command = 0;
00996         break;
00997       }
00998     }
00999   }
01000   return CP_Command;
01001 }
01002 
01003 //
01004 // NPCs
01005 //
01006 
01007 CheatScreen::Cheat_Prompt CheatScreen::NPCLoop (int num)
01008 {
01009   Actor *actor;
01010 
01011   bool looping = true;
01012 
01013   // This is for the prompt message
01014   Cheat_Prompt mode = CP_Command;
01015 
01016   // This is the command
01017   char input[17];
01018   int i;
01019   int command;
01020   bool activate = false;
01021     
01022   for (i = 0; i < 17; i++) input[i] = 0;
01023 
01024   while (looping)
01025   {
01026     if (num == -1) actor = grabbed;
01027     else actor = gwin->get_npc (num);
01028     grabbed = actor;
01029     if (actor) num = actor->get_npc_num();
01030 
01031     gwin->clear_screen();
01032 
01033     // First the display
01034     NPCDisplay(actor, num);
01035 
01036     // Now the Menu Column
01037     NPCMenu(actor, num);
01038 
01039     // Finally the Prompt...
01040     SharedPrompt(input, mode);
01041 
01042     // Draw it!
01043     pal.apply();
01044 
01045     // Check to see if we need to change menus
01046     if (activate)
01047     {
01048       NPCActivate(input, command, mode, actor, num);
01049       activate = false;
01050       continue;     
01051     }
01052 
01053     if (SharedInput (input, 17, command, mode, activate))
01054       looping = NPCCheck(input, command, mode, activate, actor, num);
01055   }
01056   return CP_Command;
01057 }
01058 
01059 void CheatScreen::NPCDisplay (Actor *actor, int &num)
01060 {
01061   char  buf[512];
01062   if (actor)
01063   {
01064     Tile_coord t = actor->get_tile();
01065   
01066     // Paint the actors shape
01067     Shape_frame *shape = actor->get_shape();
01068     if (shape) actor->paint_shape (shape->get_xright()+240, shape->get_yabove());
01069 
01070     // Now the info
01071     std::string namestr = actor->get_npc_name();
01072     snprintf (buf, 512, "NPC %i - %s", num, namestr.c_str());
01073     font->paint_text_fixedwidth(ibuf, buf, 0, 0, 8);
01074 
01075     snprintf (buf, 512, "Loc (%04i, %04i, %02i)", 
01076               t.tx, t.ty, t.tz);
01077     font->paint_text_fixedwidth(ibuf, buf, 0, 9, 8);
01078 
01079     snprintf (buf, 512, "Shape %04i:%02i  %s", actor->get_shapenum(), actor->get_framenum(), actor->get_flag(Obj_flags::met)?"Met":"Not Met");
01080     font->paint_text_fixedwidth(ibuf, buf, 0, 18, 8);
01081 
01082     snprintf (buf, 512, "Current Activity: %2i - %s", actor->get_schedule_type(), schedules[actor->get_schedule_type()]);
01083     font->paint_text_fixedwidth(ibuf, buf, 0, 36, 8);
01084 
01085     snprintf (buf, 512, "Experience: %i", actor->get_property(Actor::exp));
01086     font->paint_text_fixedwidth(ibuf, buf, 0, 45, 8);
01087     snprintf (buf, 512, "Level: %i", actor->get_level());
01088     font->paint_text_fixedwidth(ibuf, buf, 144, 45, 8);
01089 
01090     snprintf (buf, 512, "Training: %2i  Health: %2i", actor->get_property(Actor::training), actor->get_property(Actor::health));
01091     font->paint_text_fixedwidth(ibuf, buf, 0, 54, 8);
01092 
01093     if (num != -1)
01094     {
01095       int ucitemnum = 0x10000-num;
01096       if (!num) ucitemnum = 0xfe9c;
01097       snprintf (buf, 512, "Usecode item %4x function %x", ucitemnum, actor->get_usecode());
01098       font->paint_text_fixedwidth(ibuf, buf, 0, 63, 8);
01099     }
01100     else
01101     {
01102       snprintf (buf, 512, "Usecode function %x", actor->get_usecode());
01103       font->paint_text_fixedwidth(ibuf, buf, 0, 63, 8);
01104     }
01105 
01106     if (actor->get_polymorph() != -1)
01107     {
01108       snprintf (buf, 512, "Polymorphed from %04i", actor->get_polymorph());
01109       font->paint_text_fixedwidth(ibuf, buf, 0, 72, 8);
01110     }
01111   }
01112   else
01113   {
01114     snprintf (buf, 512, "NPC %i - Invalid NPC!", num);
01115     font->paint_text_fixedwidth(ibuf, buf, 0, 0, 8);
01116   }
01117 }
01118 
01119 void CheatScreen::NPCMenu (Actor *actor, int &num)
01120 {
01121   // Left Column
01122 
01123 #if 0
01124   // Attack Mode
01125   if (actor) font->paint_text_fixedwidth(ibuf, "[A]ttack Mode", 0, maxy-99, 8);
01126 #endif
01127 
01128   // Business Activity
01129   if (actor) font->paint_text_fixedwidth(ibuf, "[B]usiness Activity", 0, maxy-99, 8);
01130 
01131   // Change Shape
01132   if (actor) font->paint_text_fixedwidth(ibuf, "[C]hange Shape", 0, maxy-90, 8);
01133 
01134   // XP
01135   if (actor) font->paint_text_fixedwidth(ibuf, "[E]xperience", 0, maxy-81, 8);
01136 
01137   // NPC Flags
01138   if (actor) font->paint_text_fixedwidth(ibuf, "[N]pc Flags", 0, maxy-72, 8);
01139 
01140   // Name
01141   if (actor) font->paint_text_fixedwidth(ibuf, "[\\]ame", 0, maxy-63, 8);
01142 
01143 #if 0
01144   // Pop Weapon
01145   if (actor) font->paint_text_fixedwidth(ibuf, "[P]op Weapon", 0, maxy-45, 8);
01146 #endif
01147 
01148   // eXit
01149   font->paint_text_fixedwidth(ibuf, "[X]it", 0, maxy-36, 8);
01150 
01151 
01152   // Right Column
01153 
01154   // Stats
01155   if (actor) font->paint_text_fixedwidth(ibuf, "[S]tats", 160, maxy-99, 8);
01156 
01157 #if 0
01158   // Target
01159   if (actor) font->paint_text_fixedwidth(ibuf, "[T]arget", 160, maxy-90, 8);
01160 #endif
01161 
01162   // Training Points
01163   if (actor) font->paint_text_fixedwidth(ibuf, "[~]raining Points", 160, maxy-90, 8);
01164 
01165   // Teleport
01166   if (actor) font->paint_text_fixedwidth(ibuf, "[']eleport", 160, maxy-81, 8);
01167 
01168   // Change NPC
01169   font->paint_text_fixedwidth(ibuf, "[*] Change NPC", 160, maxy-45, 8);
01170 
01171   // Change NPC
01172   font->paint_text_fixedwidth(ibuf, "[+-] Scroll NPCs", 160, maxy-36, 8);
01173 
01174 }
01175 
01176 void CheatScreen::NPCActivate (char *input, int &command, Cheat_Prompt &mode, Actor *actor, int &num)
01177 {
01178   int i = std::atoi(input);
01179   int nshapes = 
01180     Shape_manager::get_instance()->get_shapes().get_num_shapes();
01181 
01182   mode = CP_Command;
01183 
01184   if (command == '-')
01185   {
01186     num--;
01187     if (num < 0) num = 0;
01188   }
01189   else if (command == '+')
01190   {
01191     num++;
01192   }
01193   else if (command == '*')  // Change NPC
01194   {
01195     if (i < -1) mode = CP_InvalidNPC;
01196     else if (i == -1) mode = CP_Canceled;
01197     else if (input[0]) num = i;
01198   }
01199   else if (actor) switch (command)
01200   {
01201 #if 0
01202     case 'a': // Attack mode
01203     mode = CP_NotAvail;
01204     break;
01205 #endif
01206 
01207     case 'b': // Business
01208     BusinessLoop(actor);
01209     break;
01210 
01211     case 'n': // Npc flags
01212     FlagLoop(actor);
01213     break;
01214 
01215 #if 0
01216     case 'p': // pop weapon
01217     mode = CP_NotAvail;
01218     break;
01219 #endif
01220 
01221     case 's': // stats
01222     StatLoop(actor);
01223     break;
01224 
01225 #if 0
01226     case 't': // Target
01227     mode = CP_NotAvail;
01228     break;
01229 #endif
01230 
01231     case '\'':  // Teleport
01232     Game_window::get_instance()->teleport_party(actor->get_tile());
01233     break;
01234 
01235 
01236     case 'e': // Experience
01237     if (i < 0) mode = CP_InvalidNPC;
01238     else actor->set_property (Actor::exp, i);
01239     break;
01240 
01241     case '`': // Training Points
01242     if (i < 0) mode = CP_InvalidNPC;
01243     else actor->set_property (Actor::training, i);
01244     break;
01245 
01246     case 'c': // Change shape
01247     if (input[0] == 'b')  // Browser
01248     {
01249       int n;
01250       if (!cheat.get_browser_shape(i, n))
01251       {
01252         mode = CP_WrongShapeFile;
01253         break;
01254       }
01255     }
01256 
01257     if (i == -1) mode = CP_Canceled;
01258     else if (i < 0) mode = CP_InvalidShape;
01259     else if (i >= nshapes) mode = CP_InvalidShape;
01260     else if (input[0] && (input[0] != '-' || input[1]))
01261     {
01262       actor->set_shape(i);
01263       mode = CP_ShapeSet;
01264     }
01265     break;
01266 
01267     case '\\':  // Name
01268     if (!std::strlen(input)) mode = CP_Canceled;
01269     else
01270     {
01271       actor->set_npc_name(input);
01272       mode = CP_NameSet;
01273     }
01274     break;
01275 
01276     default:
01277     break;
01278   }
01279   for (i = 0; i < 17; i++) input[i] = 0;
01280   command = 0;
01281 }
01282 
01283 // Checks the input
01284 bool CheatScreen::NPCCheck (char *input, int &command, Cheat_Prompt &mode, bool &activate, Actor *actor, int &num)
01285 {
01286   switch(command)
01287   {
01288     // Simple commands
01289     case 'a': // Attack mode
01290     case 'b': // BUsiness
01291     case 'n': // Npc flags
01292     case 'p': // pop weapon
01293     case 's': // stats
01294     case 't': // Target
01295     case '\'':  // Teleport
01296     input[0] = command;
01297     if (!actor) mode = CP_InvalidCom;
01298     else activate = true;
01299     break;
01300 
01301     // Value entries
01302     case 'e': // Experience
01303     case '`': // Training Points
01304     if (!actor) mode = CP_InvalidCom;
01305     else mode = CP_EnterValue;
01306     break;
01307 
01308     // Change shape
01309     case 'c':
01310     if (!actor) mode = CP_InvalidCom;
01311     else mode = CP_Shape;
01312     break;
01313 
01314     // Name
01315     case '\\':
01316     if (!actor) mode = CP_InvalidCom;
01317     else mode = CP_Name;
01318     break;
01319 
01320     // - NPC
01321     case SDLK_KP_MINUS:
01322     case '-':
01323     command = '-';
01324     input[0] = command;
01325     activate = true;
01326     break;
01327 
01328     // + NPC
01329     case SDLK_KP_PLUS:
01330     case '=':
01331     command = '+';
01332     input[0] = command;
01333     activate = true;
01334     break;
01335 
01336     // * Change NPC
01337     case SDLK_KP_MULTIPLY:
01338     case '8':
01339     command = '*';
01340     input[0] = 0;
01341     mode = CP_ChooseNPC;
01342     break;
01343 
01344     // X and Escape leave
01345     case SDLK_ESCAPE:
01346     case 'x':
01347     input[0] = command;
01348     return false;
01349 
01350     default:
01351     mode = CP_InvalidCom;
01352     input[0] = command;
01353     command = 0;
01354     break;
01355   }
01356 
01357   return true;
01358 }
01359 
01360 //
01361 // NPC Flags
01362 //
01363 
01364 void CheatScreen::FlagLoop (Actor *actor)
01365 {
01366   int num = actor->get_npc_num();
01367   bool looping = true;
01368 
01369   // This is for the prompt message
01370   Cheat_Prompt mode = CP_Command;
01371 
01372   // This is the command
01373   char input[17];
01374   int i;
01375   int command;
01376   bool activate = false;
01377     
01378   for (i = 0; i < 17; i++) input[i] = 0;
01379 
01380   while (looping)
01381   {
01382     gwin->clear_screen();
01383 
01384     // First the display
01385     NPCDisplay(actor, num);
01386 
01387     // Now the Menu Column
01388     FlagMenu(actor);
01389 
01390     // Finally the Prompt...
01391     SharedPrompt(input, mode);
01392 
01393     // Draw it!
01394     pal.apply();
01395 
01396     // Check to see if we need to change menus
01397     if (activate)
01398     {
01399       FlagActivate(input, command, mode, actor);
01400       activate = false;
01401       continue;     
01402     }
01403 
01404     if (SharedInput (input, 17, command, mode, activate))
01405       looping = FlagCheck(input, command, mode, activate, actor);
01406   }
01407 }
01408 
01409 void CheatScreen::FlagMenu (Actor *actor)
01410 {
01411   char  buf[512];
01412 
01413   // Left Column
01414 
01415   // Asleep
01416   snprintf (buf, 512, "[A] Asleep.%c", actor->get_flag(Obj_flags::asleep)?'Y':'N');
01417   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-108, 8);
01418 
01419   // Charmed
01420   snprintf (buf, 512, "[B] Charmd.%c", actor->get_flag(Obj_flags::charmed)?'Y':'N');
01421   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-99, 8);
01422 
01423   // Cursed
01424   snprintf (buf, 512, "[C] Cursed.%c", actor->get_flag(Obj_flags::cursed)?'Y':'N');
01425   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-90, 8);
01426 
01427   // Paralyzed
01428   snprintf (buf, 512, "[D] Prlyzd.%c", actor->get_flag(Obj_flags::paralyzed)?'Y':'N');
01429   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-81, 8);
01430 
01431   // Poisoned
01432   snprintf (buf, 512, "[E] Poisnd.%c", actor->get_flag(Obj_flags::poisoned)?'Y':'N');
01433   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-72, 8);
01434 
01435   // Protected
01436   snprintf (buf, 512, "[F] Prtctd.%c", actor->get_flag(Obj_flags::protection)?'Y':'N');
01437   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-63, 8);
01438 
01439   // Advanced Editor
01440   font->paint_text_fixedwidth(ibuf, "[*] Advanced", 0, maxy-45, 8);
01441 
01442   // Exit
01443   font->paint_text_fixedwidth(ibuf, "[X]it", 0, maxy-36, 8);
01444 
01445 
01446   // Center Column
01447 
01448   // Party
01449   snprintf (buf, 512, "[I] Party..%c", actor->get_flag(Obj_flags::in_party)?'Y':'N');
01450   font->paint_text_fixedwidth(ibuf, buf, 104, maxy-108, 8);
01451 
01452   // Invisible
01453   snprintf (buf, 512, "[J] Invsbl.%c", actor->get_flag(Obj_flags::invisible)?'Y':'N');
01454   font->paint_text_fixedwidth(ibuf, buf, 104, maxy-99, 8);
01455 
01456   // Fly
01457   snprintf (buf, 512, "[K] Fly....%c", actor->get_type_flag(Actor::tf_fly)?'Y':'N');
01458   font->paint_text_fixedwidth(ibuf, buf, 104, maxy-90, 8);
01459 
01460   // Walk
01461   snprintf (buf, 512, "[L] Walk...%c", actor->get_type_flag(Actor::tf_walk)?'Y':'N');
01462   font->paint_text_fixedwidth(ibuf, buf, 104, maxy-81, 8);
01463 
01464   // Swim
01465   snprintf (buf, 512, "[M] Swim...%c", actor->get_type_flag(Actor::tf_swim)?'Y':'N');
01466   font->paint_text_fixedwidth(ibuf, buf, 104, maxy-72, 8);
01467 
01468   // Ethereal
01469   snprintf (buf, 512, "[N] Ethrel.%c", actor->get_type_flag(Actor::tf_ethereal)?'Y':'N');
01470   font->paint_text_fixedwidth(ibuf, buf, 104, maxy-63, 8);
01471 
01472   // Protectee
01473   snprintf (buf, 512, "[O] Prtcee.%c", '?');
01474   font->paint_text_fixedwidth(ibuf, buf, 104, maxy-54, 8);
01475 
01476   // Conjured
01477   snprintf (buf, 512, "[P] Conjrd.%c", actor->get_type_flag(Actor::tf_conjured)?'Y':'N');
01478   font->paint_text_fixedwidth(ibuf, buf, 104, maxy-45, 8);
01479 
01480   // Tournament (SI ONLY)
01481   snprintf (buf, 512, "[3] Tourna.%c", actor->get_flag(
01482     Obj_flags::si_tournament)?'Y':'N');
01483   font->paint_text_fixedwidth(ibuf, buf, 104, maxy-36, 8);
01484 
01485   // Naked (AV SI ONLY)
01486   if (Game::get_game_type() == SERPENT_ISLE && !actor->get_npc_num())
01487   {
01488     snprintf (buf, 512, "[7] Naked..%c", actor->get_siflag(Actor::naked)?'Y':'N');
01489     font->paint_text_fixedwidth(ibuf, buf, 104, maxy-27, 8);
01490   }
01491 
01492 
01493   // Right Column
01494 
01495   // Summoned
01496   snprintf (buf, 512, "[Q] Summnd.%c", actor->get_type_flag(Actor::tf_summonned)?'Y':'N');
01497   font->paint_text_fixedwidth(ibuf, buf, 208, maxy-108, 8);
01498 
01499   // Bleeding
01500   snprintf (buf, 512, "[R] Bleedn.%c", actor->get_type_flag(Actor::tf_bleeding)?'Y':'N');
01501   font->paint_text_fixedwidth(ibuf, buf, 208, maxy-99, 8);
01502 
01503   if (!actor->get_npc_num())  // Avatar
01504   {
01505     // Sex
01506     snprintf (buf, 512, "[S] Sex....%c", actor->get_type_flag(Actor::tf_sex)?'F':'M');
01507     font->paint_text_fixedwidth(ibuf, buf, 208, maxy-90, 8);
01508 
01509     // Skin
01510     snprintf (buf, 512, "[1] Skin...%s", "??");
01511     font->paint_text_fixedwidth(ibuf, buf, 208, maxy-81, 8);
01512 
01513     // Read
01514     snprintf (buf, 512, "[4] Read...%c", actor->get_flag(Obj_flags::read)?'Y':'N');
01515     font->paint_text_fixedwidth(ibuf, buf, 208, maxy-72, 8);
01516   }
01517   else  // Not Avatar
01518   {
01519     // Met
01520     snprintf (buf, 512, "[T] Met....%c", actor->get_flag(Obj_flags::met)?'Y':'N');
01521     font->paint_text_fixedwidth(ibuf, buf, 208, maxy-90, 8);
01522 
01523     // NoCast
01524     snprintf (buf, 512, "[U] NoCast.%c", actor->get_flag(
01525           Obj_flags::no_spell_casting)?'Y':'N');
01526     font->paint_text_fixedwidth(ibuf, buf, 208, maxy-81, 8);
01527 
01528     // ID
01529     snprintf (buf, 512, "[V] ID#:%02i", actor->get_ident());
01530     font->paint_text_fixedwidth(ibuf, buf, 208, maxy-72, 8);
01531   }
01532 
01533   // Freeze
01534   snprintf (buf, 512, "[W] Freeze.%c", actor->get_flag(
01535             Obj_flags::freeze)?'Y':'N');
01536   font->paint_text_fixedwidth(ibuf, buf, 208, maxy-63, 8);
01537 
01538   // Party
01539   if (actor->is_in_party())
01540   {
01541     // Temp
01542     snprintf (buf, 512, "[Y] Temp: %02i", 
01543             actor->get_temperature());
01544     font->paint_text_fixedwidth(ibuf, buf, 208, maxy-54, 8);
01545 
01546     // Conjured
01547     snprintf (buf, 512, "Warmth: %04i", 
01548             actor->figure_warmth());
01549     font->paint_text_fixedwidth(ibuf, buf, 208, maxy-45, 8);
01550   }
01551 
01552   // Polymorph
01553   snprintf (buf, 512, "[2] Polymo.%c", actor->get_flag(Obj_flags::polymorph)?'Y':'N');
01554   font->paint_text_fixedwidth(ibuf, buf, 208, maxy-36, 8);
01555 
01556   // Patra (AV SI ONLY)
01557   if (Game::get_game_type() == SERPENT_ISLE && !actor->get_npc_num())
01558   {
01559     snprintf (buf, 512, "[5] Petra..%c", actor->get_flag(Obj_flags::petra)?'Y':'N');
01560     font->paint_text_fixedwidth(ibuf, buf, 208, maxy-27, 8);
01561   }
01562 
01563 }
01564 
01565 void CheatScreen::FlagActivate (char *input, int &command, Cheat_Prompt &mode, Actor *actor)
01566 {
01567   int i = std::atoi(input);
01568   int nshapes = 
01569     Shape_manager::get_instance()->get_shapes().get_num_shapes();
01570 
01571   mode = CP_Command;
01572   switch (command)
01573   {
01574     // Everyone
01575 
01576     // Toggles
01577     case 'a': // Asleep
01578     if (actor->get_flag(Obj_flags::asleep))
01579       actor->clear_flag(Obj_flags::asleep);
01580     else
01581       actor->set_flag(Obj_flags::asleep);
01582     break;
01583     
01584     case 'b': // Charmed
01585     if (actor->get_flag(Obj_flags::charmed))
01586       actor->clear_flag(Obj_flags::charmed);
01587     else
01588       actor->set_flag(Obj_flags::charmed);
01589     break;
01590     
01591     case 'c': // Cursed
01592     if (actor->get_flag(Obj_flags::cursed))
01593       actor->clear_flag(Obj_flags::cursed);
01594     else
01595       actor->set_flag(Obj_flags::cursed);
01596     break;
01597     
01598     case 'd': // Paralyzed
01599     if (actor->get_flag(Obj_flags::paralyzed))
01600       actor->clear_flag(Obj_flags::paralyzed);
01601     else
01602       actor->set_flag(Obj_flags::paralyzed);
01603     break;
01604     
01605     case 'e': // Poisoned
01606     if (actor->get_flag(Obj_flags::poisoned))
01607       actor->clear_flag(Obj_flags::poisoned);
01608     else
01609       actor->set_flag(Obj_flags::poisoned);
01610     break;
01611     
01612     case 'f': // Protected
01613     if (actor->get_flag(Obj_flags::protection))
01614       actor->clear_flag(Obj_flags::protection);
01615     else
01616       actor->set_flag(Obj_flags::protection);
01617     break;
01618     
01619     case 'j': // Invisible
01620     if (actor->get_flag(Obj_flags::invisible))
01621       actor->clear_flag(Obj_flags::invisible);
01622     else
01623       actor->set_flag(Obj_flags::invisible);
01624     break;
01625     
01626     case 'k': // Fly
01627     if (actor->get_type_flag(Actor::tf_fly))
01628       actor->clear_type_flag(Actor::tf_fly);
01629     else
01630       actor->set_type_flag(Actor::tf_fly);
01631     break;
01632     
01633     case 'l': // Walk
01634     if (actor->get_type_flag(Actor::tf_walk))
01635       actor->clear_type_flag(Actor::tf_walk);
01636     else
01637       actor->set_type_flag(Actor::tf_walk);
01638     break;
01639     
01640     case 'm': // Swim
01641     if (actor->get_type_flag(Actor::tf_swim))
01642       actor->clear_type_flag(Actor::tf_swim);
01643     else
01644       actor->set_type_flag(Actor::tf_swim);
01645     break;
01646     
01647     case 'n': // Ethrel
01648     if (actor->get_type_flag(Actor::tf_ethereal))
01649       actor->clear_type_flag(Actor::tf_ethereal);
01650     else
01651       actor->set_type_flag(Actor::tf_ethereal);
01652     break;
01653     
01654     case 'p': // Conjured
01655     if (actor->get_type_flag(Actor::tf_conjured))
01656       actor->clear_type_flag(Actor::tf_conjured);
01657     else
01658       actor->set_type_flag(Actor::tf_conjured);
01659     break;
01660     
01661     case 'q': // Summoned
01662     if (actor->get_type_flag(Actor::tf_summonned))
01663       actor->clear_type_flag(Actor::tf_summonned);
01664     else
01665       actor->set_type_flag(Actor::tf_summonned);
01666     break;
01667     
01668     case 'r': // Bleeding
01669     if (actor->get_type_flag(Actor::tf_bleeding))
01670       actor->clear_type_flag(Actor::tf_bleeding);
01671     else
01672       actor->set_type_flag(Actor::tf_bleeding);
01673     break;
01674     
01675     case '3': // Tournament
01676     if (actor->get_flag(Obj_flags::si_tournament))
01677       actor->clear_flag(Obj_flags::si_tournament);
01678     else
01679       actor->set_flag(Obj_flags::si_tournament);
01680     break;
01681     
01682     case 's': // Sex
01683     if (actor->get_type_flag(Actor::tf_sex))
01684       actor->clear_type_flag(Actor::tf_sex);
01685     else
01686       actor->set_type_flag(Actor::tf_sex);
01687     break;
01688     
01689     case '4': // Read
01690     if (actor->get_flag(Obj_flags::read))
01691       actor->clear_flag(Obj_flags::read);
01692     else
01693       actor->set_flag(Obj_flags::read);
01694     break;
01695     
01696     case '5': // Petra
01697     if (actor->get_flag(Obj_flags::petra))
01698       actor->clear_flag(Obj_flags::petra);
01699     else
01700       actor->set_flag(Obj_flags::petra);
01701     break;
01702     
01703     case '7': // Naked
01704     if (actor->get_siflag(Actor::naked))
01705       actor->clear_siflag(Actor::naked);
01706     else
01707       actor->set_siflag(Actor::naked);
01708     break;
01709     
01710     case 't': // Met
01711     if (actor->get_flag(Obj_flags::met))
01712       actor->clear_flag(Obj_flags::met);
01713     else
01714       actor->set_flag(Obj_flags::met);
01715     break;
01716     
01717     case 'u': // No Cast
01718     if (actor->get_flag(Obj_flags::no_spell_casting))
01719       actor->clear_flag(Obj_flags::no_spell_casting);
01720     else
01721       actor->set_flag(Obj_flags::no_spell_casting);
01722     break;
01723     
01724     case 'z': // Zombie
01725     if (actor->get_flag(Obj_flags::si_zombie))
01726       actor->clear_flag(Obj_flags::si_zombie);
01727     else
01728       actor->set_flag(Obj_flags::si_zombie);
01729     break;
01730 
01731     case 'w': // Freeze
01732     if (actor->get_flag(Obj_flags::freeze))
01733       actor->clear_flag(Obj_flags::freeze);
01734     else
01735       actor->set_flag(Obj_flags::freeze);
01736     break;
01737 
01738     case 'i': // Party
01739     if (actor->get_flag(Obj_flags::in_party))
01740       gwin->get_party_man()->remove_from_party(actor);
01741     else
01742       gwin->get_party_man()->add_to_party(actor);
01743     break;
01744     
01745     case 'o': // Protectee
01746     break;
01747     
01748     // Value
01749     case 'v': // ID
01750     if (i < -1) mode = CP_InvalidValue;
01751     else if (i > 63) mode = CP_InvalidValue;
01752     else if (i == -1 || !input[0]) mode = CP_Canceled;
01753     else actor->set_ident(i);
01754     break;
01755     
01756     case '1': // Skin
01757     break;
01758     
01759     case 'y': // Warmth
01760     break;
01761     
01762     case '2': // Polymorph
01763 
01764     // Clear polymorph
01765     if (actor->get_polymorph() != -1)
01766     {
01767       actor->set_polymorph(actor->get_polymorph());
01768       break;
01769     }
01770 
01771     if (input[0] == 'b')  // Browser
01772     {
01773       int n;
01774       if (!cheat.get_browser_shape(i, n))
01775       {
01776         mode = CP_WrongShapeFile;
01777         break;
01778       }
01779     }
01780 
01781     if (i == -1) mode = CP_Canceled;
01782     else if (i < 0) mode = CP_InvalidShape;
01783     else if (i >= nshapes) mode = CP_InvalidShape;
01784     else if (input[0] && (input[0] != '-' || input[1]))
01785     {
01786       actor->set_polymorph(i);
01787       mode = CP_ShapeSet;
01788     }
01789 
01790     break;
01791 
01792     // Advanced Numeric Flag Editor
01793     case '*':
01794     if (i < -1) mode = CP_InvalidValue;
01795     else if (i > 63) mode = CP_InvalidValue;
01796     else if (i == -1 || !input[0]) mode = CP_Canceled;
01797     else mode = AdvancedFlagLoop(i, actor);
01798     break;
01799 
01800     default:
01801     break;
01802   }
01803   for (i = 0; i < 17; i++) input[i] = 0;
01804   command = 0;
01805 }
01806 
01807 // Checks the input
01808 bool CheatScreen::FlagCheck (char *input, int &command, Cheat_Prompt &mode, bool &activate, Actor *actor)
01809 {
01810   switch(command)
01811   {
01812     // Everyone
01813 
01814     // Toggles
01815     case 'a': // Asleep
01816     case 'b': // Charmed
01817     case 'c': // Cursed
01818     case 'd': // Paralyzed
01819     case 'e': // Poisoned
01820     case 'f': // Protected
01821     case 'i': // Party
01822     case 'j': // Invisible
01823     case 'k': // Fly
01824     case 'l': // Walk
01825     case 'm': // Swim
01826     case 'n': // Ethrel
01827     case 'o': // Protectee
01828     case 'p': // Conjured
01829     case 'q': // Summoned
01830     case 'r': // Bleedin
01831     case 'w': // Freeze
01832     //case '3': // Tournament
01833     activate = true;
01834     input[0] = command;
01835     break;
01836 
01837     // Value
01838     case '2': // Polymorph
01839     if (actor->get_polymorph() == -1)
01840     {
01841       mode = CP_Shape;
01842       input[0] = 0;
01843     }
01844     else
01845     {
01846       activate = true;
01847       input[0] = command;
01848     }
01849     break;
01850 
01851 
01852     // Party Only
01853 
01854     // Value
01855     case 'y': // Temp
01856     if (!actor->is_in_party()) command = 0;
01857     else  mode = CP_NotAvail;
01858     input[0] = command;
01859     break;
01860 
01861 
01862     // Avatar Only
01863 
01864     // Toggles
01865     case 's': // Sex
01866     case '4': // Read
01867     if (actor->get_npc_num()) command = 0;
01868     else activate = true;
01869     input[0] = command;
01870     break;
01871 
01872     // Toggles SI
01873     case '5': // Petra
01874     case '7': // Naked
01875     if (Game::get_game_type() != SERPENT_ISLE || actor->get_npc_num()) command = 0;
01876     else activate = true;
01877     input[0] = command;
01878     break; 
01879 
01880     // Value SI
01881     case '1': // Skin
01882     if (Game::get_game_type() != SERPENT_ISLE || actor->get_npc_num()) command = 0;
01883     else mode = CP_NotAvail;
01884     input[0] = command;
01885     break;
01886 
01887 
01888     // Everyone but avatar
01889 
01890     // Toggles
01891     case 't': // Met
01892     case 'u': // No Cast
01893     case 'z': // Zombie
01894     if (!actor->get_npc_num()) command = 0;
01895     else activate = true;
01896     input[0] = command;
01897     break;
01898 
01899     // Value
01900     case 'v': // ID
01901     if (!actor->get_npc_num()) command = 0;
01902     else mode = CP_EnterValue;
01903     input[0] = 0; 
01904     break;
01905 
01906     // NPC Flag Editor
01907 
01908     case SDLK_KP_MULTIPLY:
01909     case '8':
01910     command = '*';
01911     input[0] = 0;
01912     mode = CP_NFlagNum;
01913     break;
01914 
01915 
01916     // X and Escape leave
01917     case SDLK_ESCAPE:
01918     case 'x':
01919     input[0] = command;
01920     return false;
01921 
01922     // Unknown
01923     default:
01924     command = 0;
01925     break;
01926   }
01927 
01928   return true;
01929 }
01930 
01931 //
01932 // Business Schedules
01933 //
01934 
01935 void CheatScreen::BusinessLoop (Actor *actor)
01936 {
01937   bool looping = true;
01938 
01939   // This is for the prompt message
01940   Cheat_Prompt mode = CP_Command;
01941 
01942   // This is the command
01943   char input[17];
01944   int i;
01945   int command;
01946   bool activate = false;
01947   int time = 0;
01948   int prev = 0;
01949     
01950   for (i = 0; i < 17; i++) input[i] = 0;
01951 
01952   while (looping)
01953   {
01954     gwin->clear_screen();
01955 
01956     // First the display
01957     if (mode == CP_Activity)
01958             ActivityDisplay();
01959     else
01960             BusinessDisplay(actor);
01961 
01962     // Now the Menu Column
01963     BusinessMenu(actor);
01964 
01965     // Finally the Prompt...
01966     SharedPrompt(input, mode);
01967 
01968     // Draw it!
01969     pal.apply();
01970 
01971     // Check to see if we need to change menus
01972     if (activate)
01973     {
01974       BusinessActivate(input, command, mode, actor, time, prev);
01975       activate = false;
01976       continue;     
01977     }
01978 
01979     if (SharedInput (input, 17, command, mode, activate))
01980       looping = BusinessCheck(input, command, mode, activate, actor, time);
01981   }
01982 }
01983 
01984 void CheatScreen::BusinessDisplay (Actor *actor)
01985 {
01986   char  buf[512];
01987   Tile_coord t = actor->get_tile();
01988 
01989   // Now the info
01990   std::string namestr = actor->get_npc_name();
01991   snprintf (buf, 512, "NPC %i - %s", actor->get_npc_num(), namestr.c_str());
01992   font->paint_text_fixedwidth(ibuf, buf, 0, 0, 8);
01993 
01994   snprintf (buf, 512, "Loc (%04i, %04i, %02i)", t.tx, t.ty, t.tz);
01995   font->paint_text_fixedwidth(ibuf, buf, 0, 8, 8);
01996 
01997   snprintf (buf, 512, "Current Activity:  %2i - %s", actor->get_schedule_type(), schedules[actor->get_schedule_type()]);
01998   font->paint_text_fixedwidth(ibuf, buf, 0, 16, 8);
01999   
02000 
02001   // Avatar can't have schedules
02002   if (actor->get_npc_num() > 0)
02003   {
02004     font->paint_text_fixedwidth(ibuf, "Schedules:", 0, 28, 8);
02005 
02006     Schedule_change *scheds;
02007     int num;
02008     int types[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
02009     int x[8];
02010     int y[8];
02011     int time;
02012     int i;
02013     Tile_coord tile;
02014 
02015     actor->get_schedules (scheds, num);
02016 
02017     for (i = 0; i < num; i++)
02018     {
02019       time = scheds[i].get_time();
02020       types[time] = scheds[i].get_type();
02021       tile = scheds[i].get_pos();
02022       x[time] = tile.tx;
02023       y[time] = tile.ty;
02024     }
02025 
02026     font->paint_text_fixedwidth(ibuf, "12 AM:", 0, 36, 8);
02027     font->paint_text_fixedwidth(ibuf, " 3 AM:", 0, 44, 8);
02028     font->paint_text_fixedwidth(ibuf, " 6 AM:", 0, 52, 8);
02029     font->paint_text_fixedwidth(ibuf, " 9 AM:", 0, 60, 8);
02030     font->paint_text_fixedwidth(ibuf, "12 PM:", 0, 68, 8);
02031     font->paint_text_fixedwidth(ibuf, " 3 PM:", 0, 76, 8);
02032     font->paint_text_fixedwidth(ibuf, " 6 PM:", 0, 84, 8);
02033     font->paint_text_fixedwidth(ibuf, " 9 PM:", 0, 92, 8);
02034   
02035     for (i = 0; i < 8; i++) if (types[i] != -1)
02036     {
02037       snprintf (buf, 512, "%2i (%4i,%4i) - %s", types[i], x[i], y[i], schedules[types[i]]);
02038       font->paint_text_fixedwidth(ibuf, buf, 56, 36+i*8, 8);
02039     }
02040   }
02041 }
02042 
02043 void CheatScreen::BusinessMenu (Actor *actor)
02044 {
02045   // Left Column
02046 
02047   // Might break on monster npcs?
02048   if (actor->get_npc_num() > 0)
02049   {
02050     font->paint_text_fixedwidth(ibuf, "12 AM: [A] Set  [I] Location  [1] Clear", 0, maxy-96, 8);
02051     font->paint_text_fixedwidth(ibuf, " 3 AM: [B] Set  [J] Location  [2] Clear", 0, maxy-88, 8);
02052     font->paint_text_fixedwidth(ibuf, " 6 AM: [C] Set  [K] Location  [3] Clear", 0, maxy-80, 8);
02053     font->paint_text_fixedwidth(ibuf, " 9 AM: [D] Set  [L] Location  [4] Clear", 0, maxy-72, 8);
02054     font->paint_text_fixedwidth(ibuf, "12 PM: [E] Set  [M] Location  [5] Clear", 0, maxy-64, 8);
02055     font->paint_text_fixedwidth(ibuf, " 3 PM: [F] Set  [N] Location  [6] Clear", 0, maxy-56, 8);
02056     font->paint_text_fixedwidth(ibuf, " 6 PM: [G] Set  [O] Location  [7] Clear", 0, maxy-48, 8);
02057     font->paint_text_fixedwidth(ibuf, " 9 PM: [H] Set  [P] Location  [8] Clear", 0, maxy-40, 8);
02058 
02059          font->paint_text_fixedwidth(ibuf, "[S]et Current Activity [X]it [R]evert", 0, maxy-30, 8);
02060   }
02061   else
02062           font->paint_text_fixedwidth(ibuf, "[S]et Current Activity [X]it", 0, maxy-30, 8);
02063 }
02064 
02065 void CheatScreen::BusinessActivate (char *input, int &command, Cheat_Prompt &mode, Actor *actor, int &time, int &prev)
02066 {
02067   int i = std::atoi(input);
02068 
02069   mode = CP_Command;
02070   int old = command;
02071   command = 0;
02072   switch (old)
02073   {
02074     case 'a': // Set Activity
02075     if (i < -1 || i > 31) mode = CP_InvalidValue;
02076     else if (i == -1) mode = CP_Canceled;
02077     else if (!input[0])
02078     {
02079       mode = CP_Activity;
02080       command = 'a';
02081     }
02082     else
02083     {
02084       actor->set_schedule_time_type(time, i);
02085     }
02086     break;
02087 
02088     case 'i': // X Coord
02089     if (i < -1 || i > c_num_tiles) mode = CP_InvalidValue;
02090     else if (i == -1) mode = CP_Canceled;
02091     else if (!input[0])
02092     {
02093       mode = CP_XCoord;
02094       command = 'i';
02095     }
02096     else
02097     {
02098       prev = i;
02099       mode = CP_YCoord;
02100       command = 'j';
02101     }
02102     break;
02103 
02104     case 'j': // Y Coord
02105     if (i < -1 || i > c_num_tiles) mode = CP_InvalidValue;
02106     else if (i == -1) mode = CP_Canceled;
02107     else if (!input[0])
02108     {
02109       mode = CP_YCoord;
02110       command = 'j';
02111     }
02112     else
02113     {
02114       actor->set_schedule_time_location(time, prev, i);
02115     }
02116     break;
02117 
02118 
02119     case '1': // Clear
02120     actor->remove_schedule(time);
02121     break;
02122 
02123 
02124     case 's': // Set Current
02125     if (i < -1 || i > 31) mode = CP_InvalidValue;
02126     else if (i == -1) mode = CP_Canceled;
02127     else if (!input[0])
02128     {
02129       mode = CP_Activity;
02130       command = 's';
02131     }
02132     else
02133     {
02134       actor->set_schedule_type(i);
02135     }
02136     break;
02137 
02138 
02139     case 'r': // Revert
02140     Game_window::get_instance()->revert_schedules(actor);
02141     break;
02142 
02143 
02144     default:
02145     break;
02146   }
02147   for (i = 0; i < 17; i++) input[i] = 0;
02148 }
02149 
02150 // Checks the input
02151 bool CheatScreen::BusinessCheck (char *input, int &command, Cheat_Prompt &mode, bool &activate, Actor *actor, int &time)
02152 {
02153   // Might break on monster npcs?
02154   if (actor->get_npc_num() > 0) switch(command)
02155   {
02156     case 'a':
02157     case 'b':
02158     case 'c':
02159     case 'd':
02160     case 'e':
02161     case 'f':
02162     case 'g':
02163     case 'h':
02164     time = command -'a';
02165     command = 'a';
02166     mode = CP_Activity;
02167     return true;
02168 
02169     case 'i':
02170     case 'j':
02171     case 'k':
02172     case 'l':
02173     case 'm':
02174     case 'n':
02175     case 'o':
02176     case 'p':
02177     time = command -'i';
02178     command = 'i';
02179     mode = CP_XCoord;
02180     return true;
02181 
02182     case '1':
02183     case '2':
02184     case '3':
02185     case '4':
02186     case '5':
02187     case '6':
02188     case '7':
02189     case '8':
02190     time = command -'1';
02191     command = '1';
02192     activate = true;
02193     return true;
02194 
02195     case 'r':
02196     command = 'r';
02197     activate = true;
02198     return true;
02199 
02200     default:
02201     break;
02202   }
02203 
02204   switch(command)
02205   {
02206     // Set Current
02207     case 's':
02208     command = 's';
02209     input[0] = 0;
02210     mode = CP_Activity;
02211     break;
02212     
02213 
02214     // X and Escape leave
02215     case SDLK_ESCAPE:
02216     case 'x':
02217     input[0] = command;
02218     return false;
02219 
02220     // Unknown
02221     default:
02222     command = 0;
02223     mode = CP_InvalidCom;
02224     break;
02225   }
02226 
02227   return true;
02228 }
02229 
02230 //
02231 // NPC Stats
02232 //
02233 
02234 void CheatScreen::StatLoop (Actor *actor)
02235 {
02236   int num = actor->get_npc_num();
02237   bool looping = true;
02238 
02239   // This is for the prompt message
02240   Cheat_Prompt mode = CP_Command;
02241 
02242   // This is the command
02243   char input[17];
02244   int i;
02245   int command;
02246   bool activate = false;
02247     
02248   for (i = 0; i < 17; i++) input[i] = 0;
02249 
02250   while (looping)
02251   {
02252     gwin->clear_screen();
02253 
02254     // First the display
02255     NPCDisplay(actor, num);
02256 
02257     // Now the Menu Column
02258     StatMenu(actor);
02259 
02260     // Finally the Prompt...
02261     SharedPrompt(input, mode);
02262 
02263     // Draw it!
02264     pal.apply();
02265 
02266     // Check to see if we need to change menus
02267     if (activate)
02268     {
02269       StatActivate(input, command, mode, actor);
02270       activate = false;
02271       continue;     
02272     }
02273 
02274     if (SharedInput (input, 17, command, mode, activate))
02275       looping = StatCheck(input, command, mode, activate, actor);
02276   }
02277 }
02278 
02279 void CheatScreen::StatMenu (Actor *actor)
02280 {
02281   char  buf[512];
02282 
02283   // Left Column
02284 
02285   // Dexterity
02286   snprintf (buf, 512, "[D]exterity....%3i", actor->get_property(Actor::dexterity));
02287   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-108, 8);
02288 
02289   // Food Level
02290   snprintf (buf, 512, "[F]ood Level...%3i", actor->get_property(Actor::food_level));
02291   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-99, 8);
02292 
02293   // Intelligence
02294   snprintf (buf, 512, "[I]ntellicence.%3i", actor->get_property(Actor::intelligence));
02295   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-90, 8);
02296 
02297   // Strength
02298   snprintf (buf, 512, "[S]trength.....%3i", actor->get_property(Actor::strength));
02299   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-81, 8);
02300 
02301   // Combat Skill
02302   snprintf (buf, 512, "[C]ombat Skill.%3i", actor->get_property(Actor::combat));
02303   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-72, 8);
02304 
02305   // Hit Points
02306   snprintf (buf, 512, "[H]it Points...%3i", actor->get_property(Actor::health));
02307   font->paint_text_fixedwidth(ibuf, buf, 0, maxy-63, 8);
02308 
02309   // Magic - Avatar Only
02310   if (!actor->get_npc_num())
02311   {
02312     // Magic Points
02313     snprintf (buf, 512, "[M]agic Points.%3i", actor->get_property(Actor::magic));
02314     font->paint_text_fixedwidth(ibuf, buf, 0, maxy-54, 8);
02315 
02316     // Mana
02317     snprintf (buf, 512, "[V]ana Level...%3i", actor->get_property(Actor::mana));
02318     font->paint_text_fixedwidth(ibuf, buf, 0, maxy-45, 8);
02319   }
02320 
02321   // Exit
02322   font->paint_text_fixedwidth(ibuf, "[X]it", 0, maxy-36, 8);
02323 
02324 
02325 }
02326 
02327 void CheatScreen::StatActivate (char *input, int &command, Cheat_Prompt &mode, Actor *actor)
02328 {
02329   int i = std::atoi(input);
02330 
02331   mode = CP_Command;
02332   switch (command)
02333   {
02334     case 'd': // Dexterity
02335     actor->set_property(Actor::dexterity, i);
02336     break;
02337     
02338     case 'f': // Food Level
02339     actor->set_property(Actor::food_level, i);
02340     break;
02341     
02342     case 'i': // Intelligence
02343     actor->set_property(Actor::intelligence, i);
02344     break;
02345     
02346     case 's': // Strength
02347     actor->set_property(Actor::strength, i);
02348     break;
02349     
02350     case 'c': // Combat Points
02351     actor->set_property(Actor::combat, i);
02352     break;
02353     
02354     case 'h': // Hit Points
02355     actor->set_property(Actor::health, i);
02356     break;
02357     
02358     case 'm': // Magic
02359     actor->set_property(Actor::magic, i);
02360     break;
02361     
02362     case 'v': // [V]ana
02363     actor->set_property(Actor::mana, i);
02364     break;
02365     
02366 
02367     default:
02368     break;
02369   }
02370   for (i = 0; i < 17; i++) input[i] = 0;
02371   command = 0;
02372 }
02373 
02374 // Checks the input
02375 bool CheatScreen::StatCheck (char *input, int &command, Cheat_Prompt &mode, bool &activate, Actor *actor)
02376 {
02377   switch(command)
02378   {
02379     // Everyone
02380     case 'd': // Dexterity
02381     case 'f': // Food Level
02382     case 'i': // Intelligence
02383     case 's': // Strength
02384     case 'c': // Combat Points
02385     case 'h': // Hit Points
02386     input[0] = 0;
02387     mode = CP_EnterValue;
02388     break;
02389 
02390     // Avatar Only
02391     case 'm': // Magic
02392     case 'v': // [V]ana
02393     if (actor->get_npc_num()) command = 0;
02394     else mode = CP_EnterValue;
02395     input[0] = 0;
02396     break;
02397 
02398     // X and Escape leave
02399     case SDLK_ESCAPE:
02400     case 'x':
02401     input[0] = command;
02402     return false;
02403 
02404     // Unknown
02405     default:
02406     command = 0;
02407     break;
02408   }
02409 
02410   return true;
02411 }
02412 
02413 
02414 //
02415 // Advanced Flag Edition
02416 //
02417 
02418 CheatScreen::Cheat_Prompt CheatScreen::AdvancedFlagLoop (int num, Actor *actor)
02419 {
02420   int npc_num = actor->get_npc_num();
02421   bool looping = true;
02422 
02423   // This is for the prompt message
02424   Cheat_Prompt mode = CP_Command;
02425 
02426   // This is the command
02427   char input[17];
02428   int i;
02429   int command;
02430   bool activate = false;
02431   char  buf[512];
02432     
02433   for (i = 0; i < 17; i++) input[i] = 0;
02434 
02435   while (looping)
02436   {
02437     gwin->clear_screen();
02438 
02439     NPCDisplay(actor, npc_num);
02440 
02441     if (num < 0) num = 0;
02442     else if (num > 63) num = 63;
02443 
02444     // First the info
02445     if (flag_names[num])
02446       snprintf (buf, 512, "NPC Flag %i: %s", num, flag_names[num]);
02447     else
02448       snprintf (buf, 512, "NPC Flag %i", num);
02449 
02450     font->paint_text_fixedwidth(ibuf, buf, 0, maxy-108, 8);
02451 
02452     snprintf (buf, 512, "Flag is %s", actor->get_flag(num)?"SET":"UNSET");
02453     font->paint_text_fixedwidth(ibuf, buf, 0, maxy-90, 8);
02454 
02455 
02456     // Now the Menu Column
02457     if (!actor->get_flag(num)) font->paint_text_fixedwidth(ibuf, "[S]et Flag", 160, maxy-90, 8);
02458     else font->paint_text_fixedwidth(ibuf, "[U]nset Flag", 160, maxy-90, 8);
02459 
02460     // Change Flag
02461     font->paint_text_fixedwidth(ibuf, "[*] Change Flag", 0, maxy-72, 8);
02462     if (num > 0 && num < 63) font->paint_text_fixedwidth(ibuf, "[+-] Scroll Flags", 0, maxy-63, 8);
02463     else if (num == 0) font->paint_text_fixedwidth(ibuf, "[+] Scroll Flags", 0, maxy-63, 8);
02464     else font->paint_text_fixedwidth(ibuf, "[-] Scroll Flags", 0, maxy-63, 8);
02465 
02466     font->paint_text_fixedwidth(ibuf, "[X]it", 0, maxy-36, 8);
02467 
02468     // Finally the Prompt...
02469     SharedPrompt(input, mode);
02470 
02471     // Draw it!
02472     pal.apply();
02473 
02474     // Check to see if we need to change menus
02475     if (activate)
02476     {
02477       if (command == '-')   // Decrement
02478       {
02479         num--;
02480         if (num < 0) num = 0;
02481       }
02482       else if (command == '+')  // Increment
02483       {
02484         num++;
02485         if (num > 63) num = 63;
02486       }
02487       else if (command == '*')  // Change Flag
02488       {
02489         i = std::atoi(input);
02490         if (i < -1 || i > 63) mode = CP_InvalidValue;
02491         else if (i == -1) mode = CP_Canceled;
02492         else if (input[0]) num = i;
02493       }
02494       else if (command == 's')  // Set
02495       {
02496         actor->set_flag(num);
02497       }
02498       else if (command == 'u')  // Unset
02499       {
02500         actor->clear_flag(num);
02501       }
02502 
02503       for (i = 0; i < 17; i++) input[i] = 0;
02504       mode = CP_Command;
02505       command = 0;
02506       activate = false;
02507       continue;     
02508     }
02509 
02510     if (SharedInput (input, 17, command, mode, activate))
02511     {
02512       switch(command)
02513       {
02514         // Simple commands
02515         case 's': // Set Flag
02516         case 'u': // Unset flag
02517         input[0] = command;
02518         activate = true;
02519         break;
02520 
02521         // Decrement
02522         case SDLK_KP_MINUS:
02523         case '-':
02524         command = '-';
02525         input[0] = command;
02526         activate = true;
02527         break;
02528 
02529         // Increment
02530         case SDLK_KP_PLUS:
02531         case '=':
02532         command = '+';
02533         input[0] = command;
02534         activate = true;
02535         break;
02536 
02537         // * Change Flag
02538         case SDLK_KP_MULTIPLY:
02539         case '8':
02540         command = '*';
02541         input[0] = 0;
02542         mode = CP_NFlagNum;
02543         break;
02544 
02545         // X and Escape leave
02546         case SDLK_ESCAPE:
02547         case 'x':
02548         input[0] = command;
02549         looping = false;
02550         break;
02551 
02552         default:
02553         mode = CP_InvalidCom;
02554         input[0] = command;
02555         command = 0;
02556         break;
02557       }
02558     }
02559   }
02560   return CP_Command;
02561 }

Generated on Mon Jul 9 14:42:44 2007 for ExultEngine by  doxygen 1.5.1