- Nuked the storage_gworld and party_template_gworld. Monster, terrain, and PC graphics are now drawn directly from their sheets of origin. This is partly tested, and seems to work fine.

- Removed the terrain_pic and terrain_blockage arrays, which were redundant (though shorter).
- Cleaned out some of the commented code in boe.graphics.cpp and boe.graphutil.cpp
- Added a templated get function to cOutdoors::cWandering.
In the dialog engine:
- Important fields are now initialized to default values, as they should be.
- The absence of required attributes is now recognized as an error
- Added stack element to the DTD; no code support yet
- Added fore attribute to the dialog element to specify default text colour; DTD updated and code support added.
- Likewise with the def-key attribute on other clickable items besides buttons (which already had it)
- Updated stylesheet to fall back on the fore attribute when colour is unspecified
- When drawing default monster graphics, it uses m_start_pic instead of num as the index. This should be right, though it's untested.
Unfortunately, the dialog engine is still unstable.

git-svn-id: http://openexile.googlecode.com/svn/trunk@100 4ebdad44-0ea0-11de-aab3-ff745001d230
This commit is contained in:
2009-06-28 17:18:24 +00:00
parent e5ac5db275
commit 6af129c277
35 changed files with 395 additions and 1120 deletions

View File

@@ -15,7 +15,7 @@
#define BITMAP_WIDTH 28
#define BITMAP_HEIGHT 36
#define STORED_GRAPHICS 240
//#define STORED_GRAPHICS 240
#define PC_WIN_UL_X 291
#define PC_WIN_UL_Y 5

View File

@@ -1790,8 +1790,6 @@ bool handle_keystroke(char chr,char chr2,EventRecord event)
break;
case '`':
//break;
dump_gworld();
break;
case '[':
//break;
@@ -2342,7 +2340,6 @@ void switch_pc(short which)
else if (current_pc == which)
current_pc = current_switch;
set_stat_window(current_pc);
update_pc_graphics();
current_switch = 6;
}
}

View File

@@ -399,7 +399,6 @@ void start_outdoor_combat(cOutdoors::cCreature encounter,ter_num_t in_which_terr
set_pc_moves();
pick_next_pc();
center = pc_pos[current_pc];
load_area_graphics();
draw_buttons(0);
put_pc_screen();
set_stat_window(current_pc);
@@ -4039,7 +4038,6 @@ void end_combat()
}
if (which_combat_type == 0) {
overall_mode = MODE_OUTDOORS;
load_area_graphics();
}
combat_active_pc = 6;
current_pc = store_current_pc;

View File

@@ -58,9 +58,6 @@ extern cUniverse univ;
//extern talking_record_type talking;
extern GWorldPtr pc_gworld;
short terrain_pic[256];
extern cScenarioList scen_headers;
short sign_mode,person_graphic,store_person_graphic,store_sign_mode;
@@ -1130,8 +1127,8 @@ void do_sign(short town_num, short which_sign, short sign_type,location sign_loc
cd_create_dialog(1014,mainPtr);
store_sign_mode = sign_type;
if (terrain_pic[sign_type] < 1000)
csp(1014,3,terrain_pic[sign_type],PICT_TER);
if (scenario.ter_types[sign_type].picture < 1000)
csp(1014,3,scenario.ter_types[sign_type].picture,PICT_TER);
else csp(1014,3,94,PICT_TER);
if (town_num >= 200) {

View File

@@ -19,7 +19,6 @@ extern bool sleep_field;
extern ter_num_t combat_terrain[64][64];
//extern unsigned char out[96][96], univ.out.out_e[96][96];
//extern unsigned char univ.out.misc_i[64][64],univ.out.sfx[64][64];
extern char terrain_blocked[256];
//extern short town_size[3];
extern cScenario scenario;
extern cUniverse univ;
@@ -393,7 +392,7 @@ void make_sfx(short i,short j, short type)
if (get_obscurity(i,j) > 0)
return;
ter = coord_to_ter(i,j);
if (terrain_blocked[ter] != 0)
if (scenario.ter_types[ter].blockage != 0)
return;
switch (type) {
// case 1: case 2:

View File

@@ -57,8 +57,7 @@ extern bool modeless_exists[18];
//extern location monster_targs[60];
extern DialogPtr modeless_dialogs[18] ;
extern short which_combat_type;
extern char terrain_blocked[256];
extern short terrain_pic[256],cur_town_talk_loaded;
extern short cur_town_talk_loaded;
extern cScenario scenario;
extern cUniverse univ;
//extern piles_of_stuff_dumping_type *data_store;
@@ -193,8 +192,6 @@ void finish_load_party(){
// graphics wise
end_startup();
set_up_ter_pics();
load_outdoors(loc(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1),univ.out.outdoors[1][1]);
load_outdoors(loc(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y + 1),univ.out.outdoors[0][1]);
load_outdoors(loc(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y),univ.out.outdoors[1][0]);
@@ -205,12 +202,10 @@ void finish_load_party(){
stat_screen_mode = 0;
build_outdoors();
erase_out_specials();
update_pc_graphics();
if (!town_restore) {
center = univ.party.p_loc;
load_area_graphics();
}
else {
load_town_str(univ.town.num,univ.town.record);
@@ -250,7 +245,6 @@ void finish_load_party(){
blade_wall = true;
sleep_field = true;
center = univ.town.p_loc;
load_area_graphics();
}
create_clip_region();
@@ -628,10 +622,6 @@ void shift_universe_left()
load_outdoors(loc(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y),univ.out.outdoors[0][0]);
load_outdoors(loc(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y + 1),univ.out.outdoors[0][1]);
build_outdoors();
// reload graphics -- who knows what we added
load_area_graphics();
make_cursor_sword();
}
@@ -666,9 +656,6 @@ void shift_universe_right()
load_outdoors(loc(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y),univ.out.outdoors[1][0]);
load_outdoors(loc(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1),univ.out.outdoors[1][1]);
build_outdoors();
// reload graphics -- who knows what we added
load_area_graphics();
make_cursor_sword();
}
@@ -704,9 +691,6 @@ void shift_universe_up()
load_outdoors(loc(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y),univ.out.outdoors[1][0]);
build_outdoors();
// reload graphics -- who knows what we added
load_area_graphics();
make_cursor_sword();
}
@@ -743,9 +727,6 @@ void shift_universe_down()
load_outdoors(loc(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1),univ.out.outdoors[1][1]);
build_outdoors();
// reload graphics -- who knows what we added
load_area_graphics();
make_cursor_sword();
}
@@ -1118,14 +1099,14 @@ void end_data_dump()
// return true;
//}
void set_up_ter_pics()
{
short i;
set_terrain_blocked();
for (i = 0; i < 256; i++)
terrain_pic[i] = scenario.ter_types[i].picture;
}
//void set_up_ter_pics()
//{
// short i;
//
// set_terrain_blocked();
// for (i = 0; i < 256; i++)
// terrain_pic[i] = scenario.ter_types[i].picture;
//}
//void oops_error(short error)
//{
// Str255 error_str;

View File

@@ -27,7 +27,7 @@ void start_data_dump();
void end_data_dump();
void set_terrain(location l, ter_num_t terrain_type);
//void oops_error(short error);
void set_up_ter_pics();
//void set_up_ter_pics();
//bool load_scenario();
short onm(char x_sector,char y_sector);
void build_scen_headers();

View File

@@ -15,7 +15,7 @@
#define BITMAP_WIDTH 28
#define BITMAP_HEIGHT 36
#define STORED_GRAPHICS 240
//#define STORED_GRAPHICS 240
#define PC_WIN_UL_X 291
#define PC_WIN_UL_Y 5

View File

@@ -34,14 +34,7 @@ extern short stat_window,give_delays;
extern eGameMode overall_mode;
extern short current_spell_range,town_type,store_anim_type;
extern bool in_startup_mode,anim_onscreen,play_sounds,frills_on,startup_loaded,party_in_memory;
//extern short town_size[3];
extern short anim_step;
//extern party_record_type univ.party;
//extern big_tr_type t_d;
//extern cOutdoors univ.out.outdoors[2][2];
//extern current_town_type univ.town;
//extern town_item_list t_i;
//extern unsigned char univ.out[96][96],out_e[96][96];
extern ter_num_t combat_terrain[64][64];
extern effect_pat_type current_pat;
extern bool web,crate,barrel,fire_barrier,force_barrier,quickfire,force_wall,fire_wall,antimagic,scloud,ice_wall,blade_wall;
@@ -51,8 +44,6 @@ extern short which_combat_type,current_pc;
extern bool monsters_going,boom_anim_active,cartoon_happening,skip_boom_delay;
extern PicHandle spell_pict;
extern short current_ground;
extern short terrain_pic[256];
//extern short pc_moves[6];
extern short num_targets_left;
extern location spell_targets[8];
extern short display_mode;
@@ -65,27 +56,14 @@ extern Point store_anim_ul;
extern long register_flag;
extern long ed_flag,ed_key;
extern bool fast_bang;
//extern unsigned char m_pic_index[200];
extern Rect bg[];
extern KeyMap key_state;
extern bool fry_startup;
//extern piles_of_stuff_dumping_type *data_store;
extern cScenario scenario;
extern cUniverse univ;
//extern outdoor_strs_type outdoor_text[2][2];
extern GWorldPtr spec_scen_g;
extern DialogPtr modeless_dialogs[18];
extern bool modeless_exists[18];
//extern dlg_filter_t give_password_filter,pick_prefab_scen_event_filter,pick_a_scen_event_filter,tip_of_day_event_filter;
//extern dlg_filter_t talk_notes_event_filter,adventure_notes_event_filter,journal_event_filter,display_strings_event_filter;
//extern dlg_filter_t display_strings_event_filter,display_strings_event_filter,display_strings_event_filter;
//extern dlg_filter_t display_item_event_filter,pick_trapped_monst_event_filter,edit_party_event_filter,display_pc_event_filter;
//extern dlg_filter_t display_alchemy_event_filter,display_help_event_filter,display_pc_item_event_filter,display_monst_event_filter;
//extern dlg_filter_t spend_xp_event_filter,get_num_of_items_event_filter,pick_race_abil_event_filter,sign_event_filter;
//extern dlg_filter_t get_text_response_event_filter,get_text_response_event_filter,select_pc_event_filter;
//extern dlg_filter_t give_pc_info_event_filter,alch_choice_event_filter,pc_graphic_event_filter,pc_name_event_filter;
//extern dlg_filter_t give_reg_info_event_filter,do_registration_event_filter,display_spells_event_filter;
//extern dlg_filter_t display_skills_event_filter,pick_spell_event_filter,prefs_event_filter,fancy_choice_dialog_event_filter;
extern bool show_startup_splash;
RgnHandle clip_region;
@@ -135,12 +113,10 @@ GWorldPtr vehicle_gworld = NULL;
GWorldPtr pc_stats_gworld = NULL;
GWorldPtr item_stats_gworld = NULL;
GWorldPtr text_area_gworld = NULL;
GWorldPtr storage_gworld = NULL; // TODO: Abolish
GWorldPtr terrain_screen_gworld = NULL;
GWorldPtr text_bar_gworld = NULL;
GWorldPtr orig_text_bar_gworld = NULL;
GWorldPtr buttons_gworld = NULL;
GWorldPtr party_template_gworld = NULL;
GWorldPtr items_gworld = NULL;
GWorldPtr tiny_obj_gworld = NULL;
GWorldPtr fields_gworld = NULL;
@@ -162,13 +138,6 @@ GWorldPtr startup_button_orig = NULL;
GWorldPtr startup_button_g = NULL;
GWorldPtr anim_mess = NULL;
// Graphics storage vals
short which_g_stored[STORED_GRAPHICS];
// 0 - 299 terrain graphic 300 + i monster graphic i, face right 600 + i face left
// 1000 + 100 * j + i anim i pos j 2300 + i combat monster graphic i, face right 2600 + i face left
short wish_list[STORED_GRAPHICS];
short storage_status[STORED_GRAPHICS]; // 0 - empty 1 - in use 2 - there, not in use
bool has_run_anim = false,currently_loading_graphics = false;
//short anim_step = 0;
//short overall_anim_step = 0;
@@ -187,9 +156,6 @@ Rect share_mess_source_rect = {0,0,59,120},
Rect start_buttons_source_rect = {0,0,186,190},
start_buttons_rect = {214,30,400,220};
// Variables to store trim. Makes game faster, but wastes 15K. We'll see how it works...
//char out_trim[96][96],town_trim[64][64];
// Array to store which spots have been seen. Time-saver for drawing fields
char spot_seen[9][9];
@@ -219,18 +185,10 @@ void init_dialogs(){
&small_ter_gworld,
&fields_gworld,
&pc_stats_gworld,
&item_stats_gworld,/*
&text_area_gworld,
&storage_gworld,
&terrain_screen_gworld,
&text_bar_gworld,
&orig_text_bar_gworld,
&buttons_gworld,
&party_template_gworld,*/
&item_stats_gworld,
NULL,
&spec_scen_g
);
//cd_register_event_filter(823,give_password_filter);
cd_register_event_filter(869,pick_prefab_scen_event_filter);
cd_register_event_filter(947,pick_a_scen_event_filter);
cd_register_event_filter(958,tip_of_day_event_filter);
@@ -263,7 +221,6 @@ void init_dialogs(){
cd_register_event_filter(1098,pick_spell_event_filter );
cd_register_event_filter(1099,prefs_event_filter );
cd_register_default_event_filter(fancy_choice_dialog_event_filter);
//return &tmp;
}
void adjust_window_mode()
@@ -290,7 +247,7 @@ void adjust_window_mode()
}
create_clip_region();
undo_clip();
if (overall_mode != MODE_STARTUP) { // TODO: This is odd – fix it
if (overall_mode != MODE_STARTUP) { // TODO: This is odd - fix it
if (in_startup_mode == true)
draw_startup(0);
if (in_startup_mode == false)
@@ -367,12 +324,7 @@ void plop_fancy_startup()
SetPort(oldPort);
*/
}
// initialize buffers and rects TODO: Not needed
for (i = 0; i < STORED_GRAPHICS; i++) {
which_g_stored[i] = (i < 50) ? i : 0;
wish_list[i] = 0;
storage_status[i] = (i < 50) ? 1 : 0;
}
// for (i = 0;i < 8; i++)
// OffsetRect(&trim_rects[i],61,37);
for (i = 0; i < 9; i++)
@@ -517,11 +469,6 @@ void fancy_startup_delay()
void init_startup()
{
startup_loaded = true;
// startup_gworld = load_pict(830);
// startup_button_orig = load_pict(832);
// startup_button_g = load_pict(832);
// anim_mess = load_pict(831);
startup_gworld = load_pict("startup.png");
startup_button_orig = load_pict("startbut.png");
startup_button_g = load_pict("startbut.png");
@@ -589,7 +536,7 @@ void draw_startup_anim()
void draw_startup_stats()
{
Rect from_rect,to_rect,party_from = {0,0,36,28},pc_rect,frame_rect;
Rect from_rect,to_rect,party_to = {0,0,36,28},pc_rect,frame_rect;
short i;
Str255 str;
@@ -627,11 +574,10 @@ void draw_startup_stats()
OffsetRect(&pc_rect,60 + 232 * (i / 3) - 9,95 + 45 * (i % 3));
if (univ.party[i].main_status > 0) {
from_rect = party_from;
OffsetRect(&from_rect,56 * (i / 3),36 * (i % 3));
to_rect = party_from,
from_rect = calc_rect(2 * (univ.party[i].which_graphic / 8), univ.party[i].which_graphic % 8);
to_rect = party_to,
OffsetRect(&to_rect,pc_rect.left,pc_rect.top);
rect_draw_some_item(party_template_gworld,from_rect,to_rect,ul,transparent);
rect_draw_some_item(pc_gworld,from_rect,to_rect,ul,transparent);
TextSize(14);
OffsetRect(&pc_rect,35,0);
@@ -827,38 +773,7 @@ void Set_up_win ()
if (dungeon_font_num == 0)
GetFNum(fn3,&dungeon_font_num);
temp_rect.bottom = (STORED_GRAPHICS / 10) * 36;
err = NewGWorld(&storage_gworld, 0 /*8*/,&temp_rect, NULL, NULL, kNativeEndianPixMap);
if (err != 0) {
SysBeep(2);
ExitToShell();
}
// TODO: This relates to the storage gworld, and hence should be abolished
temp_gworld = load_pict("ter1.png");
GetPortBounds(temp_gworld, &r);
rect_draw_some_item(temp_gworld,r,storage_gworld,r);
DisposeGWorld(temp_gworld);
terrain_screen_gworld = load_pict("terscreen.png");
err = NewGWorld(&party_template_gworld, 0 /*8*/,&pc_rect, NULL, NULL, kNativeEndianPixMap);
if (err != 0)
SysBeep(2);
// TODO: These should be loaded later, when a scenario is loaded. Exceptions: dialog pictures and pc graphics
// items_gworld = load_pict(901);
// tiny_obj_gworld = load_pict(900);
// fields_gworld = load_pict(821);
// roads_gworld = load_pict(822);
// boom_gworld = load_pict(823);
// missiles_gworld = load_pict(880);
// dlogpics_gworld = load_pict(850);
//
// // possibly not ideal place for this, but...
// for (i = 0; i < 11; i++)
// monst_gworld[i] = load_pict(1100 + i);
// for (i = 0; i < 7; i++)
// terrain_gworld[i] = load_pict(800 + i);
// anim_gworld = load_pict(820);
// talkfaces_gworld = load_pict(860);
for (i = 0; i < 7; i++)
bw_pats[i] = GetPattern(128 + i * 2);
@@ -1030,38 +945,6 @@ void redraw_screen(){
}
}
//void refresh_screen(short mode)
//{
// if (overall_mode == MODE_TALKING) {
// put_background();
// refresh_talking();
// }
// else if (overall_mode == MODE_SHOPPING) {
// put_background();
// refresh_shopping();
// }
// else {
// draw_buttons(0);
// redraw_terrain();
// if (overall_mode == MODE_COMBAT)
// draw_pcs(pc_pos[current_pc],1);
// if (overall_mode == MODE_FANCY_TARGET)
// draw_targets(center);
// draw_text_bar(1);
// }
//
// draw_text_area(0);
// ShowControl(text_sbar);
// Draw1Control(text_sbar);
// ShowControl(item_sbar);
// Draw1Control(item_sbar);
// if (overall_mode == MODE_SHOPPING) {
// ShowControl(shop_sbar);
// Draw1Control(shop_sbar);
// }
// else HideControl(shop_sbar);
//}
void put_background()
{
Rect bg_pict;
@@ -1268,458 +1151,6 @@ void put_text_bar(char *str)
rect_draw_some_item (text_bar_gworld, win_from_rects[4], win_to_rects[4],ul);
}
// This is called when a new situation is entered. It figures out what graphics are needed,
// sets up which_g_stored, and loads them.
void load_area_graphics()
{
short i;
currently_loading_graphics = true;
// Set all graphics as loseable
for (i = 50; i < STORED_GRAPHICS; i++)
if (storage_status[i] == 1)
storage_status[i] = 2;
for (i = 0; i < STORED_GRAPHICS; i++)
wish_list[i] = 0;
// Build wish list
if (is_out())
load_outdoor_graphics();
if ((is_town()) || (is_combat()))
load_town_graphics();
// Reserve all in wish list not taken
for (i = 0; i < STORED_GRAPHICS; i++)
if (wish_list[i] > 49)
if (reserve_graphic_num_in_array(wish_list[i]) == true)
wish_list[i] = 0;
// Place all graphics not found in array.
for (i = 0; i < STORED_GRAPHICS; i++)
if (wish_list[i] > 49) {
place_graphic_num_in_array(wish_list[i]);
wish_list[i] = 0;
}
// Finally, load graphics.
put_graphics_in_template();
currently_loading_graphics = false;
}
void add_to_wish_list(short which_g)
{
short i;
if (which_g < 50)
return;
for (i = 0; i < STORED_GRAPHICS; i++) {
if (wish_list[i] == which_g)
return;
if (wish_list[i] == 0) {
wish_list[i] = which_g;
return;
}
}
add_string_to_buf("No room for graphic.");
}
// Used to set up array. If graphic there, sets it to be saved, otherwise leaves.
// Returns true is already there
bool reserve_graphic_num_in_array(short which_g)
{
short i;
if (which_g < 50)
return true;
for (i = 50; i < STORED_GRAPHICS; i++)
if (which_g_stored[i] == which_g) {
storage_status[i] = 1;
return true;
}
return false;
}
// Otherwise, puts in array. Note ... if graphic is alreayd here and locked (i.e.
// storage status is 1, this will add a new copy.
void place_graphic_num_in_array(short which_g)
{
short i;
for (i = 50; i < STORED_GRAPHICS; i++)
if ((storage_status[i] == 2) || (storage_status[i] == 0)) {
which_g_stored[i] = which_g;
storage_status[i] = 3;
return;
}
// if we get here, couldn't find a space. Time to flush excess crap.
if (currently_loading_graphics == false)
load_area_graphics(); // calling this is nice and fast, because game won't try to reload
// graphics already there. It'll only purge the trash.
// try again
for (i = 50; i < STORED_GRAPHICS; i++)
if ((storage_status[i] == 2) || (storage_status[i] == 0)) {
which_g_stored[i] = which_g;
storage_status[i] = 3;
return;
}
add_string_to_buf("No room for graphic.");
print_nums(0,0,which_g);
}
void add_one_graphic(short which_g)
{
short i;
for (i = 0; i < STORED_GRAPHICS; i++)
if (which_g_stored[i] == which_g) {
// Good. We got it. Now lock it and leave
storage_status[i] = 1;
return;
}
// otherwise, load it in
place_graphic_num_in_array(which_g);
put_graphics_in_template();
}
void add_terrain_to_wish_list(unsigned short ter)////
{
if (terrain_pic[ter] >= 1000)
return;
else if (terrain_pic[ter] >= 400) {
add_to_wish_list(600 + terrain_pic[ter]);
add_to_wish_list(700 + terrain_pic[ter]);
add_to_wish_list(800 + terrain_pic[ter]);
add_to_wish_list(900 + terrain_pic[ter]);
}
else switch (terrain_pic[ter]) {
case 143:
add_to_wish_list(230);
add_to_wish_list(143);
break;
case 213: case 214:
add_to_wish_list(213);
add_to_wish_list(214);
break;
case 215:
add_to_wish_list(215);
add_to_wish_list(218);
add_to_wish_list(219);
add_to_wish_list(220);
add_to_wish_list(221);
break;
case 216:
add_to_wish_list(216);
add_to_wish_list(222);
add_to_wish_list(223);
add_to_wish_list(224);
add_to_wish_list(225);
break;
case 68: case 69:
add_to_wish_list(68);
add_to_wish_list(69);
break;
case 86: case 87:
add_to_wish_list(86);
add_to_wish_list(87);
break;
default:
add_to_wish_list((short) terrain_pic[ter]);
break;
}
}
void load_outdoor_graphics() ////
{
short l,m,i,j;
short pict;
for (i = 0; i < 96; i++)
for (j = 0; j < 96; j++)
add_terrain_to_wish_list(univ.out[i][j]);
for (l = 0; l < 2; l++)
for (m = 0; m < 2; m++)
for (i = 0; i < 4; i++) {
for (j = 0; j < 7; j++)
if (univ.out.outdoors[l][m].wandering[i].monst[j] != 0) {
pict = get_monst_picnum(univ.out.outdoors[l][m].wandering[i].monst[j]);
//add_monst_graphic(pict,0);
add_monst_graphic(univ.out.outdoors[l][m].wandering[i].monst[j],0);
j = 8;
}
for (j = 0; j < 7; j++)
if (univ.out.outdoors[l][m].special_enc[i].monst[j] != 0) {
pict = get_monst_picnum(univ.out.outdoors[l][m].special_enc[i].monst[j]);
//add_monst_graphic(pict,0);
add_monst_graphic(univ.out.outdoors[l][m].special_enc[i].monst[j],0);
j = 8;
}
}
for (i = 0; i < 10; i++)
if (univ.party.out_c[i].exists == true)
for (j = 0; j < 7; j++)
if (univ.party.out_c[i].what_monst.monst[j] != 0) {
pict = get_monst_picnum(univ.party.out_c[i].what_monst.monst[j]);
//add_monst_graphic(pict, 0);
add_monst_graphic(univ.party.out_c[i].what_monst.monst[j], 0);
j = 8;
}
}
void add_monst_graphic(unsigned short m,short mode)////
// mode 0 - just put in list, 1 - actually add graphics
{
short x,y,i,pict;
get_monst_dims(m,&x,&y);
for (i = 0; i < x * y; i++) {
pict = get_monst_picnum(m);
if (pict >= NUM_MONST_G)
return;
pict = m_pic_index[pict].i;
if (mode == 0) {
add_to_wish_list(300 + pict + i);
add_to_wish_list(600 + pict + i);
add_to_wish_list(2300 + pict + i);
add_to_wish_list(2600 + pict + i);
}
else {
add_one_graphic(300 + pict + i);
add_one_graphic(600 + pict + i);
add_one_graphic(2300 + pict + i);
add_one_graphic(2600 + pict + i);
}
}
}
void load_town_graphics() // Setting up town monsters takes some finess, due to the flexibility
// of the situation
// This can be used for town or beginning outdoor combat
{
short i,j;
for (i = 0; i < univ.town->max_dim(); i++)
for (j = 0; j < univ.town->max_dim(); j++)
if (is_combat())
add_terrain_to_wish_list(combat_terrain[i][j]);
else add_terrain_to_wish_list(univ.town->terrain(i,j));
for (i = 0; i < univ.town->max_monst(); i++)
if ((univ.town.monst[i].number != 0) && (univ.town.monst[i].active > 0))
add_monst_graphic(univ.town.monst[i].number,0);
if (is_town())
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++) {
add_monst_graphic(univ.town->wandering[i].monst[j],0);
}
}
void update_pc_graphics() // TODO: The party_template_gworld isn't really necessary; abolish it
{
short i;
GWorldPtr temp_gworld;//,temp_gworld2;
Rect template_rect = {0,0,36,28};
PixMapHandle store_source, store_dest;
Rect source_rect;
GrafPtr old_port;
if (party_in_memory == false)
return;
GetPort(&old_port);
SetPortWindowPort(mainPtr);
// temp_gworld = load_pict(902);
// temp_gworld2 = load_pict(905);
temp_gworld = load_pict("pcs.png");
for (i = 0; i < 6; i++)
if (univ.party[i].main_status > 0)
if (univ.party[i].which_graphic != which_graphic_index[i]) {
template_rect.left = (i / 3) * 56;
template_rect.right = template_rect.left + 56;
template_rect.top = (i % 3) * 36;
template_rect.bottom = template_rect.top + 36;
store_source = GetPortPixMap(temp_gworld);
source_rect.left = (univ.party[i].which_graphic / 8) * 56;
source_rect.right = source_rect.left + 56;
// source_rect.top = (univ.party[i].which_graphic % 8) * 36;
// source_rect.bottom = template_rect.top + 36;
source_rect.top = 36 * (univ.party[i].which_graphic % 8);
source_rect.bottom = 36 * (univ.party[i].which_graphic % 8) + 36;
store_dest = GetPortPixMap(party_template_gworld);
CopyBits ( (BitMap *) *store_source ,
(BitMap *) *store_dest ,
&source_rect, &template_rect,
0 , NULL);
OffsetRect(&source_rect,0,288);
OffsetRect(&template_rect,0,108);
CopyBits ( (BitMap *) *store_source ,
(BitMap *) *store_dest ,
&source_rect, &template_rect,
0 , NULL);
which_graphic_index[i] = univ.party[i].which_graphic;
}
DisposeGWorld (temp_gworld);
//DisposeGWorld (temp_gworld2);
SetPort(old_port);
}
// This one is complicated, but that's because it's optimized for efficiency.
// Goes through, and loads graphics for anything with storage_status of 3////
void put_graphics_in_template() // TODO: Get rid of this! It's not necessary! Just keep everything in memory!
{
GWorldPtr temp_gworld;
short i,j,which_position,offset;
bool this_graphic_needed = false;
Rect from_rect,to_rect;
// First, load all terrains
for (j = 1; j < 6; j++) {
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= j * 50) && (which_g_stored[i] < j * 50 + 50) &&
(storage_status[i] == 3)) {
this_graphic_needed = true;
}
if (this_graphic_needed == true) {
temp_gworld = load_pict(800 + j);
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= j * 50) && (which_g_stored[i] < j * 50 + 50) &&
(storage_status[i] == 3)) {
which_position = which_g_stored[i] - j * 50;
from_rect = calc_rect(which_position % 10,which_position / 10);
to_rect = calc_rect(i % 10,i / 10);
rect_draw_some_item(temp_gworld,from_rect,storage_gworld,to_rect);
storage_status[i] = 1;
}
DisposeGWorld (temp_gworld);
}
this_graphic_needed = false;
}
// Now, load all monsters
for (j = 0; j < 10; j++) {
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 300 + j * 20) && (which_g_stored[i] < 300 + j * 20 + 20) &&
(storage_status[i] == 3))
this_graphic_needed = true;
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 600 + j * 20) && (which_g_stored[i] < 600 + j * 20 + 20) &&
(storage_status[i] == 3))
this_graphic_needed = true;
if (this_graphic_needed == true) {
temp_gworld = load_pict(1100 + j);
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 300 + j * 20) && (which_g_stored[i] < 300 + j * 20 + 20) &&
(storage_status[i] == 3)) {
which_position = which_g_stored[i] % 20;
from_rect = calc_rect((which_position / 10) * 2,which_position % 10);
to_rect = calc_rect(i % 10,i / 10);
rect_draw_some_item(temp_gworld,from_rect,storage_gworld,to_rect);
storage_status[i] = 1;
}
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 600 + j * 20) && (which_g_stored[i] < 600 + j * 20 + 20) &&
(storage_status[i] == 3)) {
which_position = which_g_stored[i] % 20;
from_rect = calc_rect((which_position / 10) * 2 + 1,which_position % 10);
to_rect = calc_rect(i % 10,i / 10);
rect_draw_some_item(temp_gworld,from_rect,storage_gworld,to_rect);
storage_status[i] = 1;
}
DisposeGWorld (temp_gworld);
}
this_graphic_needed = false;
}
// Now, load all monster combat poses
for (j = 0; j < 10; j++) {
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 2300 + j * 20) && (which_g_stored[i] < 2300 + j * 20 + 20) &&
(storage_status[i] == 3))
this_graphic_needed = true;
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 2600 + j * 20) && (which_g_stored[i] < 2600 + j * 20 + 20) &&
(storage_status[i] == 3))
this_graphic_needed = true;
if (this_graphic_needed == true) {
temp_gworld = load_pict(1200 + j);
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 2300 + j * 20) && (which_g_stored[i] < 2300 + j * 20 + 20) &&
(storage_status[i] == 3)) {
which_position = which_g_stored[i] % 20;
from_rect = calc_rect((which_position / 10) * 2,which_position % 10);
to_rect = calc_rect(i % 10,i / 10);
rect_draw_some_item(temp_gworld,from_rect,storage_gworld,to_rect);
storage_status[i] = 1;
}
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 2600 + j * 20) && (which_g_stored[i] < 2600 + j * 20 + 20) &&
(storage_status[i] == 3)) {
which_position = which_g_stored[i] % 20;
from_rect = calc_rect((which_position / 10) * 2 + 1,which_position % 10);
to_rect = calc_rect(i % 10,i / 10);
rect_draw_some_item(temp_gworld,from_rect,storage_gworld,to_rect);
storage_status[i] = 1;
}
DisposeGWorld (temp_gworld);
}
this_graphic_needed = false;
}
// Now, anim terrains
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 1000) && (which_g_stored[i] < 1400) &&
(storage_status[i] == 3))
this_graphic_needed = true;
if (this_graphic_needed == true) {
temp_gworld = load_pict(820);
for (i = 50; i < STORED_GRAPHICS; i++)
if ((which_g_stored[i] >= 1000) && (which_g_stored[i] < 1400) &&
(storage_status[i] == 3)) {
which_position = which_g_stored[i] % 100;
offset = (which_g_stored[i] - 1000) / 100;
from_rect = calc_rect(4 * (which_position / 5) + offset,which_position % 5);
to_rect = calc_rect(i % 10,i / 10);
rect_draw_some_item(temp_gworld,from_rect,storage_gworld,to_rect);
storage_status[i] = 1;
}
DisposeGWorld (temp_gworld);
}
}
// this is used for determinign whether to round off walkway corners
// right now, trying a restrictive rule (just cave floor and grass, mainly)
bool is_nature(char x, char y, unsigned char ground_t)
@@ -1728,23 +1159,6 @@ bool is_nature(char x, char y, unsigned char ground_t)
ter_type = coord_to_ter((short) x,(short) y);
return ground_t == scenario.ter_types[ter_type].ground_type;
// pic = scenario.ter_types[ter_type].picture;
// if ((pic >= 0) && (pic <= 45))
// return true;
// if ((pic >= 67) && (pic <= 73))
// return true;
// if ((pic >= 75) && (pic <= 87))
// return true;
// if ((pic >= 121) && (pic <= 122))
// return true;
// if ((pic >= 179) && (pic <= 208))
// return true;
// if ((pic >= 211) && (pic <= 212))
// return true;
// if ((pic >= 217) && (pic <= 246))
// return true;
//
// return false;
}
ter_num_t get_ground_from_ter(ter_num_t ter){
@@ -2742,37 +2156,6 @@ void FlushAndPause(unsigned long ticks)
Delay(ticks,&dummy);
}
void dump_gworld()
{
Rect from_rect,to_rect;
GetPortBounds(storage_gworld,&from_rect);
from_rect.top += 180;
to_rect = from_rect;
OffsetRect(&to_rect,0,-180);
to_rect.bottom = to_rect.top + (to_rect.bottom + to_rect.top) / 2;
rect_draw_some_item(storage_gworld,from_rect,to_rect,ul);
play_sound(0);
FlushAndPause(60);
}
// This tells the dialog engine to kill the dialog, and refreshes the screen
//void final_process_dialog(short which_dlog)
//{
// GrafPtr old_port;
//
// cd_kill_dialog(which_dlog,0);
//
// GetPort(&old_port);
// SetPort(GetWindowPort(mainPtr));
// BeginUpdate(mainPtr);
// if (in_startup_mode == false)
// refresh_screen(0);
// else draw_startup(0);
// EndUpdate(mainPtr);
// SetPort(old_port);
//}
/*
void HideMenuBar( void )
{

View File

@@ -20,25 +20,11 @@ void set_gworld_fonts(short font_num);
void redraw_screen();
void put_background();
void draw_main_screen();
//void refresh_screen(short mode);
void draw_buttons(short mode);
void draw_text_area(short mode);
void reset_text_bar();
void draw_text_bar(short mode);
void put_text_bar(char *str);
void load_area_graphics();
void add_to_wish_list(short which_g);
bool reserve_graphic_num_in_array(short which_g);
void place_graphic_num_in_array(short which_g);
//GWorldPtr load_bmp(unsigned char *data, long length);
void add_one_graphic(short which_g);
void add_terrain_to_wish_list(unsigned short ter);
void load_outdoor_graphics();
void add_monst_graphic(unsigned short m,short mode);
void load_town_graphics();
void update_pc_graphics();
void put_graphics_in_template();
//GWorldPtr load_pict(short picture_to_get);
void draw_terrain(short mode = 0);
void place_trim(short q,short r,location where,ter_num_t ter_type);
void draw_trim(short q,short r,short which_trim,short which_mode);
@@ -55,8 +41,6 @@ void undo_clip();
void draw_targeting_line(Point where_curs);
bool party_toast();
void redraw_partial_terrain(Rect redraw_rect);
void dump_gworld();
//void final_process_dialog(short which_dlog);
bool is_nature(char i, char j, unsigned char ground_t);
void put_dialog_graphic(short graphic_num,short spec_g,Rect draw_rect);
void draw_startup_stats();

View File

@@ -46,11 +46,11 @@ extern DialogPtr modeless_dialogs[18];
extern short combat_posing_monster , current_working_monster ; // 0-5 PC 100 + x - monster x
//extern piles_of_stuff_dumping_type *data_store; TODO: Abolish storage_gworld
extern GWorldPtr storage_gworld,terrain_screen_gworld,party_template_gworld,items_gworld,tiny_obj_gworld;
extern GWorldPtr fields_gworld,anim_gworld,vehicle_gworld;
extern short which_g_stored[STORED_GRAPHICS];
extern short wish_list[STORED_GRAPHICS];
extern short storage_status[STORED_GRAPHICS]; // 0 - empty 1 - in use 2 - there, not in use
extern GWorldPtr terrain_screen_gworld,items_gworld,tiny_obj_gworld,pc_gworld,monst_gworld[NUM_MONST_SHEETS];
extern GWorldPtr fields_gworld,anim_gworld,vehicle_gworld,terrain_gworld[NUM_TER_SHEETS];
//extern short which_g_stored[STORED_GRAPHICS];
//extern short wish_list[STORED_GRAPHICS];
//extern short storage_status[STORED_GRAPHICS]; // 0 - empty 1 - in use 2 - there, not in use
extern short terrain_there[9][9];
extern pending_special_type special_queue[20];
@@ -66,7 +66,6 @@ extern short display_mode;
extern long anim_ticks;
extern short terrain_pic[256];
extern char spot_seen[9][9];
//extern char out_trim[96][96],town_trim[64][64];
extern short monster_index[21];
@@ -80,85 +79,6 @@ extern GWorldPtr spec_scen_g;
Rect boat_rects[4] = {{0,0,36,28}, {0,28,36,56},{0,56,36,84},{0,84,36,112}};
bool gave_no_g_error = false;
eAmbientSound ambient_sound;
//unsigned char m_pic_index[200] = {////
//1,2,3,4,5,6,7,8,9,10,
//11,12,13,14,15,16,17,18,19,20,
//
//21,22,23,24,25, 26,27,28,29,30,
//31,32,33,34,35, 36,37,38,39,40,
//
//41,42,43,44,46,47,48,49,50,51,
//53,55,57,59,60,61,62,63,64,65,
//
//66,67,68,69,70, 71,72,73,74,75,
//76,77,78,79,81, 82,83,85,86,87,
//
//88,89,90,91,92, 93,94,95,96,97,
//98,99,100,101,102, 103,104,105,106,107,
//
//108,109,111,112,113, 114,116,117,118,119, //100
//120,122,123,125,127, 128,129,130,131,135,
//
//136,137,139,140,141,142,143,144,145,146,
//147,148,149,150,151,152,152,154,155,159,
//
//160,164,166,168,170,171,172,173,174,175,
//176,177,178,179,180,181,182,183,184,185,
//
//186,187,188,189,190,191,192,193,194,195,
//196,197,198,0,0,0,0,0,0,0,
//
//0,0,0,0,0,0,0,0,0,0,
//0,0,0,0,0,0,0,0,0,0};
//
//unsigned char m_pic_index_x[200] = {
//
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,2,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//
//1,2,1,1,1,2,1,1,1,1, // 100
//2,1,1,1,1,1,1,1,2,1,
//1,2,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,2,1,
//
//2,2,2,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1};
//
//unsigned char m_pic_index_y[200] = {
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,2,
//2,2,2,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,2,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//
//1,1,1,1,1,1,1,1,1,1,
//1,1,2,2,1,1,1,1,2,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,2,1,
//2,1,1,2,1,1,1,1,1,1,
//
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1,
//1,1,1,1,1,1,1,1,1,1};
void draw_one_terrain_spot (short i,short j,short terrain_to_draw) ////
//short dest; // 0 - terrain gworld 1 - screen
@@ -172,8 +92,6 @@ void draw_one_terrain_spot (short i,short j,short terrain_to_draw) ////
GrafPtr old_port;
location l;
source_gworld = storage_gworld;
l.x = i; l.y = j;
if (supressing_some_spaces && (l != ok_space[0]) && (l != ok_space[1]) && (l != ok_space[2]) && (l != ok_space[3]))
return;
@@ -183,54 +101,63 @@ void draw_one_terrain_spot (short i,short j,short terrain_to_draw) ////
if (terrain_to_draw == -1) {
if ((cartoon_happening == false) && (terrain_there[i][j] == 300)) {
return;
}
}
terrain_there[i][j] = 300;
GetPort(&old_port);
SetPort(terrain_screen_gworld);
PaintRect(&where_draw);
SetPort(old_port);
return;
}
}
////
if (terrain_to_draw >= 10000) { // force using a specific graphic
if (terrain_there[i][j] == terrain_to_draw - 10000)
terrain_to_draw -= 10000;
if (terrain_there[i][j] == terrain_to_draw)
return;
terrain_there[i][j] = terrain_to_draw - 10000;
source_rect = return_item_rect(terrain_to_draw - 10000);
source_gworld = terrain_gworld[terrain_to_draw / 50];
terrain_there[i][j] = terrain_to_draw;
terrain_to_draw %= 50;
source_rect = calc_rect(terrain_to_draw % 10, terrain_to_draw / 10);
anim_type = -1;
}
else if (scenario.ter_types[terrain_to_draw].picture >= 2000) { // custom
source_gworld = spec_scen_g;
source_rect = get_custom_rect(scenario.ter_types[terrain_to_draw].picture - 2000 + (anim_ticks % 4));
anim_type = 0;
terrain_there[i][j] = -1;
}
else if (scenario.ter_types[terrain_to_draw].picture >= 1000) { // custom
source_gworld = spec_scen_g;
source_rect = get_custom_rect(scenario.ter_types[terrain_to_draw].picture - 1000);
terrain_there[i][j] = -1;
}
else if (scenario.ter_types[terrain_to_draw].picture >= 400) { // animated
source_gworld = anim_gworld;
terrain_to_draw = scenario.ter_types[terrain_to_draw].picture;
source_rect = calc_rect(4 * ((terrain_to_draw - 400) / 5) + (anim_ticks % 4),(terrain_to_draw - 400) % 5);
terrain_there[i][j] = -1;
anim_type = 0;
}
else {
if (cartoon_happening == false) {
if (terrain_there[i][j] == scenario.ter_types[terrain_to_draw].picture) {
return;
}
terrain_there[i][j] = scenario.ter_types[terrain_to_draw].picture;
}
else if (terrain_pic[terrain_to_draw] >= 2000) { // custom
source_gworld = spec_scen_g;
source_rect = get_custom_rect(terrain_pic[terrain_to_draw] - 2000 + (anim_ticks % 4));
anim_type = 0;
terrain_there[i][j] = -1;
}
else if (terrain_pic[terrain_to_draw] >= 1000) { // custom
source_gworld = spec_scen_g;
source_rect = get_custom_rect(terrain_pic[terrain_to_draw] - 1000);
terrain_there[i][j] = -1;
}
else if (terrain_pic[terrain_to_draw] >= 400) { // animated
source_rect = return_item_rect(terrain_pic[terrain_to_draw] + 600 + 100 * (anim_ticks % 4));
terrain_there[i][j] = -1;
anim_type = 0;
}
else {
if (cartoon_happening == false) {
if (terrain_there[i][j] == terrain_pic[terrain_to_draw]) {
return;
}
terrain_there[i][j] = terrain_pic[terrain_to_draw];
}
source_rect = return_item_rect(terrain_pic[terrain_to_draw]);
anim_type = -1;
}
terrain_to_draw = scenario.ter_types[terrain_to_draw].picture;
source_gworld = terrain_gworld[terrain_to_draw / 50];
terrain_there[i][j] = terrain_to_draw;
terrain_to_draw %= 50;
source_rect = calc_rect(terrain_to_draw % 10, terrain_to_draw / 10);
anim_type = -1;
}
if (anim_type >= 0)
{
if ((is_town()) || (is_out()))
anim_onscreen = true;
}
if (anim_type >= 0)
{
if ((is_town()) || (is_out()))
anim_onscreen = true;
}
rect_draw_some_item(source_gworld, source_rect, terrain_screen_gworld, where_draw);
}
@@ -259,17 +186,14 @@ void draw_monsters() ////
where_draw.y = univ.party.out_c[i].m_loc.y - univ.party.p_loc.y + 4;
terrain_there[where_draw.x][where_draw.y] = -1;
j = 0;
while ((univ.party.out_c[i].what_monst.monst[j] == 0) && (j < 7)) {
j++;
}
for(j = 0; univ.party.out_c[i].what_monst.monst[j] == 0 && j < 7; j++);
if (j == 7) univ.party.out_c[i].exists = false; // begin watch out
else {
picture_wanted = get_monst_picnum(univ.party.out_c[i].what_monst.monst[j]);
} // end watch out
if (univ.party.out_c[i].exists == true) {
if (univ.party.out_c[i].exists) {
get_monst_dims(univ.party.out_c[i].what_monst.monst[j],&width,&height);
if (picture_wanted >= 1000) {
for (k = 0; k < width * height; k++) {
@@ -282,11 +206,11 @@ void draw_monsters() ////
}
if (picture_wanted < 1000) {
for (k = 0; k < width * height; k++) {
source_rect = get_monster_template_rect(univ.party.out_c[i].what_monst.monst[j],
(univ.party.out_c[i].direction < 4) ? 0 : 1,k);
pic_num_t this_monst = univ.party.out_c[i].what_monst.get(j,true,&cMonster::picture_num);
source_rect = get_monster_template_rect(this_monst,(univ.party.out_c[i].direction < 4) ? 0 : 1,k);
to_rect = monst_rects[(width - 1) * 2 + height - 1][k];
OffsetRect(&to_rect,13 + 28 * where_draw.x,13 + 36 * where_draw.y);
rect_draw_some_item(storage_gworld, source_rect, terrain_screen_gworld,to_rect, transparent);
rect_draw_some_item(monst_gworld[m_pic_index[this_monst].i/20], source_rect, terrain_screen_gworld,to_rect, transparent);
}
}
}
@@ -301,7 +225,7 @@ void draw_monsters() ////
where_draw.y = univ.town.monst[i].cur_loc.y - center.y + 4;
get_monst_dims(univ.town.monst[i].number,&width,&height);
if (point_onscreen(center,univ.town.monst[i].cur_loc) == true)
play_see_monster_str(univ.town.monst[i].number);
play_see_monster_str(univ.town.monst[i].number); // TODO: This also gets called by check_if_monst_seen!
for (k = 0; k < width * height; k++) {
store_loc = where_draw;
@@ -312,10 +236,20 @@ void draw_monsters() ////
source_rect = get_custom_rect((univ.town.monst[i].picture_num % 1000) +
k + ((univ.town.monst[i].direction < 4) ? 0 : width * height)
+ ((combat_posing_monster == i + 100) ? (2 * width * height) : 0));
Draw_Some_Item(spec_scen_g, source_rect, terrain_screen_gworld, store_loc, 1, 0);
ter = univ.town->terrain(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y);
// in bed?
if ((store_loc.x >= 0) && (store_loc.x < 9) && (store_loc.y >= 0) && (store_loc.y < 9) &&
(scenario.ter_types[ter].special == TER_SPEC_BED) &&
((univ.town.monst[i].m_type < 7)
&& (univ.town.monst[i].m_type != 1) && (univ.town.monst[i].m_type != 2))
&& ((univ.town.monst[i].active == 1) || (univ.town.monst[i].target == 6)) &&
(width == 1) && (height == 1)) ////
draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + scenario.ter_types[ter].flag1.u);
else Draw_Some_Item(spec_scen_g, source_rect, terrain_screen_gworld, store_loc, 1, 0);
}
if (univ.town.monst[i].picture_num < 1000) {
source_rect = get_monster_template_rect(univ.town.monst[i].number,
pic_num_t this_monst = univ.town.monst[i].picture_num;
source_rect = get_monster_template_rect(this_monst,
((univ.town.monst[i].direction < 4) ? 0 : 1) + ((combat_posing_monster == i + 100) ? 10 : 0),k);
ter = univ.town->terrain(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y);
// in bed?
@@ -326,7 +260,7 @@ void draw_monsters() ////
&& ((univ.town.monst[i].active == 1) || (univ.town.monst[i].target == 6)) &&
(width == 1) && (height == 1)) ////
draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + scenario.ter_types[ter].flag1.u);
else Draw_Some_Item(storage_gworld, source_rect, terrain_screen_gworld, store_loc, 1, 0);
else Draw_Some_Item(monst_gworld[m_pic_index[this_monst].i/20], source_rect, terrain_screen_gworld, store_loc, 1, 0);
}
}
}
@@ -349,10 +283,19 @@ void draw_monsters() ////
source_rect = get_custom_rect((univ.town.monst[i].picture_num % 1000) +
k + ((univ.town.monst[i].direction < 4) ? 0 : width * height)
+ ((combat_posing_monster == i + 100) ? (2 * width * height) : 0));
Draw_Some_Item(spec_scen_g, source_rect, terrain_screen_gworld, store_loc, 1, 0);
ter = univ.town->terrain(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y);
if ((store_loc.x >= 0) && (store_loc.x < 9) && (store_loc.y >= 0) && (store_loc.y < 9) &&
(scenario.ter_types[ter].special == TER_SPEC_BED) &&
((univ.town.monst[i].m_type < 7)
&& (univ.town.monst[i].m_type != 1) && (univ.town.monst[i].m_type != 2))
&& ((univ.town.monst[i].active == 1) || (univ.town.monst[i].target == 6)) &&
(width == 1) && (height == 1))
draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + scenario.ter_types[ter].flag1.u); ////
else Draw_Some_Item(spec_scen_g, source_rect, terrain_screen_gworld, store_loc, 1, 0);
}
if (univ.town.monst[i].picture_num < 1000) {
source_rect = get_monster_template_rect(univ.town.monst[i].number,
pic_num_t this_monst = univ.town.monst[i].picture_num;
source_rect = get_monster_template_rect(this_monst,
((univ.town.monst[i].direction < 4) ? 0 : 1) + ((combat_posing_monster == i + 100) ? 10 : 0)
,k);
ter = univ.town->terrain(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y);
@@ -363,7 +306,7 @@ void draw_monsters() ////
&& ((univ.town.monst[i].active == 1) || (univ.town.monst[i].target == 6)) &&
(width == 1) && (height == 1))
draw_one_terrain_spot((short) where_draw.x,(short) where_draw.y,10000 + scenario.ter_types[ter].flag1.u); ////
else Draw_Some_Item(storage_gworld, source_rect, terrain_screen_gworld, store_loc, 1, 0);
else Draw_Some_Item(monst_gworld[m_pic_index[this_monst].i/20], source_rect, terrain_screen_gworld, store_loc, 1, 0);
}
}
}
@@ -415,12 +358,14 @@ void draw_pcs(location center,short mode)
((cartoon_happening == true) || (party_can_see(pc_pos[i]) < 6))){
where_draw.x = pc_pos[i].x - center.x + 4;
where_draw.y = pc_pos[i].y - center.y + 4;
source_rect = get_party_template_rect(i,(pc_dir[i] < 4) ? 0 : 1);
source_rect = calc_rect(2 * (univ.party[i].which_graphic / 8), univ.party[i].which_graphic % 8);
if(pc_dir[i] >= 4)
OffsetRect(&source_rect,28,0);
if (combat_posing_monster == i)
OffsetRect(&source_rect,0,108);
OffsetRect(&source_rect,0,288);
if (mode == 0) {
Draw_Some_Item(party_template_gworld, source_rect, terrain_screen_gworld, where_draw, 1, 0);
Draw_Some_Item(pc_gworld, source_rect, terrain_screen_gworld, where_draw, 1, 0);
}
if ((current_pc == i) && (mode == 1) && (monsters_going == false)) {
@@ -440,12 +385,14 @@ void draw_pcs(location center,short mode)
if ( ((point_onscreen(center, pc_pos[current_pc])) == true) && (univ.party[current_pc].main_status == 1)) {
where_draw.x = pc_pos[current_pc].x - center.x + 4;
where_draw.y = pc_pos[current_pc].y - center.y + 4;
source_rect = get_party_template_rect(current_pc,(pc_dir[current_pc] < 4) ? 0 : 1);
if (combat_posing_monster == current_pc)
OffsetRect(&source_rect,0,108);
source_rect = calc_rect(2 * (univ.party[current_pc].which_graphic / 8), univ.party[current_pc].which_graphic % 8);
if(pc_dir[current_pc] >= 4)
OffsetRect(&source_rect,28,0);
if (combat_posing_monster == current_pc)
OffsetRect(&source_rect,0,288);
if (mode == 0)
Draw_Some_Item(party_template_gworld, source_rect, terrain_screen_gworld, where_draw, 1, 0);
Draw_Some_Item(pc_gworld, source_rect, terrain_screen_gworld, where_draw, 1, 0);
}
}
@@ -618,12 +565,14 @@ void draw_party_symbol(short mode,location center)
if ((univ.party.in_boat < 0) && (univ.party.in_horse < 0)) {
i = first_active_pc();
source_rect = get_party_template_rect(i,univ.party.direction > 3);
source_rect = calc_rect(2 * (univ.party[current_pc].which_graphic / 8), univ.party[i].which_graphic % 8);
if(pc_dir[current_pc] >= 4)
OffsetRect(&source_rect,28,0);
ter_num_t ter = univ.town->terrain(univ.town.p_loc.x,univ.town.p_loc.y);
// now wedge in bed graphic
if ((is_town()) && (scenario.ter_types[ter].special == TER_SPEC_BED))
draw_one_terrain_spot((short) target.x,(short) target.y,10000 + scenario.ter_types[ter].flag1.u);
else Draw_Some_Item(party_template_gworld, source_rect, terrain_screen_gworld, target, 1, 0);
else Draw_Some_Item(pc_gworld, source_rect, terrain_screen_gworld, target, 1, 0);
}
else if (univ.party.in_boat >= 0) {
//source_rect = boat_rects[dir_array[univ.party.direction]];
@@ -639,49 +588,6 @@ void draw_party_symbol(short mode,location center)
}
}
/* Input terrain currently trying to draw. Get back Rect in terrain template containing
desired pixmap, or Rect to darkness if desired map not present */
Rect get_terrain_template_rect (ter_num_t type_wanted) ////
{
short picture_wanted;
picture_wanted = terrain_pic[type_wanted];
if (picture_wanted >= 400)
return return_item_rect(picture_wanted + 700);
return return_item_rect(picture_wanted);
}
Rect return_item_rect(short wanted)////
{
Rect orig_rect = {0,0,36,28};
short i;
if (wanted < 50) {
OffsetRect(&orig_rect,28 * (wanted % 10),36 * (wanted / 10));
return orig_rect;
}
for (i = 50; i < STORED_GRAPHICS; i++)
if (which_g_stored[i] == wanted) {
OffsetRect(&orig_rect,28 * (i % 10),36 * (i / 10));
return orig_rect;
}
// oops it's not here. better try to add it.
add_one_graphic(wanted);
for (i = 50; i < STORED_GRAPHICS; i++)
if (which_g_stored[i] == wanted) {
OffsetRect(&orig_rect,28 * (i % 10),36 * (i / 10));
return orig_rect;
}
// oh well.
if (gave_no_g_error == false) {
give_error("Blades of Exile doesn't have enough memory to show all the graphics needed. Some things may look like cave floor. The game can still be played safely - restarting isn't necessary.","",0);
gave_no_g_error = true;
}
return orig_rect;
}
// Give the position of the monster graphic in the picture resource
// Will store monsters the same in Exile's II and III
Rect get_monster_rect (unsigned short type_wanted,short mode) ////
@@ -701,24 +607,22 @@ Rect get_monster_rect (unsigned short type_wanted,short mode) ////
}
// Give the position of the monster graphic in the template in memory
Rect get_monster_template_rect (unsigned short type_wanted,short mode,short which_part) ////
Rect get_monster_template_rect (pic_num_t picture_wanted,short mode,short which_part) ////
//mode; // 0 - left 1 - right +10 - combat mode
{
Rect store_rect = {0,0,36,28};
short picture_wanted;
short adj = 0;
short adj;
if (mode >= 10) {adj = 2000; mode -= 10;}
picture_wanted = get_monst_picnum(type_wanted);
if (picture_wanted >= 1000)
return store_rect;
picture_wanted = m_pic_index[picture_wanted].i + which_part;
return return_item_rect(300 + picture_wanted + (300 * mode) + adj);
if (mode >= 10) {
adj += 4;
mode -= 10;
}
if(mode == 0) adj++;
picture_wanted = (m_pic_index[picture_wanted].i + which_part) % 20;
//return return_item_rect(300 + picture_wanted + (300 * mode) + adj);
return calc_rect(2 * (picture_wanted / 10) + adj, picture_wanted % 10);
}
// Returns rect for drawing an item, if num < 25, rect is in big item template,
// otherwise in small item template
Rect get_item_template_rect (short type_wanted)////
@@ -792,75 +696,8 @@ bool is_ground(ter_num_t ter_type)
// if(scenario.ter_types[ter_type].trim_type == TRIM_WALKWAY)
// return false;
return true;
// short pic;
//
// pic = scenario.ter_types[ter_type].picture;
// if ((pic >= 0) && (pic <= 87))
// return true;
// if ((pic >= 121) && (pic <= 122))
// return true;
// if ((pic >= 179) && (pic <= 208))
// return true;
// if ((pic >= 211) && (pic <= 212))
// return true;
// if ((pic >= 215) && (pic <= 246))
// return true;
//
// return false;
}
//void make_town_trim(short mode)
////mode; // 0 - town 1 - outdoor combat
//{
// location where;
// eGameMode store_mode;
//
// store_mode = overall_mode;
// overall_mode = (mode == 0) ? MODE_TOWN : MODE_COMBAT;
// for (where.x = 0; where.x < univ.town->max_dim(); where.x++)
// for (where.y = 0; where.y < univ.town->max_dim(); where.y++)
// town_trim[where.x][where.y] = add_trim_to_array(where,
// (mode == 0) ? univ.town->terrain(where.x,where.y) : combat_terrain[where.x][where.y]);
// for (where.x = 0; where.x < univ.town->max_dim(); where.x++)
// for (where.y = 0; where.y < univ.town->max_dim(); where.y++) {
// if (town_trim[where.x][where.y] & 1)
// town_trim[where.x][where.y] &= 125;
// if (town_trim[where.x][where.y] & 4)
// town_trim[where.x][where.y] &= 245;
// if (town_trim[where.x][where.y] & 10)
// town_trim[where.x][where.y] &= 215;
// if (town_trim[where.x][where.y] & 64)
// town_trim[where.x][where.y] &= 95;
// }
// overall_mode = store_mode;
//}
//void make_out_trim()
//{
// location where;
// eGameMode store_mode;
//
// store_mode = overall_mode;
// overall_mode = MODE_OUTDOORS;
//
// for (where.x = 0; where.x < 96; where.x++)
// for (where.y = 0; where.y < 96; where.y++)
// out_trim[where.x][where.y] = add_trim_to_array(where,univ.out[where.x][where.y]);
// for (where.x = 0; where.x < 96; where.x++)
// for (where.y = 0; where.y < 96; where.y++) {
// if (out_trim[where.x][where.y] & 1)
// out_trim[where.x][where.y] &= 125;
// if (out_trim[where.x][where.y] & 4)
// out_trim[where.x][where.y] &= 245;
// if (out_trim[where.x][where.y] & 10)
// out_trim[where.x][where.y] &= 215;
// if (out_trim[where.x][where.y] & 64)
// out_trim[where.x][where.y] &= 95;
// }
// overall_mode = store_mode;
//
//}
char get_fluid_trim(location where,ter_num_t ter_type)
{
bool at_top = false,at_bot = false,at_left = false,at_right = false;

View File

@@ -5,8 +5,6 @@ void draw_pcs(location center,short mode);
void draw_outd_boats(location center);
void draw_town_boat(location center) ;
void draw_party_symbol(short mode,location center);
Rect get_terrain_template_rect (ter_num_t type_wanted);
Rect return_item_rect(short wanted);
Rect get_monster_rect (unsigned char type_wanted,short mode) ;
Rect get_monster_template_rect (unsigned short type_wanted,short mode,short which_part) ;
Rect get_item_template_rect (short type_wanted);
@@ -14,8 +12,6 @@ bool is_fluid(ter_num_t ter_type);
bool is_shore(ter_num_t ter_type);
bool is_wall(ter_num_t ter_type);
bool is_ground(ter_num_t ter_type);
//void make_town_trim(short mode);
//void make_out_trim();
char get_fluid_trim(location where,ter_num_t ter_type);
void check_if_monst_seen(unsigned short m_num);
void adjust_monst_menu();

View File

@@ -11,10 +11,6 @@
#include "boe.monster.h"
#include "boe.fields.h"
char terrain_blocked[256];
short short_can_see();
bool combat_pt_in_light();
//extern short town_size[3];
@@ -39,14 +35,14 @@ location light_locs[40];
short num_lights = 0;
char d_s[60];
////
void set_terrain_blocked()
{
short i;
for (i = 0; i < 256; i++)
terrain_blocked[i] = scenario.ter_types[i].blockage;
}
//
//void set_terrain_blocked()
//{
// short i;
//
// for (i = 0; i < 256; i++)
// terrain_blocked[i] = scenario.ter_types[i].blockage;
//}
//short dist(location p1,location p2)
//{
@@ -191,7 +187,7 @@ short can_see(location p1,location p2,short mode)
if (p1.x > p2.x) {
for (count = p2.x + 1; count < p1.x; count++) {
storage = storage + get_obscurity(count, p1.y);
if (((terrain_blocked[coord_to_ter(count,p1.y)] > 2) || (is_lava(count,p1.y) == true)) && (mode == 1))
if (((scenario.ter_types[coord_to_ter(count,p1.y)].blockage > 2) || (is_lava(count,p1.y) == true)) && (mode == 1))
return 5;
}
}
@@ -199,7 +195,7 @@ short can_see(location p1,location p2,short mode)
for (count = p1.x + 1; count < p2.x; count++) {
storage = storage + get_obscurity(count, p1.y);
if (((terrain_blocked[coord_to_ter(count,p1.y)] > 2) || (is_lava(count,p1.y) == true)) && (mode == 1))
if (((scenario.ter_types[coord_to_ter(count,p1.y)].blockage > 2) || (is_lava(count,p1.y) == true)) && (mode == 1))
return 5;
}
}
@@ -209,14 +205,14 @@ short can_see(location p1,location p2,short mode)
if (p1.y > p2.y) {
for (count = p1.y - 1; count > p2.y; count--) {
storage = storage + get_obscurity(p1.x, count);
if (((terrain_blocked[coord_to_ter(p1.x,count)] > 2) || (is_lava(p1.x,count) == true)) && (mode == 1))
if (((scenario.ter_types[coord_to_ter(p1.x,count)].blockage > 2) || (is_lava(p1.x,count) == true)) && (mode == 1))
return 5;
}
}
else {
for (count = p1.y + 1; count < p2.y; count++) {
storage = storage + get_obscurity(p1.x, count);
if (((terrain_blocked[coord_to_ter(p1.x,count)] > 2) || (is_lava(p1.x,count) == true)) && (mode == 1))
if (((scenario.ter_types[coord_to_ter(p1.x,count)].blockage > 2) || (is_lava(p1.x,count) == true)) && (mode == 1))
return 5;
}
}
@@ -229,7 +225,7 @@ short can_see(location p1,location p2,short mode)
if (p2.y > p1.y) {
for (count = 1; count < dy; count++) {
storage = storage + get_obscurity(p1.x + (count * dx) / dy, p1.y + count);
if ( ((terrain_blocked[coord_to_ter(p1.x + (count * dx) / dy,p1.y + count)] > 2) ||
if ( ((scenario.ter_types[coord_to_ter(p1.x + (count * dx) / dy,p1.y + count)].blockage > 2) ||
(is_lava(p1.x + (count * dx) / dy,p1.y + count) == true))
&& (mode == 1))
return 5;
@@ -238,7 +234,7 @@ short can_see(location p1,location p2,short mode)
else {
for (count = -1; count > dy; count--) {
storage = storage + get_obscurity(p1.x + (count * dx) / dy, p1.y + count);
if ( ((terrain_blocked[coord_to_ter(p1.x + (count * dx) / dy, p1.y + count)] > 2) ||
if ( ((scenario.ter_types[coord_to_ter(p1.x + (count * dx) / dy, p1.y + count)].blockage > 2) ||
(is_lava(p1.x + (count * dx) / dy, p1.y + count) == true))
&& (mode == 1))
return 5;
@@ -250,7 +246,7 @@ short can_see(location p1,location p2,short mode)
if (p2.x > p1.x) {
for (count = 1; count < dx; count++) {
storage = storage + get_obscurity(p1.x + count, p1.y + (count * dy) / dx);
if (((terrain_blocked[coord_to_ter(p1.x + count,p1.y + (count * dy) / dx)] > 2) ||
if (((scenario.ter_types[coord_to_ter(p1.x + count,p1.y + (count * dy) / dx)].blockage > 2) ||
(is_lava(p1.x + count,p1.y + (count * dy) / dx) == true))
&& (mode == 1))
return 5;
@@ -259,7 +255,7 @@ short can_see(location p1,location p2,short mode)
else {
for (count = -1; count > dx; count--) {
storage = storage + get_obscurity(p1.x + count, p1.y + (count * dy) / dx);
if ( ((terrain_blocked[coord_to_ter(p1.x + count,p1.y + (count * dy) / dx)] > 2) ||
if ( ((scenario.ter_types[coord_to_ter(p1.x + count,p1.y + (count * dy) / dx)].blockage > 2) ||
(is_lava(p1.x + count,p1.y + (count * dy) / dx) == true))
&& (mode == 1))
return 5;
@@ -542,7 +538,7 @@ return false;
bool special_which_blocks_monst(location to_check)
{
if (terrain_blocked[coord_to_ter(to_check.x,to_check.y)] == 2)
if (scenario.ter_types[coord_to_ter(to_check.x,to_check.y)].blockage == 2)
return true;
else return false;
}
@@ -555,7 +551,7 @@ bool is_special(location to_check)
if (special_which_blocks_monst(to_check) == false)
return false;
which_ter = coord_to_ter(to_check.x,to_check.y);
if (terrain_blocked[which_ter] == 2)
if (scenario.ter_types[which_ter].blockage == 2)
return true;
else return false;
}
@@ -563,7 +559,7 @@ bool is_special(location to_check)
bool outd_is_special(location to_check)
{
if (overall_mode == MODE_OUTDOORS) {
if (terrain_blocked[univ.out[to_check.x][to_check.y]] == 2) {
if (scenario.ter_types[univ.out[to_check.x][to_check.y]].blockage == 2) {
return true;
}
else return false;
@@ -573,7 +569,7 @@ bool outd_is_special(location to_check)
bool impassable(ter_num_t terrain_to_check)
{
if (terrain_blocked[terrain_to_check] > 2)
if (scenario.ter_types[terrain_to_check].blockage > 2)
return true;
else return false;
}
@@ -583,9 +579,9 @@ short get_blockage(ter_num_t terrain_type)
// little kludgy in here for pits
if ((terrain_type == 90) && (is_combat()) && (which_combat_type == 0))
return 5;
if ((terrain_blocked[terrain_type] == 5) || (terrain_blocked[terrain_type] == 1))
if ((scenario.ter_types[terrain_type].blockage == 5) || (scenario.ter_types[terrain_type].blockage == 1))
return 5;
else if (terrain_blocked[terrain_type] > 3)
else if (scenario.ter_types[terrain_type].blockage > 3)
return 1;
else {
return 0;
@@ -709,7 +705,7 @@ location push_loc(location from_where,location to_where)
return loc_to_try;
}
if ((get_obscurity((short) loc_to_try.x,(short) loc_to_try.y) > 0) ||
(terrain_blocked[univ.town->terrain(loc_to_try.x,loc_to_try.y)] > 0) ||
(scenario.ter_types[univ.town->terrain(loc_to_try.x,loc_to_try.y)].blockage > 0) ||
(loc_off_act_area(loc_to_try) == true) ||
(monst_there(loc_to_try) < 90) ||
(pc_there(loc_to_try) < 6))
@@ -724,7 +720,7 @@ bool spot_impassable(short i,short j)
ter_num_t ter;
ter = coord_to_ter(i,j);
if (terrain_blocked[ter] == 5)
if (scenario.ter_types[ter].blockage == 5)
return true;
else return false;
}

View File

@@ -1,4 +1,4 @@
void set_terrain_blocked();
//void set_terrain_blocked();
//short dist(location p1,location p2);
//short ex_sqrt(short val);
//short vdist(location p1,location p2) ;

View File

@@ -818,7 +818,6 @@ void handle_file_menu(int item_hit)
draw_startup(0);
}
start_new_game();
update_pc_graphics();
draw_startup(0);
break;
case 6:
@@ -856,7 +855,6 @@ void handle_options_menu(int item_hit)
choice = char_select_pc(0,0,"New graphic for who?");
if (choice < 6)
pick_pc_graphic(choice,1,0);
update_pc_graphics();
draw_terrain();
break;
@@ -871,7 +869,6 @@ void handle_options_menu(int item_hit)
if ((i = FCD(1053,0)) == 2)
kill_pc(choice,MAIN_STATUS_ABSENT);
}
update_pc_graphics();
draw_terrain();
}
break;
@@ -1196,10 +1193,7 @@ pascal OSErr handle_open_app(AppleEvent *theAppleEvent,AppleEvent *reply,long ha
return noErr;
}
pascal OSErr handle_open_doc(AppleEvent *theAppleEvent,AppleEvent *reply,long handlerRefcon)
//AppleEvent *theAppleEvent,*reply;
//long handlerRefcon;
{
pascal OSErr handle_open_doc(AppleEvent *theAppleEvent,AppleEvent *reply,long handlerRefcon){
FSSpec myFSS;
AEDescList docList;
OSErr myErr;
@@ -1219,10 +1213,9 @@ pascal OSErr handle_open_doc(AppleEvent *theAppleEvent,AppleEvent *reply,long ha
do_apple_event_open(myFSS);
if ((in_startup_mode == false) && (startup_loaded == true))
end_startup();
if (in_startup_mode == false) {
if (!in_startup_mode) {
post_load();
}
else update_pc_graphics();
}
}
}

View File

@@ -1305,10 +1305,6 @@ short place_monster(m_num_t which,location where)
univ.town.monst[i].summoned = 0;
univ.town.monst[i].target = 6;
if (univ.town.monst[i].picture_num < 1000) {
add_monst_graphic(which,1);
}
univ.town.set_crate(where.x,where.y,false);
univ.town.set_barrel(where.x,where.y,false);
@@ -1389,7 +1385,6 @@ void activate_monsters(short code,short attitude)
//univ.town.monst[i].cur_loc = univ.town->creatures(i).start_loc;
univ.town.monst[i].target = 6;
add_monst_graphic(univ.town.monst[i].number,1);
univ.town.set_crate(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y,false);
univ.town.set_barrel(univ.town.monst[i].cur_loc.x,univ.town.monst[i].cur_loc.y,false);
}

View File

@@ -316,7 +316,6 @@ void init_party(short mode)
// NOT DEBUG
build_outdoors();
update_pc_graphics();
}
@@ -499,7 +498,7 @@ void put_party_in_scen(string scen_name)
FSGetCatalogInfo(&file_ref, kFSCatInfoNone, NULL, NULL, &file_spec, NULL);
if (!load_scenario(file_spec))
return;
set_up_ter_pics();
init_party_scen_data();
@@ -508,8 +507,6 @@ void put_party_in_scen(string scen_name)
end_startup();
in_startup_mode = false;
set_up_ter_pics();
load_outdoors(loc(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1),univ.out.outdoors[1][1]);
load_outdoors(loc(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y + 1),univ.out.outdoors[0][1]);
load_outdoors(loc(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y),univ.out.outdoors[1][0]);
@@ -517,7 +514,6 @@ void put_party_in_scen(string scen_name)
stat_screen_mode = 0;
build_outdoors();
erase_out_specials();
update_pc_graphics();
current_pc = first_active_pc();
force_town_enter(scenario.which_town_start,scenario.where_start);
@@ -525,7 +521,6 @@ void put_party_in_scen(string scen_name)
center = scenario.where_start;
update_explored(scenario.where_start);
overall_mode = MODE_TOWN;
load_area_graphics();
create_clip_region();
redraw_screen();
set_stat_window(0);
@@ -608,7 +603,6 @@ bool create_pc(short spot,short parent_num)
univ.party[spot].cur_sp = univ.party[spot].max_sp;
}
update_pc_graphics();
return true;
}
@@ -2981,7 +2975,6 @@ void pc_graphic_event_filter (short item_hit)
switch (item_hit) {
case 1:
univ.party[store_graphic_pc_num].which_graphic = store_pc_graphic;
update_pc_graphics();
if (store_graphic_mode == 0)
toast_dialog();
else {
@@ -2991,7 +2984,6 @@ void pc_graphic_event_filter (short item_hit)
break;
case 4:
update_pc_graphics();
if (store_graphic_mode == 0) {
if (univ.party[store_graphic_pc_num].main_status < MAIN_STATUS_ABSENT)
univ.party[store_graphic_pc_num].main_status = MAIN_STATUS_ABSENT;

View File

@@ -63,7 +63,6 @@ bool handle_startup_press(Point the_point)
case STARTBTN_NEW:
draw_startup(0);
start_new_game();
update_pc_graphics();
make_cursor_sword();
draw_startup(0);
break;
@@ -125,7 +124,6 @@ void startup_load()////
FSSpec file_to_load = nav_get_party();
if(load_party(file_to_load)){
party_in_memory = true;
update_pc_graphics();
if(univ.party.scen_name.length() > 0)
in_startup_mode = false;
else in_startup_mode = true;

View File

@@ -71,7 +71,8 @@ extern location dest_locs[40] ;
//extern piles_of_stuff_dumping_type *data_store;
extern cScenario scenario;
extern GWorldPtr spec_scen_g, pc_stats_gworld, item_stats_gworld, text_area_gworld,tiny_obj_gworld,party_template_gworld,invenbtn_gworld,status_gworld;
extern GWorldPtr spec_scen_g, pc_stats_gworld, item_stats_gworld, text_area_gworld,tiny_obj_gworld,invenbtn_gworld,status_gworld;
extern GWorldPtr pc_gworld;
extern short terrain_there[9][9];
// game globals
@@ -548,9 +549,9 @@ void place_item_bottom_buttons()
item_bottom_button_active[i] = true;
to_rect = item_screen_button_rects[i];
rect_draw_some_item (invenbtn_gworld, but_from_rect, item_stats_gworld, to_rect, transparent);
pc_from_rect = get_party_template_rect(i,0);
pc_from_rect = calc_rect(2 * (univ.party[i].which_graphic / 8), univ.party[i].which_graphic % 8);
InsetRect(&to_rect,2,2);
rect_draw_some_item (party_template_gworld, pc_from_rect, item_stats_gworld, to_rect, transparent);
rect_draw_some_item (pc_gworld, pc_from_rect, item_stats_gworld, to_rect, transparent);
}
else item_bottom_button_active[i] = false;
}
@@ -562,19 +563,6 @@ void place_item_bottom_buttons()
rect_draw_some_item(invenbtn_gworld, help_from_rect, item_stats_gworld, to_rect, transparent);
}
Rect get_party_template_rect(short pc_num,short mode)
{
Rect source_rect;
source_rect.top = (pc_num % 3) * BITMAP_HEIGHT;
source_rect.bottom = 36 + (pc_num % 3) * BITMAP_HEIGHT;
source_rect.left = (pc_num / 3) * BITMAP_WIDTH * 2 + ((mode == 1) ? 28 : 0);
source_rect.right = source_rect.left + BITMAP_WIDTH;
return source_rect;
}
void set_stat_window(short new_stat)
{
short i,array_pos = 0;

View File

@@ -5,7 +5,7 @@ void put_pc_screen();
void place_buy_button(short position,short pc_num,short item_num);
void put_item_screen(short screen_num,short suppress_buttons);
void place_item_bottom_buttons();
Rect get_party_template_rect(short pc_num,short mode);
//Rect get_party_template_rect(short pc_num,short mode);
void set_stat_window(short new_stat);
void place_item_button(short which_button_to_put,short which_slot,short which_button_position,short extra_val);
short first_active_pc();

View File

@@ -69,8 +69,6 @@ extern short last_attacked[6],pc_dir[6],pc_parry[6];//,pc_moves[6];
extern location hor_vert_place[14];
extern location diag_place[14];
extern short terrain_pic[256];
extern char terrain_blocked[256];
extern location golem_m_locs[16];
extern ModalFilterUPP main_dialog_UPP;
extern cScenario scenario;
@@ -521,9 +519,6 @@ void start_town_mode(short which_town, short entry_dir)
// make_town_trim(0);
load_area_graphics();
univ.town.p_loc = (entry_dir < 9) ? univ.town->start_locs[entry_dir] : town_force_loc;
center = univ.town.p_loc;
if (univ.party.in_boat >= 0) {
@@ -714,8 +709,6 @@ location end_town_mode(short switching_level,location destination) // returns n
erase_out_specials();
load_area_graphics();
PSD[SDF_PARTY_STEALTHY] = 0;
//PSD[SDF_PARTY_DETECT_LIFE] = 0; //Yes? No? Maybe?
for (i = 0; i < 6; i++)
@@ -1636,11 +1629,11 @@ pascal void draw_map (DialogPtr the_dialog, short the_item)
}
else switch ((pic >= 400) ? anim_map_pats[pic - 400] : map_pats[pic]) {
case 0: case 10: case 11:
if (terrain_pic[what_ter] < 400)
if (scenario.ter_types[what_ter].picture < 400)
OffsetRect(&ter_temp_from,
6 * (terrain_pic[what_ter] % 10),6 * (terrain_pic[what_ter] / 10));
6 * (scenario.ter_types[what_ter].picture % 10),6 * (scenario.ter_types[what_ter].picture / 10));
else OffsetRect(&ter_temp_from,
24 * ((terrain_pic[what_ter] - 400) / 5),6 * ((terrain_pic[what_ter] - 400) % 5) + 156);
24 * ((scenario.ter_types[what_ter].picture - 400) / 5),6 * ((scenario.ter_types[what_ter].picture - 400) % 5) + 156);
rect_draw_some_item(small_ter_gworld,ter_temp_from,map_gworld,draw_rect);
break;

View File

@@ -25,3 +25,9 @@
#include "creatlist.h"
#include "party.h"
#include "universe.h"
extern cScenario scenario;
template<class type> type cOutdoors::cWandering::get(m_num_t who,bool hostile,type cMonster::* what){
if(hostile) return scenario.scen_monsters[monst[who]].*what;
return scenario.scen_monsters[friendly[who]].*what;
}

View File

@@ -133,8 +133,8 @@ public:
unsigned short radiate_2; // I THINK this is the extra field for the second ability TODO: Delete in favour of cAbility
unsigned char default_attitude;
unsigned char summon_type;
unsigned char default_facial_pic;
short picture_num;
pic_num_t default_facial_pic;
pic_num_t picture_num;
str_num_t see_str1, see_str2;
snd_num_t see_sound, ambient_sound; // ambient_sound has a chance of being played every move
spec_num_t see_spec;

View File

@@ -32,6 +32,7 @@ public:
cWandering& operator = (legacy::out_wandering_type old);
void writeTo(std::ostream& file, std::string prefix = "");
void readAttrFrom(std::string cur, std::istream& sin);
template<class type> type get(m_num_t who,bool hostile,type cMonster::* what);
};
class cCreature { // formerly outdoor_creature_type
public:

View File

@@ -52,7 +52,7 @@ public:
bool equip[24];
bool priest_spells[62];
bool mage_spells[62];
short which_graphic;
pic_num_t which_graphic;
short weap_poisoned;
//bool advan[15];
bool traits[15];

View File

@@ -31,9 +31,15 @@ bool cButton::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Poi
return false;
}
cButton::cButton(cDialog* parent) : cControl(parent,CTRL_BTN) {}
cButton::cButton(cDialog* parent) :
cControl(parent,CTRL_BTN),
wrapLabel(false),
fromList("none") {}
cButton::cButton(cDialog* parent,eControlType t) : cControl(parent,t) {}
cButton::cButton(cDialog* parent,eControlType t) :
cControl(parent,t),
fromList("none"),
wrapLabel("true") {/* This constructor is only called for LEDs. TODO: Should wrapLabel be true for LEDs? */}
bool cButton::isClickable(){
return true;
@@ -163,7 +169,12 @@ void cLed::init(){
}
}
cLed::cLed(cDialog* parent) : cButton(parent,CTRL_LED) {}
cLed::cLed(cDialog* parent) :
cButton(parent,CTRL_LED),
state(led_off),
textFont(SILOM),
textSize(10),
color(parent->defTextClr) {}
void cLed::attachClickHandler(click_callback_t f) throw(){
onClick = f;
@@ -237,7 +248,9 @@ void cLed::draw(){
SetPort(old_port);
}
cLedGroup::cLedGroup(cDialog* parent) : cControl(parent,CTRL_GROUP) {}
cLedGroup::cLedGroup(cDialog* parent) :
cControl(parent,CTRL_GROUP),
fromList("none") {}
cButton::~cButton() {}

View File

@@ -233,7 +233,12 @@ void cControl::detachKey(){
this->key.c = 0;
}
cControl::cControl(cDialog* p, eControlType t) : parent(p), type(t), visible(true) {}
cControl::cControl(cDialog* p, eControlType t) : parent(p), type(t), visible(true) {
// No key by default.
key.spec = false;
key.c = 0;
key.mod = mod_none;
}
bool cControl::triggerClickHandler(cDialog& __attribute__((unused)), std::string __attribute__((unused)), eKeyMod __attribute__((unused)), Point __attribute__((unused))){
return true;

View File

@@ -38,6 +38,7 @@ template<> pair<string,cPict*> cDialog::parse(Element& who /*pict*/){
Iterator<Attribute> attr;
std::string name;
bool wide = false, tall = false, custom = false;
bool foundTop = false, foundLeft = false, foundType = false, foundNum = false; // required attributes
int width = 0, height = 0;
p.second = new cPict(this);
for(attr = attr.begin(&who); attr != attr.end(); attr++){
@@ -46,6 +47,7 @@ template<> pair<string,cPict*> cDialog::parse(Element& who /*pict*/){
attr->GetValue(&p.first);
else if(name == "type"){
std::string val;
foundType = true;
attr->GetValue(&val);
if(val == "blank"){
p.second->picType = PIC_TER;
@@ -78,7 +80,7 @@ template<> pair<string,cPict*> cDialog::parse(Element& who /*pict*/){
p.second->picType = PIC_TER_MAP;
else if(val == "status")
p.second->picType = PIC_STATUS;
else throw xBadVal("pict",name,val);
else throw xBadVal("pict",name,val,attr->Row(),attr->Column());
}else if(name == "custom"){
std::string val;
attr->GetValue(&val);
@@ -93,19 +95,31 @@ template<> pair<string,cPict*> cDialog::parse(Element& who /*pict*/){
if(val == "wide") wide = true;
else if(val == "tall") tall = true;
else if(val == "large") wide = tall = true;
else throw xBadVal("pict",name,val);
else throw xBadVal("pict",name,val,attr->Row(),attr->Column());
}else if(name == "def-key"){
std::string val;
attr->GetValue(&val);
try{
p.second->key = parseKey(val);
}catch(int){
throw xBadVal("pict",name,val,attr->Row(),attr->Column());
}
}else if(name == "num"){
attr->GetValue(&p.second->picNum);
attr->GetValue(&p.second->picNum), foundNum = true;
}else if(name == "top"){
attr->GetValue(&p.second->frame.top);
attr->GetValue(&p.second->frame.top), foundTop = true;
}else if(name == "left"){
attr->GetValue(&p.second->frame.left);
attr->GetValue(&p.second->frame.left), foundLeft = true;;
}else if(name == "width"){
attr->GetValue(&width);
}else if(name == "height"){
attr->GetValue(&height);
}else throw xBadAttr("pict",name);
}else throw xBadAttr("pict",name,attr->Row(),attr->Column());
}
if(!foundType) throw xMissingAttr("pict","type",who.Row(),who.Column());
if(!foundNum) throw xMissingAttr("pict","num",who.Row(),who.Column());
if(!foundTop) throw xMissingAttr("pict","top",who.Row(),who.Column());
if(!foundLeft) throw xMissingAttr("pict","left",who.Row(),who.Column());
if(wide && !tall && p.second->picType == PIC_MONST) p.second->picType = PIC_MONST_WIDE;
else if(!wide && tall && p.second->picType == PIC_MONST) p.second->picType = PIC_MONST_TALL;
else if(wide && tall){
@@ -168,6 +182,7 @@ template<> pair<string,cTextMsg*> cDialog::parse(Element& who /*text*/){
Iterator<Node> node;
string name;
int width = 0, height = 0;
bool foundTop = false, foundLeft = false; // top and left are required attributes
p.second = new cTextMsg(this);
for(attr = attr.begin(&who); attr != attr.end(); attr++){
attr->GetName(&name);
@@ -192,7 +207,7 @@ template<> pair<string,cTextMsg*> cDialog::parse(Element& who /*text*/){
p.second->textFont = SILOM;
else if(val == "maidenword")
p.second->textFont = MAIDENWORD;
else throw xBadVal("text",name,val);
else throw xBadVal("text",name,val,attr->Row(),attr->Column());
}else if(name == "size"){
std::string val;
attr->GetValue(&val);
@@ -200,7 +215,7 @@ template<> pair<string,cTextMsg*> cDialog::parse(Element& who /*text*/){
p.second->textSize = 12;
else if(val == "small")
p.second->textSize = 10;
else throw xBadVal("text",name,val);
else throw xBadVal("text",name,val,attr->Row(),attr->Column());
}else if(name == "color" || name == "colour"){
std::string val;
attr->GetValue(&val);
@@ -208,21 +223,31 @@ template<> pair<string,cTextMsg*> cDialog::parse(Element& who /*text*/){
try{
clr = parseColor(val);
}catch(int){
throw xBadVal("text",name,val);
throw xBadVal("text",name,val,attr->Row(),attr->Column());
}
p.second->color = clr;
}else if(name == "def-key"){
std::string val;
attr->GetValue(&val);
try{
p.second->key = parseKey(val);
}catch(int){
throw xBadVal("text",name,val,attr->Row(),attr->Column());
}
}else if(name == "top"){
attr->GetValue(&p.second->frame.top);
attr->GetValue(&p.second->frame.top), foundTop = true;
}else if(name == "left"){
attr->GetValue(&p.second->frame.left);
attr->GetValue(&p.second->frame.left), foundLeft = true;
}else if(name == "width"){
attr->GetValue(&width);
}else if(name == "height"){
attr->GetValue(&height);
}else if(name == "fromlist"){
attr->GetValue(&p.second->fromList);
}else throw xBadAttr("pict",name);
}else throw xBadAttr("pict",name,attr->Row(),attr->Column());
}
if(!foundTop) throw xMissingAttr("text","top",who.Row(),who.Column());
if(!foundLeft) throw xMissingAttr("text","left",who.Row(),who.Column());
p.second->frame.right = p.second->frame.left + width;
p.second->frame.bottom = p.second->frame.top + height;
string content;
@@ -234,7 +259,7 @@ template<> pair<string,cTextMsg*> cDialog::parse(Element& who /*text*/){
else if(type == TiXmlNode::TEXT) content += val;
else{
val = '<' + val + '>';
throw xBadVal("text","<content>",content + val);
throw xBadVal("text","<content>",content + val,node->Row(),node->Column());
}
}
p.second->lbl = content;
@@ -302,6 +327,7 @@ template<> pair<string,cButton*> cDialog::parse(Element& who /*button*/){
Iterator<Node> node;
string name;
int width = 0, height = 0;
bool foundType = false, foundTop = false, foundLeft = false; // required attributes
p.second = new cButton(this);
for(attr = attr.begin(&who); attr != attr.end(); attr++){
attr->GetName(&name);
@@ -313,6 +339,7 @@ template<> pair<string,cButton*> cDialog::parse(Element& who /*button*/){
if(val == "true") p.second->wrapLabel = true;
}else if(name == "type"){
std::string val;
foundType = true;
attr->GetValue(&val);
if(val == "small")
p.second->type = BTN_SM;
@@ -346,20 +373,23 @@ template<> pair<string,cButton*> cDialog::parse(Element& who /*button*/){
try{
p.second->key = parseKey(val);
}catch(int){
throw xBadVal("button",name,val);
throw xBadVal("button",name,val,attr->Row(),attr->Column());
}
}else if(name == "fromlist")
attr->GetValue(&p.second->fromList);
else if(name == "top"){
attr->GetValue(&p.second->frame.top);
attr->GetValue(&p.second->frame.top), foundTop = true;
}else if(name == "left"){
attr->GetValue(&p.second->frame.left);
attr->GetValue(&p.second->frame.left), foundLeft = true;
}else if(name == "width"){
attr->GetValue(&width);
}else if(name == "height"){
attr->GetValue(&height);
}else throw xBadAttr("button",name);
}else throw xBadAttr("button",name,attr->Row(),attr->Column());
}
if(!foundType) throw xMissingAttr("button","type",who.Row(),who.Column());
if(!foundTop) throw xMissingAttr("button","top",who.Row(),who.Column());
if(!foundLeft) throw xMissingAttr("button","left",who.Row(),who.Column());
if(width > 0 || height > 0) {
p.second->frame.right = p.second->frame.left + width;
p.second->frame.bottom = p.second->frame.top + height;
@@ -400,12 +430,12 @@ template<> pair<string,cButton*> cDialog::parse(Element& who /*button*/){
int type = node->Type();
node->GetValue(&val);
if(type == TiXmlNode::ELEMENT && val == "key"){
if(content.length() > 0) throw xBadVal("button","<content>",content + val);
if(content.length() > 0) throw xBadVal("button","<content>",content + val,node->Row(),node->Column());
p.second->labelWithKey = true;
}else if(type == TiXmlNode::TEXT) content += val;
else{
val = '<' + val + '>';
throw xBadVal("text","<content>",val);
throw xBadVal("text","<content>",val,node->Row(),node->Column());
}
}
p.second->lbl = content;
@@ -422,6 +452,7 @@ cKey cDialog::parseKey(string what){
key.spec = false;
key.c = 0;
key.mod = mod_none;
if(what == "none") return key;
istringstream sin(what);
string parts[4];
sin >> parts[0] >> parts[1] >> parts[2] >> parts[3];
@@ -478,6 +509,7 @@ template<> pair<string,cLed*> cDialog::parse(Element& who /*LED*/){
Iterator<Node> node;
string name;
int width = 0, height = 0;
bool foundTop = false, foundLeft = false; // requireds
p.second = new cLed(this);
p.second->type = BTN_LED;
for(attr = attr.begin(&who); attr != attr.end(); attr++){
@@ -490,7 +522,7 @@ template<> pair<string,cLed*> cDialog::parse(Element& who /*LED*/){
if(val == "red") p.second->state = led_red;
else if(val == "green") p.second->state = led_green;
else if(val == "off") p.second->state = led_off;
else throw xBadVal("led",name,val);
else throw xBadVal("led",name,val,attr->Row(),attr->Column());
}else if(name == "fromlist")
attr->GetValue(&p.second->fromList);
else if(name == "font"){
@@ -504,7 +536,7 @@ template<> pair<string,cLed*> cDialog::parse(Element& who /*LED*/){
p.second->textFont = SILOM;
else if(val == "maidenword")
p.second->textFont = MAIDENWORD;
else throw xBadVal("text",name,val);
else throw xBadVal("text",name,val,attr->Row(),attr->Column());
}else if(name == "size"){
std::string val;
attr->GetValue(&val);
@@ -512,7 +544,7 @@ template<> pair<string,cLed*> cDialog::parse(Element& who /*LED*/){
p.second->textSize = 12;
else if(val == "small")
p.second->textSize = 10;
else throw xBadVal("text",name,val);
else throw xBadVal("text",name,val,attr->Row(),attr->Column());
}else if(name == "color" || name == "colour"){
std::string val;
attr->GetValue(&val);
@@ -520,19 +552,21 @@ template<> pair<string,cLed*> cDialog::parse(Element& who /*LED*/){
try{
clr = parseColor(val);
}catch(int){
throw xBadVal("text",name,val);
throw xBadVal("text",name,val,attr->Row(),attr->Column());
}
p.second->color = clr;
}else if(name == "top"){
attr->GetValue(&p.second->frame.top);
attr->GetValue(&p.second->frame.top), foundTop = true;
}else if(name == "left"){
attr->GetValue(&p.second->frame.left);
attr->GetValue(&p.second->frame.left), foundLeft = true;
}else if(name == "width"){
attr->GetValue(&width);
}else if(name == "height"){
attr->GetValue(&height);
}else throw xBadAttr("button",name);
}else throw xBadAttr("button",name,attr->Row(),attr->Column());
}
if(!foundTop) throw xMissingAttr("led","top",who.Row(),who.Column());
if(!foundLeft) throw xMissingAttr("led","left",who.Row(),who.Column());
if(width > 0 || height > 0) {
p.second->frame.right = p.second->frame.left + width;
p.second->frame.bottom = p.second->frame.top + height;
@@ -548,7 +582,7 @@ template<> pair<string,cLed*> cDialog::parse(Element& who /*LED*/){
if(type == TiXmlNode::TEXT) content += val;
else{
val = '<' + val + '>';
throw xBadVal("text","<content>",content + val);
throw xBadVal("text","<content>",content + val,node->Row(),node->Column());
}
}
p.second->lbl = content;
@@ -572,7 +606,7 @@ template<> pair<string,cLedGroup*> cDialog::parse(Element& who /*group*/){
attr->GetValue(&p.first);
else if(name == "fromlist")
attr->GetValue(&p.second->fromList);
else throw xBadAttr("button",name);
else throw xBadAttr("button",name,attr->Row(),attr->Column());
}
string content;
for(node = node.begin(&who); node != node.end(); node++){
@@ -583,7 +617,7 @@ template<> pair<string,cLedGroup*> cDialog::parse(Element& who /*group*/){
p.second->choices.insert(parse<cLed>(*node));
}else{
val = '<' + val + '>';
throw xBadVal("text","<content>", content + val);
throw xBadVal("text","<content>", content + val,node->Row(),node->Column());
}
}
p.second->lbl = content;
@@ -602,6 +636,7 @@ template<> pair<string,cTextField*> cDialog::parse(Element& who /*field*/){
Iterator<Node> node;
string name;
int width = 0, height = 0;
bool foundTop = false, foundLeft = false; // requireds
p.second = new cTextField(this);
for(attr = attr.begin(&who); attr != attr.end(); attr++){
attr->GetName(&name);
@@ -614,17 +649,19 @@ template<> pair<string,cTextField*> cDialog::parse(Element& who /*field*/){
p.second->isNumericField = true;
else if(val == "text")
p.second->isNumericField = false;
else throw xBadVal("field",name,val);
else throw xBadVal("field",name,val,attr->Row(),attr->Column());
}else if(name == "top"){
attr->GetValue(&p.second->frame.top);
attr->GetValue(&p.second->frame.top), foundTop = true;
}else if(name == "left"){
attr->GetValue(&p.second->frame.left);
attr->GetValue(&p.second->frame.left), foundLeft = true;
}else if(name == "width"){
attr->GetValue(&width);
}else if(name == "height"){
attr->GetValue(&height);
}else throw xBadAttr("button",name);
}else throw xBadAttr("button",name,attr->Row(),attr->Column());
}
if(!foundTop) throw xMissingAttr("field","top",attr->Row(),attr->Column());
if(!foundLeft) throw xMissingAttr("field","left",attr->Row(),attr->Column());
p.second->frame.right = p.second->frame.left + width;
p.second->frame.bottom = p.second->frame.top + height;
if(p.first == ""){
@@ -635,13 +672,13 @@ template<> pair<string,cTextField*> cDialog::parse(Element& who /*field*/){
return p;
}
cDialog::cDialog(cDialog* p) : parent(p) {}
cDialog::cDialog(cDialog* p) : parent(p), win(NULL) {}
cDialog::cDialog(std::string path) : parent(NULL){
cDialog::cDialog(std::string path) : parent(NULL), win(NULL){
loadFromFile(path);
}
cDialog::cDialog(std::string path, cDialog* p) : parent(p){
cDialog::cDialog(std::string path, cDialog* p) : parent(p), win(NULL){
loadFromFile(path);
}
@@ -668,7 +705,7 @@ void cDialog::loadFromFile(std::string path){
string type, name, val;
xml.FirstChildElement()->GetValue(&type);
if(type != "dialog") throw xBadNode(type);
if(type != "dialog") throw xBadNode(type,xml.FirstChildElement()->Row(),xml.FirstChildElement()->Column());
for(attr = attr.begin(xml.FirstChildElement()); attr != attr.end(); attr++){
attr->GetName(&name);
attr->GetValue(&val);
@@ -678,10 +715,19 @@ void cDialog::loadFromFile(std::string path){
else{
istringstream sin(val);
sin >> bg;
if(sin.fail()) throw xBadVal(type,name,val);
if(sin.fail()) throw xBadVal(type,name,val,attr->Row(),attr->Column());
}
}else if(name == "fore"){
RGBColor clr;
try{
clr = parseColor(val);
}catch(int){
throw xBadVal("text",name,val,attr->Row(),attr->Column());
}
defTextClr = clr;
}else if(name != "debug")
throw xBadAttr(type,name);
throw xBadAttr(type,name,attr->Row(),attr->Column());
}
for(node = node.begin(xml.FirstChildElement()); node != node.end(); node++){
@@ -701,7 +747,7 @@ void cDialog::loadFromFile(std::string path){
controls.insert(parse<cLed>(*node));
else if(type == "group")
controls.insert(parse<cLedGroup>(*node));
else throw xBadNode(type);
else throw xBadNode(type,node->Row(),node->Column());
}
} catch(Exception& x){ // XML processing exception
printf(x.what());
@@ -715,6 +761,9 @@ void cDialog::loadFromFile(std::string path){
} catch(xBadNode& x){ // Invalid element
printf(x.what());
exit(1);
} catch(xMissingAttr& x){ // Invalid element
printf(x.what());
exit(1);
}
dialogNotToast = true;
bg = BG_DARK; // default is dark background
@@ -731,7 +780,6 @@ void cDialog::loadFromFile(std::string path){
}
iter++;
}
win = NewCWindow(NULL, &winRect, (unsigned char*) "", false, dBoxProc, IN_FRONT, false, 0);
// TODO: Set parent
}
@@ -795,9 +843,14 @@ void cDialog::run(){
GrafPtr old_port;
std::string itemHit = "";
dialogNotToast = true;
if(win == NULL) {
recalcRect();
win = NewCWindow(NULL, &winRect, (unsigned char*) "", false, dBoxProc, IN_FRONT, false, 0);
}
GetPort(&old_port);
ShowWindow(win);
SetPortWindowPort(win);
ShowWindow(win);
SelectWindow(win);
BeginAppModalStateForWindow(win);
while(dialogNotToast){
if(!WaitNextEvent(everyEvent, &currentEvent, 0, NULL))continue;
@@ -964,7 +1017,11 @@ std::string cDialog::process_click(Point where, eKeyMod mods){
return "";
}
xBadNode::xBadNode(std::string t) throw() : type(t), msg(NULL) {}
xBadNode::xBadNode(std::string t, int r, int c) throw() :
type(t),
row(r),
col(c),
msg(NULL) {}
const char* xBadNode::what() throw() {
if(msg == NULL){
@@ -973,7 +1030,7 @@ const char* xBadNode::what() throw() {
printf("Allocation of memory for error message failed, bailing out...");
abort();
}
sprintf(s,"XML Parse Error: Unknown element %s encountered.",type.c_str());
sprintf(s,"XML Parse Error: Unknown element %s encountered (line %d, column %d).",type.c_str(),row,col);
msg = s;
}
return msg;
@@ -983,7 +1040,12 @@ xBadNode::~xBadNode() throw(){
if(msg != NULL) delete msg;
}
xBadAttr::xBadAttr(std::string t, std::string n) throw() : type(t), name(n), msg(NULL) {}
xBadAttr::xBadAttr(std::string t, std::string n, int r, int c) throw() :
type(t),
name(n),
row(r),
col(c),
msg(NULL) {}
const char* xBadAttr::what() throw() {
if(msg == NULL){
@@ -992,7 +1054,7 @@ const char* xBadAttr::what() throw() {
printf("Allocation of memory for error message failed, bailing out...");
abort();
}
sprintf(s,"XML Parse Error: Unknown attribute %s encountered on element %s.",name.c_str(),type.c_str());
sprintf(s,"XML Parse Error: Unknown attribute %s encountered on element %s (line %d, column %d).",name.c_str(),type.c_str(),row,col);
msg = s;
}
return msg;
@@ -1002,7 +1064,37 @@ xBadAttr::~xBadAttr() throw(){
if(msg != NULL) delete msg;
}
xBadVal::xBadVal(std::string t, std::string n, std::string v) throw() : type(t), name(n), val(v), msg(NULL) {}
xMissingAttr::xMissingAttr(std::string t, std::string n, int r, int c) throw() :
type(t),
name(n),
row(r),
col(c),
msg(NULL) {}
const char* xMissingAttr::what() throw() {
if(msg == NULL){
char* s = new (nothrow) char[100];
if(s == NULL){
printf("Allocation of memory for error message failed, bailing out...");
abort();
}
sprintf(s,"XML Parse Error: Required attribute %s missing on element %s (line %d, column %d).",name.c_str(),type.c_str(),row,col);
msg = s;
}
return msg;
}
xMissingAttr::~xMissingAttr() throw(){
if(msg != NULL) delete msg;
}
xBadVal::xBadVal(std::string t, std::string n, std::string v, int r, int c) throw() :
type(t),
name(n),
val(v),
row(r),
col(c),
msg(NULL) {}
const char* xBadVal::what() throw() {
if(msg == NULL){
@@ -1011,7 +1103,7 @@ const char* xBadVal::what() throw() {
printf("Allocation of memory for error message failed, bailing out...");
abort();
}
sprintf(s,"XML Parse Error: Invalid value %s for attribute %s encountered on element %s.",val.c_str(),name.c_str(),type.c_str());
sprintf(s,"XML Parse Error: Invalid value %s for attribute %s encountered on element %s (line %d, column %d).",val.c_str(),name.c_str(),type.c_str(),row,col);
msg = s;
}
return msg;

View File

@@ -7,32 +7,34 @@
<!ELEMENT button (#PCDATA*|key)>
<!ELEMENT led (CDATA)>
<!ELEMENT group (led+)>
<!ELEMENT stack ((field | text | pict | button | led | group)*)>
<!ENTITY % num 'NUMBER'>
<!ENTITY % bool '(true|false)'>
<!ENTITY % picttype '(blank|ter|teranim|monst|dlog|talk|scen|item|pc|field|boom|missile|full|map|status)'>
<!ENTITY % rect '
top %num; #REQUIRED
left %num; #REQUIRED
width %num; #IMPLIED
height %num; #IMPLIED'
>
<!ENTITY % font "
font (dungeon|geneva|silom|maidenword) 'silom'
size (small|large) 'small'
color CDATA '#000000'"
colour CDATA '#000000'"
>
<!ENTITY % btntype '(small|regular|large|help|left|right|up|down|tiny|done|tall|trait|push)'>
<!ENTITY % digit '(0|1|2|3|4|5|6|7|8|9)'>
<!ENTITY % letter '(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)'>
<!ENTITY % symbol '(`|-|=|[|]|\|;|'|,|.|/)'>
<!ENTITY % mod '((ctrl|shift|alt)*)'>
<!ENTITY % key '(%mod; (%digit;|%letter;|%symbol;|left|right|up|down|esc|enter|return|tab|help|space))'>
<!ENTITY % rect '
top %num; #REQUIRED
left %num; #REQUIRED
width %num; #IMPLIED
height %num; #IMPLIED
'>
<!ENTITY % font "
font (dungeon|geneva|silom|maidenword) 'silom'
size (small|large) 'small'
color CDATA #IMPLIED
colour CDATA #IMPLIED
">
<!ATTLIST dialog
skin (light|dark) 'dark'
debug %bool; 'false'
fore CDATA 'black'
>
<!ATTLIST field
name ID #IMPLIED
@@ -43,6 +45,7 @@
name ID #IMPLIED
framed %bool; 'true'
%font;
def-key (%key;|none) 'none'
clickable %bool; 'false'
fromlist (none|CDATA) 'none'
%rect;
@@ -52,6 +55,7 @@
type %picttype; #REQUIRED
custom %bool; 'false'
size (small|wide|tall|large) #IMPLIED
def-key (%key;|none) 'none'
clickable %bool; 'false'
num %num; #REQUIRED
%rect;
@@ -60,7 +64,7 @@
name ID #IMPLIED
type %btntype; #REQUIRED
wrap %bool; 'false'
def-key %key; 'none'
def-key (%key;|none) 'none'
fromlist (none|CDATA) 'none'
%rect;
>
@@ -75,3 +79,6 @@
name ID #IMPLIED
fromlist (none|CDATA) 'none'
>
<!ATTLIST stack
name ID #IMPLIED
>

View File

@@ -74,27 +74,40 @@ private:
class xBadNode : std::exception {
std::string type;
int row, col;
const char* msg;
public:
xBadNode(std::string t) throw();
xBadNode(std::string t, int r, int c) throw();
~xBadNode() throw();
const char* what() throw();
};
class xBadAttr : std::exception {
std::string type, name;
int row, col;
const char* msg;
public:
xBadAttr(std::string t,std::string n) throw();
xBadAttr(std::string t,std::string n, int r, int c) throw();
~xBadAttr() throw();
const char* what() throw();
};
class xMissingAttr : std::exception {
std::string type, name;
int row, col;
const char* msg;
public:
xMissingAttr(std::string t,std::string n, int r, int c) throw();
~xMissingAttr() throw();
const char* what() throw();
};
class xBadVal : std::exception {
std::string type, name, val;
int row, col;
const char* msg;
public:
xBadVal(std::string t,std::string n,std::string v) throw();
xBadVal(std::string t,std::string n,std::string v, int r, int c) throw();
~xBadVal() throw();
const char* what() throw();
};

View File

@@ -86,7 +86,7 @@ background-image: url('bg/<xsl:value-of select='/dialog/@skin'/>.png');
<xsl:if test='/dialog/@debug = "true"'>debug</xsl:if>
</xsl:attribute>
<xsl:attribute name='style'>
color: <xsl:value-of select='./@color'/>;
color: <xsl:value-of select='./@color'/> <xsl:value-of select='/dialog/@fore'/>;
font-family:
<xsl:choose>
<xsl:when test='@font = "plain"'>Geneva</xsl:when>
@@ -108,7 +108,7 @@ background-image: url('bg/<xsl:value-of select='/dialog/@skin'/>.png');
<xsl:if test='/dialog/@debug = "true"'>debug</xsl:if>
</xsl:attribute>
<xsl:attribute name='style'>
color: <xsl:value-of select='./@color'/>;
color: <xsl:value-of select='./@color'/> <xsl:value-of select='/dialog/@fore'/>;
font-family:
<xsl:choose>
<xsl:when test='@font = "plain"'>Geneva</xsl:when>
@@ -133,7 +133,7 @@ background-image: url('bg/<xsl:value-of select='/dialog/@skin'/>.png');
<xsl:if test='/dialog/@debug = "true"'>debug</xsl:if>
</xsl:attribute>
<xsl:attribute name='style'>
color: <xsl:value-of select='./@color'/>;
color: <xsl:value-of select='./@color'/> <xsl:value-of select='/dialog/@fore'/>;
font-family: <xsl:value-of select='./@font'/>;
left: <xsl:value-of select='./@left'/>px; top: <xsl:value-of select='./@top'/>px;
width: <xsl:value-of select='./@width'/>px; height: <xsl:value-of select='./@height'/>px;

View File

@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
<!DOCTYPE dialog SYSTEM "dialog.dtd">
<dialog skin='light' debug='true'>
<dialog skin='light' fore='black' debug='true'>
<text size='large' top='6' left='50' height='17' width='138'>Edit Terrain Type</text>
<pict name='graphic' type='ter' num='0' top='8' left='8'/>
<text top='8' left='222' height='14' width='111'>Terrain number:</text>

View File

@@ -51,7 +51,9 @@ bool cTextField::isClickable(){
return false;
}
cTextField::cTextField(cDialog* parent) : cControl(parent,CTRL_FIELD) {
cTextField::cTextField(cDialog* parent) :
cControl(parent,CTRL_FIELD),
isNumericField(false) {
OSStatus err;
err = CreateEditTextControl(parent->win,&frame,NULL,false,true/*useInlineInput*/,NULL,&theField);
}

View File

@@ -93,7 +93,14 @@ short cTextMsg::getFormat(eFormat prop) throw(xUnsupportedProp){
return 0;
}
cTextMsg::cTextMsg(cDialog* parent) : cControl(parent,CTRL_TEXT), drawFramed(true), textFont(SILOM), textSize(10) {}
cTextMsg::cTextMsg(cDialog* parent) :
cControl(parent,CTRL_TEXT),
drawFramed(true),
textFont(SILOM),
textSize(10),
color(parent->defTextClr),
clickable(false),
fromList("none") {}
bool cTextMsg::isClickable(){
return clickable;

View File

@@ -250,7 +250,9 @@ ePicType cPict::getPicType(){
return picType;
}
cPict::cPict(cDialog* parent) : cControl(parent,CTRL_PICT) {}
cPict::cPict(cDialog* parent) :
cControl(parent,CTRL_PICT),
clickable(false) {}
bool cPict::isClickable(){
return clickable;
@@ -580,7 +582,7 @@ void cPict::drawPresetMonstSm(short num, Rect to_rect){
if(!isSheetSet(SHEET_MONST,m_start_pic / 20)) throw xMissingSheet(SHEET_MONST,m_start_pic / 20);
GWorldPtr from_gw = monst[m_start_pic / 20];
m_start_pic = m_start_pic % 20;
Rect from_rect = calcDefMonstRect(num, animFrame);
Rect from_rect = calcDefMonstRect(m_start_pic, animFrame);
to_rect.right = to_rect.left + 28;
to_rect.bottom = to_rect.top + 36;
PaintRect(&to_rect);