diff --git a/osx/Blades of Exile Char Editor/pc.action.cpp b/osx/Blades of Exile Char Editor/pc.action.cpp index f6fc9860..6815986b 100644 --- a/osx/Blades of Exile Char Editor/pc.action.cpp +++ b/osx/Blades of Exile Char Editor/pc.action.cpp @@ -1,4 +1,4 @@ -#include +#include #include "pc.graphics.h" #include "pc.global.h" @@ -31,7 +31,7 @@ extern cUniverse univ; extern WindowPtr mainPtr; extern bool file_in_mem; -extern short current_cursor,dialog_answer; +extern short dialog_answer; //extern long register_flag; extern GWorldPtr pc_gworld; diff --git a/osx/Blades of Exile Char Editor/pc.editors.cpp b/osx/Blades of Exile Char Editor/pc.editors.cpp index d4f69e3c..f644fadb 100644 --- a/osx/Blades of Exile Char Editor/pc.editors.cpp +++ b/osx/Blades of Exile Char Editor/pc.editors.cpp @@ -25,7 +25,7 @@ extern short current_active_pc; extern WindowPtr mainPtr; extern Rect d_rects[80]; -extern short d_rect_index[80],current_cursor; +extern short d_rect_index[80]; extern bool modeless_exists[12],diff_depth_ok,current_file_has_maps; extern short modeless_key[12]; diff --git a/osx/Blades of Exile Char Editor/pc.fileio.cpp b/osx/Blades of Exile Char Editor/pc.fileio.cpp index 45809939..eb7c4b21 100644 --- a/osx/Blades of Exile Char Editor/pc.fileio.cpp +++ b/osx/Blades of Exile Char Editor/pc.fileio.cpp @@ -1,6 +1,6 @@ -//#inculde -#include -#include +//#inculde +#include +#include #include "pc.global.h" #include "classes.h" diff --git a/osx/Blades of Exile Char Editor/pc.graphics.cpp b/osx/Blades of Exile Char Editor/pc.graphics.cpp index a975d8c6..dac2ce77 100644 --- a/osx/Blades of Exile Char Editor/pc.graphics.cpp +++ b/osx/Blades of Exile Char Editor/pc.graphics.cpp @@ -1,6 +1,6 @@ -//#include -#include -#include +//#include +#include +#include #include "pc.global.h" #include "classes.h" #include "pc.graphics.h" @@ -12,17 +12,6 @@ #include "dlglowlevel.h" #include "dlgutil.h" -/* Adventure globals */ -//extern party_record_type party; -//extern outdoor_record_type outdoors[2][2]; -//extern current_town_type c_town; -//extern big_tr_type t_d; -//extern town_item_list t_i; -//extern unsigned char out[96][96],out_e[96][96]; -//extern setup_save_type setup_save; -//extern stored_items_list_type stored_items[3]; -//extern stored_town_maps_type maps; -//extern stored_outdoor_maps_type o_maps; extern cUniverse univ; extern WindowPtr mainPtr; @@ -37,7 +26,7 @@ extern short current_active_pc; //extern long ed_flag,ed_key; GWorldPtr title_gworld,pc_gworld,dlogpics_gworld; -GWorldPtr mixed_gworld,buttons_gworld; +GWorldPtr buttons_gworld,invenbtn_gworld,status_gworld; //GWorldPtr race_dark,train_dark,items_dark,spells_dark; //GWorldPtr race_light,train_light,items_light,spells_light; Rect whole_win_rect = {0,0,440,590}; @@ -67,6 +56,10 @@ Rect ed_buttons_from[2] = {{0,0,57,57},{0,57,57,114}}; short current_pressed_button = -1; bool init_once = false; GWorldPtr spec_scen_g; // not actually needed; just here to silence compiler because it's reference in fileio.h +// (actually, it WILL be needed eventually; the same is true about most of the rest of these.) +GWorldPtr items_gworld,tiny_obj_gworld,fields_gworld,roads_gworld,boom_gworld,missiles_gworld; +GWorldPtr monst_gworld[11],terrain_gworld[7],anim_gworld,talkfaces_gworld; +GWorldPtr vehicle_gworld, small_ter_gworld; void init_dialogs(){ cd_init_dialogs(NULL,NULL,NULL,NULL,NULL,&dlogpics_gworld,NULL,NULL,NULL,NULL,NULL,NULL/*,NULL,NULL,NULL,NULL,NULL,NULL,NULL*/,NULL,NULL); @@ -268,11 +261,16 @@ void init_main_buttons() void Set_up_win () { short i; - title_gworld = load_pict(5000); - pc_gworld = load_pict(902); - mixed_gworld = load_pict(903); - dlogpics_gworld = load_pict(850); - buttons_gworld = load_pict(5001); +// title_gworld = load_pict(5000); +// pc_gworld = load_pict(902); +// mixed_gworld = load_pict(903); +// dlogpics_gworld = load_pict(850); +// buttons_gworld = load_pict(5001); + title_gworld = load_pict("pcedtitle.png"); + invenbtn_gworld = load_pict("invenbtns.png"); + status_gworld = load_pict("staticons.png"); + dlogpics_gworld = load_pict("dlogpics.png"); + buttons_gworld = load_pict("pcedbuttons.png"); for (i = 0; i < 14; i++){ bg[i] = GetPixPat (128 + i); @@ -376,53 +374,6 @@ void do_button_action(short which_pc,short which_button) display_party(6,0); } -GWorldPtr load_pict(short picture_to_get) -{ - PicHandle current_pic_handle; - Rect pic_rect; - short pic_wd,pic_hgt; - GWorldPtr myGWorld; - CGrafPtr origPort; - GDHandle origDev; - QDErr check_error; - PixMapHandle offPMHandle; - char good; - - current_pic_handle = GetPicture (picture_to_get); - if (current_pic_handle == NULL) { - SysBeep(2);SysBeep(50);SysBeep(50); - ExitToShell(); - } - QDGetPictureBounds(current_pic_handle, &pic_rect); - pic_wd = pic_rect.right - pic_rect.left; - pic_hgt = pic_rect.bottom - pic_rect.top; - GetGWorld (&origPort, &origDev); - check_error = NewGWorld (&myGWorld, 0, - &pic_rect, - NULL, NULL, kNativeEndianPixMap); - if (check_error != noErr) { - SysBeep(50); -// sprintf((char *) debug, "Stuck on %d ",(short) picture_to_get); -// add_string_to_buf((char *)debug); -// print_buf(); -// ExitToShell(); - } - - SetGWorld(myGWorld, NULL); - - offPMHandle = GetGWorldPixMap (myGWorld); - good = LockPixels (offPMHandle); - if (good == false) { - SysBeep(50); } - SetRect (&pic_rect, 0, 0, pic_wd, pic_hgt); - DrawPicture (current_pic_handle, &pic_rect); - SetGWorld (origPort, origDev); - UnlockPixels (offPMHandle); - ReleaseResource ((Handle) current_pic_handle); - - return myGWorld; -} - //extern Rect pc_area_buttons[6][6] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later //extern Rect item_string_rects[24][4]; // 0 - name 1 - drop 2 - id 3 - void draw_items(short clear_first) @@ -479,8 +430,8 @@ void draw_items(short clear_first) char_win_draw_string(mainPtr,item_string_rects[i][0],(char *) to_draw,0,10,true); //Draw id/drop buttons - rect_draw_some_item(mixed_gworld,d_from,mixed_gworld,item_string_rects[i][1],1,1); - rect_draw_some_item(mixed_gworld,i_from,mixed_gworld,item_string_rects[i][2],1,1); + rect_draw_some_item(invenbtn_gworld,d_from,invenbtn_gworld,item_string_rects[i][1],1,1); + rect_draw_some_item(invenbtn_gworld,i_from,invenbtn_gworld,item_string_rects[i][2],1,1); } frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // re draw entire frame frame_dlog_rect(GetWindowPort(mainPtr),name_rect,1); // draw the frame diff --git a/osx/Blades of Exile Char Editor/pc.main.cpp b/osx/Blades of Exile Char Editor/pc.main.cpp index 304b3b90..c23788d6 100644 --- a/osx/Blades of Exile Char Editor/pc.main.cpp +++ b/osx/Blades of Exile Char Editor/pc.main.cpp @@ -1,7 +1,7 @@ -//#include +//#include #include -#include +#include #include "pc.global.h" #include "classes.h" #include "pc.graphics.h" @@ -60,7 +60,6 @@ bool scen_items_loaded = false; //unsigned char template_terrain[64][64]; short store_flags[3]; -extern short sword_curs; //town_record_type anim_town; //tiny_tr_type anim_t_d; @@ -93,7 +92,6 @@ void handle_reg_menu(int item_hit); void handle_extra_menu(int item_hit); void handle_edit_menu(int item_hit); void update_item_menu(); -void set_cursor(CursHandle which_curs); void find_quickdraw(); void check_sys_7(); pascal OSErr handle_open_app(AppleEvent *theAppleEvent,AppleEvent *reply,long handlerRefcon); @@ -173,6 +171,7 @@ int main(void) while (All_Done == false) Handle_One_Event(); restore_depth(); + clean_up_graphtool(); return 0; } diff --git a/osx/BoE.xcodeproj/project.pbxproj b/osx/BoE.xcodeproj/project.pbxproj index a15de534..f4e9bd85 100644 --- a/osx/BoE.xcodeproj/project.pbxproj +++ b/osx/BoE.xcodeproj/project.pbxproj @@ -113,6 +113,14 @@ 9141DAC40FCB95CA0047D3A3 /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBA2A0FB8C459001E34EA /* tinyxml.cpp */; }; 9141DAC50FCB95CA0047D3A3 /* tinyxmlerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBA2C0FB8C459001E34EA /* tinyxmlerror.cpp */; }; 9141DAC60FCB95CB0047D3A3 /* tinyxmlparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBA2D0FB8C459001E34EA /* tinyxmlparser.cpp */; }; + 91A32B6A0FDB5F1000C4E957 /* choose-pict.xml in Copy Dialogs */ = {isa = PBXBuildFile; fileRef = 91A32B670FDB5F1000C4E957 /* choose-pict.xml */; }; + 91A32B6B0FDB5F1000C4E957 /* choose-string.xml in Copy Dialogs */ = {isa = PBXBuildFile; fileRef = 91A32B680FDB5F1000C4E957 /* choose-string.xml */; }; + 91A32B6C0FDB5F1000C4E957 /* edit-terrain.xml in Copy Dialogs */ = {isa = PBXBuildFile; fileRef = 91A32B690FDB5F1000C4E957 /* edit-terrain.xml */; }; + 91A32B770FDB5F6800C4E957 /* arena-names.txt in Copy String Lists */ = {isa = PBXBuildFile; fileRef = 91A32B720FDB5F6800C4E957 /* arena-names.txt */; }; + 91A32B780FDB5F6800C4E957 /* ter-flag1.txt in Copy String Lists */ = {isa = PBXBuildFile; fileRef = 91A32B730FDB5F6800C4E957 /* ter-flag1.txt */; }; + 91A32B790FDB5F6800C4E957 /* ter-flag2.txt in Copy String Lists */ = {isa = PBXBuildFile; fileRef = 91A32B740FDB5F6800C4E957 /* ter-flag2.txt */; }; + 91A32B7A0FDB5F6800C4E957 /* ter-flag3.txt in Copy String Lists */ = {isa = PBXBuildFile; fileRef = 91A32B750FDB5F6800C4E957 /* ter-flag3.txt */; }; + 91A32B7B0FDB5F6800C4E957 /* trim-names.txt in Copy String Lists */ = {isa = PBXBuildFile; fileRef = 91A32B760FDB5F6800C4E957 /* trim-names.txt */; }; 91A79DC70FA797BF00A6A41F /* menu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 91A79DC60FA797BF00A6A41F /* menu.xib */; }; 91AC60800FA26A3B00EEAE67 /* regtown.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC607F0FA26A3B00EEAE67 /* regtown.cpp */; }; 91AC60810FA26A3B00EEAE67 /* regtown.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC607F0FA26A3B00EEAE67 /* regtown.cpp */; }; @@ -141,7 +149,6 @@ 91B3EF490F969F2300BF5B67 /* pc.action.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EF060F969BD300BF5B67 /* pc.action.cpp */; }; 91B3EF4A0F969F2300BF5B67 /* pc.editors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EF070F969BD300BF5B67 /* pc.editors.cpp */; }; 91B3EF4B0F969F2300BF5B67 /* pc.fileio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EF080F969BD300BF5B67 /* pc.fileio.cpp */; }; - 91B3EF4D0F969F2300BF5B67 /* pc.graphics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EF0A0F969BD300BF5B67 /* pc.graphics.cpp */; }; 91B3EF500F969F3000BF5B67 /* scen.main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EEEB0F969BA700BF5B67 /* scen.main.cpp */; }; 91B3EF530F969F3000BF5B67 /* scen.keydlgs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EEEE0F969BA700BF5B67 /* scen.keydlgs.cpp */; }; 91B3EF540F969F3000BF5B67 /* scen.core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EEEF0F969BA700BF5B67 /* scen.core.cpp */; }; @@ -158,6 +165,13 @@ 91C1FCA90FCB6F7200EBAA65 /* field.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBAB50FB91A26001E34EA /* field.cpp */; }; 91C1FCAA0FCB6F7200EBAA65 /* message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBAB90FB91ADB001E34EA /* message.cpp */; }; 91C1FCAB0FCB6F7300EBAA65 /* pict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBAA90FB8F733001E34EA /* pict.cpp */; }; + 91C6864A0FD5EEFD000F6D01 /* pc.graphics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EF0A0F969BD300BF5B67 /* pc.graphics.cpp */; }; + 91C686FA0FD5F217000F6D01 /* graphics.exd in CopyFiles */ = {isa = PBXBuildFile; fileRef = 91C686B00FD5F217000F6D01 /* graphics.exd */; }; + 91C686FB0FD5F217000F6D01 /* graphics.exd in CopyFiles */ = {isa = PBXBuildFile; fileRef = 91C686B00FD5F217000F6D01 /* graphics.exd */; }; + 91C686FC0FD5F217000F6D01 /* graphics.exd in CopyFiles */ = {isa = PBXBuildFile; fileRef = 91C686B00FD5F217000F6D01 /* graphics.exd */; }; + 91C688E80FD702B9000F6D01 /* cursors.m in Sources */ = {isa = PBXBuildFile; fileRef = 91C688E70FD702B9000F6D01 /* cursors.m */; }; + 91C688E90FD702B9000F6D01 /* cursors.m in Sources */ = {isa = PBXBuildFile; fileRef = 91C688E70FD702B9000F6D01 /* cursors.m */; }; + 91C688EA0FD702B9000F6D01 /* cursors.m in Sources */ = {isa = PBXBuildFile; fileRef = 91C688E70FD702B9000F6D01 /* cursors.m */; }; 91D62F340F8EB84800674AB3 /* bladesofexile.rsrc in Resources */ = {isa = PBXBuildFile; fileRef = 91D62F330F8EB84800674AB3 /* bladesofexile.rsrc */; }; 91D634560F8FD77800674AB3 /* BoE.icns in Resources */ = {isa = PBXBuildFile; fileRef = 2B8F435C0C0973680012E4A8 /* BoE.icns */; }; 91D635B60F90E7D200674AB3 /* stealth.exs in CopyFiles */ = {isa = PBXBuildFile; fileRef = 91D635AA0F90E7B500674AB3 /* stealth.exs */; }; @@ -209,14 +223,14 @@ isa = PBXContainerItemProxy; containerPortal = 2BF04AA10BF51845006C0831 /* Project object */; proxyType = 1; - remoteGlobalIDString = 9141DAB40FCB94900047D3A3 /* ticpp */; + remoteGlobalIDString = 9141DAB40FCB94900047D3A3; remoteInfo = ticpp; }; 912287110FD333AE00B21642 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 2BF04AA10BF51845006C0831 /* Project object */; proxyType = 1; - remoteGlobalIDString = 9141DAB40FCB94900047D3A3 /* ticpp */; + remoteGlobalIDString = 9141DAB40FCB94900047D3A3; remoteInfo = ticpp; }; 9141DABB0FCB95030047D3A3 /* PBXContainerItemProxy */ = { @@ -250,6 +264,34 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ + 91A32B660FDB5EF100C4E957 /* Copy Dialogs */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Dialogs; + dstSubfolderSpec = 7; + files = ( + 91A32B6A0FDB5F1000C4E957 /* choose-pict.xml in Copy Dialogs */, + 91A32B6B0FDB5F1000C4E957 /* choose-string.xml in Copy Dialogs */, + 91A32B6C0FDB5F1000C4E957 /* edit-terrain.xml in Copy Dialogs */, + ); + name = "Copy Dialogs"; + runOnlyForDeploymentPostprocessing = 0; + }; + 91A32B710FDB5F5A00C4E957 /* Copy String Lists */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Strings; + dstSubfolderSpec = 7; + files = ( + 91A32B770FDB5F6800C4E957 /* arena-names.txt in Copy String Lists */, + 91A32B780FDB5F6800C4E957 /* ter-flag1.txt in Copy String Lists */, + 91A32B790FDB5F6800C4E957 /* ter-flag2.txt in Copy String Lists */, + 91A32B7A0FDB5F6800C4E957 /* ter-flag3.txt in Copy String Lists */, + 91A32B7B0FDB5F6800C4E957 /* trim-names.txt in Copy String Lists */, + ); + name = "Copy String Lists"; + runOnlyForDeploymentPostprocessing = 0; + }; 91B3EF2C0F969D4700BF5B67 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -257,6 +299,7 @@ dstSubfolderSpec = 16; files = ( 91B3EF300F969D7B00BF5B67 /* Blades of Exile Graphics in CopyFiles */, + 91C686FC0FD5F217000F6D01 /* graphics.exd in CopyFiles */, 91B3EF310F969D7B00BF5B67 /* Blades of Exile Sounds in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; @@ -267,11 +310,22 @@ dstPath = "Scenario Editor"; dstSubfolderSpec = 16; files = ( + 91C686FB0FD5F217000F6D01 /* graphics.exd in CopyFiles */, 91B3EF2E0F969D7200BF5B67 /* Blades of Exile Graphics in CopyFiles */, 91B3EF2F0F969D7200BF5B67 /* Blades of Exile Sounds in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; + 91C687050FD5F277000F6D01 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 16; + files = ( + 91C686FA0FD5F217000F6D01 /* graphics.exd in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 91D635A30F90E77C00674AB3 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -397,6 +451,16 @@ 913D05BB0FA1EA0A00184C18 /* pc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pc.cpp; path = classes/pc.cpp; sourceTree = ""; }; 913D6C040FC57A8E00E12527 /* boeresources.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = boeresources.icns; sourceTree = ""; }; 9141DAB50FCB94900047D3A3 /* libticpp.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libticpp.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; + 91A32B670FDB5F1000C4E957 /* choose-pict.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = "choose-pict.xml"; path = "dialogxml/choose-pict.xml"; sourceTree = ""; }; + 91A32B680FDB5F1000C4E957 /* choose-string.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = "choose-string.xml"; path = "dialogxml/choose-string.xml"; sourceTree = ""; }; + 91A32B690FDB5F1000C4E957 /* edit-terrain.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = "edit-terrain.xml"; path = "dialogxml/edit-terrain.xml"; sourceTree = ""; }; + 91A32B720FDB5F6800C4E957 /* arena-names.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "arena-names.txt"; path = "Scenario Editor/strings/arena-names.txt"; sourceTree = ""; }; + 91A32B730FDB5F6800C4E957 /* ter-flag1.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "ter-flag1.txt"; path = "Scenario Editor/strings/ter-flag1.txt"; sourceTree = ""; }; + 91A32B740FDB5F6800C4E957 /* ter-flag2.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "ter-flag2.txt"; path = "Scenario Editor/strings/ter-flag2.txt"; sourceTree = ""; }; + 91A32B750FDB5F6800C4E957 /* ter-flag3.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "ter-flag3.txt"; path = "Scenario Editor/strings/ter-flag3.txt"; sourceTree = ""; }; + 91A32B760FDB5F6800C4E957 /* trim-names.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "trim-names.txt"; path = "Scenario Editor/strings/trim-names.txt"; sourceTree = ""; }; + 91A32BBA0FDB657800C4E957 /* dialog.results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dialog.results.h; sourceTree = ""; }; + 91A32BD10FDB797B00C4E957 /* dlogutil.buttons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dlogutil.buttons.h; sourceTree = ""; }; 91A79DC60FA797BF00A6A41F /* menu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = menu.xib; sourceTree = ""; }; 91A79DDD0FA79DEE00A6A41F /* dialogs.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = dialogs.xib; sourceTree = ""; }; 91AC607E0FA26A3B00EEAE67 /* regtown.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = regtown.h; path = classes/regtown.h; sourceTree = ""; }; @@ -461,6 +525,9 @@ 91B3F10F0F9779D000BF5B67 /* soundtool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = soundtool.cpp; path = tools/soundtool.cpp; sourceTree = ""; }; 91B3F11D0F97801F00BF5B67 /* mathutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mathutil.h; path = tools/mathutil.h; sourceTree = ""; }; 91B3F11E0F97801F00BF5B67 /* mathutil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mathutil.cpp; path = tools/mathutil.cpp; sourceTree = ""; }; + 91C686B00FD5F217000F6D01 /* graphics.exd */ = {isa = PBXFileReference; lastKnownFileType = folder; name = graphics.exd; path = ../rsrc/graphics.exd; sourceTree = SOURCE_ROOT; }; + 91C688E60FD702B9000F6D01 /* cursors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cursors.h; path = tools/cursors.h; sourceTree = ""; }; + 91C688E70FD702B9000F6D01 /* cursors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = cursors.m; path = tools/cursors.m; sourceTree = ""; }; 91D62F330F8EB84800674AB3 /* bladesofexile.rsrc */ = {isa = PBXFileReference; lastKnownFileType = archive.rsrc; path = bladesofexile.rsrc; sourceTree = ""; }; 91D635AA0F90E7B500674AB3 /* stealth.exs */ = {isa = PBXFileReference; lastKnownFileType = file; path = stealth.exs; sourceTree = ""; }; 91D635AB0F90E7B500674AB3 /* stealth.meg */ = {isa = PBXFileReference; lastKnownFileType = file; path = stealth.meg; sourceTree = ""; }; @@ -578,6 +645,8 @@ 910BBAB40FB91A26001E34EA /* field.h */, 910BBAB80FB91ADB001E34EA /* message.h */, 910BBAD90FB91D2A001E34EA /* dlogutil.h */, + 91A32BBA0FDB657800C4E957 /* dialog.results.h */, + 91A32BD10FDB797B00C4E957 /* dlogutil.buttons.h */, ); name = headers; sourceTree = ""; @@ -689,6 +758,8 @@ 91E5C7A60F9F615400C21460 /* fileio.cpp */, 913D005A0F9FEEC200184C18 /* porting.cpp */, 913D00850FA0021400184C18 /* dlgutil.cpp */, + 91C688E70FD702B9000F6D01 /* cursors.m */, + 912283C80FD0E16C00B21642 /* undo.cpp */, ); name = src; sourceTree = ""; @@ -696,6 +767,8 @@ 913D03350FA1000200184C18 /* headers */ = { isa = PBXGroup; children = ( + 912283C70FD0E16B00B21642 /* undo.h */, + 91C688E60FD702B9000F6D01 /* cursors.h */, 91B3F1090F9779C300BF5B67 /* graphtool.h */, 91B3F10E0F9779D000BF5B67 /* soundtool.h */, 91B3F11D0F97801F00BF5B67 /* mathutil.h */, @@ -709,6 +782,56 @@ name = headers; sourceTree = ""; }; + 91A32AFD0FDAC35D00C4E957 /* dialogs */ = { + isa = PBXGroup; + children = ( + ); + name = dialogs; + sourceTree = ""; + }; + 91A32AFE0FDAC36300C4E957 /* strings */ = { + isa = PBXGroup; + children = ( + ); + name = strings; + sourceTree = ""; + }; + 91A32AFF0FDAC37400C4E957 /* dialogs */ = { + isa = PBXGroup; + children = ( + 91A32B670FDB5F1000C4E957 /* choose-pict.xml */, + 91A32B680FDB5F1000C4E957 /* choose-string.xml */, + 91A32B690FDB5F1000C4E957 /* edit-terrain.xml */, + ); + name = dialogs; + sourceTree = ""; + }; + 91A32B000FDAC37B00C4E957 /* strings */ = { + isa = PBXGroup; + children = ( + 91A32B720FDB5F6800C4E957 /* arena-names.txt */, + 91A32B730FDB5F6800C4E957 /* ter-flag1.txt */, + 91A32B740FDB5F6800C4E957 /* ter-flag2.txt */, + 91A32B750FDB5F6800C4E957 /* ter-flag3.txt */, + 91A32B760FDB5F6800C4E957 /* trim-names.txt */, + ); + name = strings; + sourceTree = ""; + }; + 91A32B010FDAC39100C4E957 /* dialogs */ = { + isa = PBXGroup; + children = ( + ); + name = dialogs; + sourceTree = ""; + }; + 91A32B020FDAC39900C4E957 /* strings */ = { + isa = PBXGroup; + children = ( + ); + name = strings; + sourceTree = ""; + }; 91B3EECD0F969B7000BF5B67 /* ScenEd */ = { isa = PBXGroup; children = ( @@ -722,6 +845,8 @@ 91B3EED50F969BA700BF5B67 /* rsrc */ = { isa = PBXGroup; children = ( + 91A32B000FDAC37B00C4E957 /* strings */, + 91A32AFF0FDAC37400C4E957 /* dialogs */, 91279BAD0F9CFCBA007B0D52 /* boescenario.icns */, 91B3EED90F969BA700BF5B67 /* BoE Scenario Editor-Info.plist */, 91B3EEDA0F969BA700BF5B67 /* BOEScen.rsrc */, @@ -799,6 +924,8 @@ 91B3EF0D0F969BD300BF5B67 /* rsrc */ = { isa = PBXGroup; children = ( + 91A32B020FDAC39900C4E957 /* strings */, + 91A32B010FDAC39100C4E957 /* dialogs */, 91B3EF110F969BD300BF5B67 /* BoECharEd.icns */, 91B3EF120F969BD300BF5B67 /* bladespced.rsrc */, 91B3EF130F969BD300BF5B67 /* Blades of Exile Character Editor-Info.plist */, @@ -812,6 +939,7 @@ 91B3EF250F969CE300BF5B67 /* Blades of Exile Base */, 91B3EF260F969CE300BF5B67 /* Blades of Exile Graphics */, 91B3EF270F969CE300BF5B67 /* Blades of Exile Sounds */, + 91C686B00FD5F217000F6D01 /* graphics.exd */, 91D635A90F90E7B500674AB3 /* Blades of Exile Scenarios */, ); name = Files; @@ -842,8 +970,6 @@ 910BBA130FB8BE66001E34EA /* dialogs */, 913D03350FA1000200184C18 /* headers */, 913D03340FA0FFFF00184C18 /* src */, - 912283C70FD0E16B00B21642 /* undo.h */, - 912283C80FD0E16C00B21642 /* undo.cpp */, ); name = tools; sourceTree = ""; @@ -910,6 +1036,8 @@ 91D62F2E0F8EB80200674AB3 /* rsrc */ = { isa = PBXGroup; children = ( + 91A32AFE0FDAC36300C4E957 /* strings */, + 91A32AFD0FDAC35D00C4E957 /* dialogs */, 91279BB30F9D03B6007B0D52 /* boesave.icns */, 91279BB40F9D03B7007B0D52 /* boesounds.icns */, 913D6C040FC57A8E00E12527 /* boeresources.icns */, @@ -1029,6 +1157,9 @@ buildConfigurationList = 91B3EF440F969F0100BF5B67 /* Build configuration list for PBXNativeTarget "BoE Scenario Editor" */; buildPhases = ( 91B3EF3B0F969F0000BF5B67 /* Resources */, + 91A32B710FDB5F5A00C4E957 /* Copy String Lists */, + 91A32B660FDB5EF100C4E957 /* Copy Dialogs */, + 91C687050FD5F277000F6D01 /* CopyFiles */, 91B3EF3C0F969F0000BF5B67 /* Sources */, 91B3EF3D0F969F0000BF5B67 /* Frameworks */, ); @@ -1170,6 +1301,7 @@ 912287040FD330F300B21642 /* field.cpp in Sources */, 912287050FD330F300B21642 /* message.cpp in Sources */, 912287060FD330F300B21642 /* pict.cpp in Sources */, + 91C688E80FD702B9000F6D01 /* cursors.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1213,7 +1345,6 @@ 91B3EF490F969F2300BF5B67 /* pc.action.cpp in Sources */, 91B3EF4A0F969F2300BF5B67 /* pc.editors.cpp in Sources */, 91B3EF4B0F969F2300BF5B67 /* pc.fileio.cpp in Sources */, - 91B3EF4D0F969F2300BF5B67 /* pc.graphics.cpp in Sources */, 91279BE30F9D0F73007B0D52 /* location.cpp in Sources */, 91279C5A0F9D1253007B0D52 /* scenario.cpp in Sources */, 91279C680F9D12D6007B0D52 /* terrain.cpp in Sources */, @@ -1240,6 +1371,8 @@ 912286FD0FD330EC00B21642 /* field.cpp in Sources */, 912286FE0FD330EC00B21642 /* message.cpp in Sources */, 912286FF0FD330ED00B21642 /* pict.cpp in Sources */, + 91C6864A0FD5EEFD000F6D01 /* pc.graphics.cpp in Sources */, + 91C688E90FD702B9000F6D01 /* cursors.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1289,6 +1422,7 @@ 91C1FCAB0FCB6F7300EBAA65 /* pict.cpp in Sources */, 912283C90FD0E16C00B21642 /* undo.cpp in Sources */, 912286F80FD330E500B21642 /* dlogutil.cpp in Sources */, + 91C688EA0FD702B9000F6D01 /* cursors.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1338,7 +1472,7 @@ COPY_PHASE_STRIP = NO; DEAD_CODE_STRIPPING = NO; GCC_ENABLE_OBJC_EXCEPTIONS = NO; - GCC_INPUT_FILETYPE = sourcecode.cpp.cpp; + GCC_INPUT_FILETYPE = automatic; GCC_MODEL_TUNING = G4; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; @@ -1358,6 +1492,13 @@ LINK_WITH_STANDARD_LIBRARIES = YES; MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; MACOSX_DEPLOYMENT_TARGET_ppc = 10.3; + OTHER_LDFLAGS = ( + "-framework", + Carbon, + "-framework", + Cocoa, + "-lz", + ); OTHER_LDFLAGS_QUOTED_FOR_PROJECT_1 = "\"$(PROJECT_DIR)/misc/\""; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk; @@ -1380,7 +1521,7 @@ COPY_PHASE_STRIP = YES; DEAD_CODE_STRIPPING = YES; GCC_ENABLE_OBJC_EXCEPTIONS = NO; - GCC_INPUT_FILETYPE = sourcecode.cpp.cpp; + GCC_INPUT_FILETYPE = automatic; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; @@ -1399,6 +1540,13 @@ LINK_WITH_STANDARD_LIBRARIES = YES; MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; MACOSX_DEPLOYMENT_TARGET_ppc = 10.3; + OTHER_LDFLAGS = ( + "-framework", + Carbon, + "-framework", + Cocoa, + "-lz", + ); OTHER_LDFLAGS_QUOTED_FOR_PROJECT_1 = "\"$(PROJECT_DIR)/misc/\""; SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk; @@ -1432,11 +1580,6 @@ "$(inherited)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", ); - OTHER_LDFLAGS = ( - "-framework", - Carbon, - "-lz", - ); OTHER_LDFLAGS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_DIR)/misc/\""; PREBINDING = NO; PRODUCT_NAME = "Blades of Exile"; @@ -1465,11 +1608,6 @@ "$(inherited)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", ); - OTHER_LDFLAGS = ( - "-framework", - Carbon, - "-lz", - ); OTHER_LDFLAGS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_DIR)/misc/\""; PREBINDING = NO; PRODUCT_NAME = "Blades of Exile"; @@ -1589,11 +1727,6 @@ "$(inherited)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", ); - OTHER_LDFLAGS = ( - "-framework", - Carbon, - "-lz", - ); OTHER_LDFLAGS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_DIR)/misc/\""; PREBINDING = NO; PRODUCT_NAME = "Blades of Exile Character Editor"; @@ -1624,11 +1757,6 @@ "$(inherited)", "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", ); - OTHER_LDFLAGS = ( - "-framework", - Carbon, - "-lz", - ); OTHER_LDFLAGS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_DIR)/misc/\""; PREBINDING = NO; PRODUCT_NAME = "Blades of Exile Character Editor"; @@ -1665,11 +1793,6 @@ MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; OTHER_CFLAGS = "-fpack-struct=2"; OTHER_CPLUSPLUSFLAGS = "-fpack-struct=2"; - OTHER_LDFLAGS = ( - "-framework", - Carbon, - "-lz", - ); PREBINDING = NO; PRODUCT_NAME = "BoE Scenario Editor"; SDKROOT = ""; @@ -1706,11 +1829,6 @@ MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; OTHER_CFLAGS = "-fpack-struct=2"; OTHER_CPLUSPLUSFLAGS = "-fpack-struct=2"; - OTHER_LDFLAGS = ( - "-framework", - Carbon, - "-lz", - ); PREBINDING = NO; PRODUCT_NAME = "BoE Scenario Editor"; SDKROOT = ""; diff --git a/osx/Scenario Editor/BOEScen.rsrc b/osx/Scenario Editor/BOEScen.rsrc index 02101f66..699c308e 100644 Binary files a/osx/Scenario Editor/BOEScen.rsrc and b/osx/Scenario Editor/BOEScen.rsrc differ diff --git a/osx/Scenario Editor/Blades of Exile Graphics b/osx/Scenario Editor/Blades of Exile Graphics index 97f9d0c4..83df4771 100644 Binary files a/osx/Scenario Editor/Blades of Exile Graphics and b/osx/Scenario Editor/Blades of Exile Graphics differ diff --git a/osx/Scenario Editor/scen.actions.cpp b/osx/Scenario Editor/scen.actions.cpp index 9298d0fc..581df98b 100644 --- a/osx/Scenario Editor/scen.actions.cpp +++ b/osx/Scenario Editor/scen.actions.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include "scen.global.h" #include "classes.h" #include "graphtool.h" @@ -274,7 +274,7 @@ bool handle_action(Point the_point,EventRecord event) { } } if ((overall_mode < MODE_MAIN_SCREEN) && (i == NLS - 1)) { - set_cursor(0); + set_cursor(wand_curs); set_up_main_screen(); } mouse_button_held = false; @@ -431,14 +431,14 @@ bool handle_action(Point the_point,EventRecord event) { if ((!mouse_button_held && terrain_matches(spot_hit.x,spot_hit.y,current_terrain_type)) || (mouse_button_held && erasing_mode)) { set_terrain(spot_hit,current_ground); - set_cursor(0); + set_cursor(wand_curs); erasing_mode = true; mouse_button_held = true; } else { mouse_button_held = true; - set_cursor(0); + set_cursor(wand_curs); set_terrain(spot_hit,current_terrain_type); erasing_mode = false; } @@ -451,7 +451,7 @@ bool handle_action(Point the_point,EventRecord event) { working_rect.left = spot_hit.x; working_rect.top = spot_hit.y; mode_count = 1; - set_cursor(6); + set_cursor(bottomright_curs); set_string("Now select lower right corner",""); break; } @@ -492,7 +492,7 @@ bool handle_action(Point the_point,EventRecord event) { give_error("You have placed the maximum number of area rectangles (16 in town, 8 outdoors).","",0); } overall_mode = MODE_DRAWING; - set_cursor(0); + set_cursor(wand_curs); break; case MODE_SET_WANDER_POINTS: if (mouse_button_held == true) @@ -518,7 +518,7 @@ bool handle_action(Point the_point,EventRecord event) { break; case 0: overall_mode = MODE_DRAWING; - set_cursor(0); + set_cursor(wand_curs); set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str()); break; } @@ -574,7 +574,7 @@ bool handle_action(Point the_point,EventRecord event) { give_error("You can only have 64 preset items in each town.","",0); overall_mode = MODE_DRAWING; - set_cursor(0); + set_cursor(wand_curs); set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str()); break; case MODE_EDIT_ITEM: @@ -585,12 +585,12 @@ bool handle_action(Point the_point,EventRecord event) { store_place_item = town->preset_items[x]; } overall_mode = MODE_DRAWING; - set_cursor(0); + set_cursor(wand_curs); break; // case 7: // edit_monst does nothing at all, but I think this would otherwise be the same as mode 39 // edit_monst(1,spot_hit.x,spot_hit.y); // overall_mode = MODE_DRAWING; -// set_cursor(0); +// set_cursor(wand_curs); // break; case MODE_PLACE_SAME_CREATURE: if (last_placed_monst.number == 0) { @@ -612,7 +612,7 @@ bool handle_action(Point the_point,EventRecord event) { i = 60; } overall_mode = MODE_DRAWING; - set_cursor(0); + set_cursor(wand_curs); break; case MODE_PLACE_CREATURE: for (i = 0; i < 60; i++) @@ -649,14 +649,14 @@ bool handle_action(Point the_point,EventRecord event) { give_error("Large towns can have at most 60 preset monsters.","",0); // error } overall_mode = MODE_DRAWING; - set_cursor(0); + set_cursor(wand_curs); break; case MODE_PLACE_NORTH_ENTRANCE: case MODE_PLACE_EAST_ENTRANCE: case MODE_PLACE_SOUTH_ENTRANCE: case MODE_PLACE_WEST_ENTRANCE: town->start_locs[overall_mode - 10].x = spot_hit.x; town->start_locs[overall_mode - 10].y = spot_hit.y; - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_PLACE_WEB: @@ -702,7 +702,7 @@ bool handle_action(Point the_point,EventRecord event) { take_field_type(spot_hit.x, spot_hit.y, 2); for (i = 0; i < 8; i++) take_sfx(spot_hit.x,spot_hit.y,i); - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_PLACE_SFX: @@ -713,7 +713,7 @@ bool handle_action(Point the_point,EventRecord event) { if (editing_town == true) set_new_terrain(town->terrain(spot_hit.x,spot_hit.y)); else set_new_terrain(current_terrain.terrain[spot_hit.x][spot_hit.y]); - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_PLACE_SAME_ITEM: @@ -730,7 +730,7 @@ bool handle_action(Point the_point,EventRecord event) { town->preset_items[x].contained = container_there(town->preset_items[x].loc); x = 64; } - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_EDIT_SIGN: //edit sign @@ -756,7 +756,7 @@ bool handle_action(Point the_point,EventRecord event) { "",0); } } - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_EDIT_CREATURE: //edit monst @@ -765,12 +765,12 @@ bool handle_action(Point the_point,EventRecord event) { edit_placed_monst(x); last_placed_monst = town->creatures(x); } - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_EDIT_SPECIAL: //make special place_edit_special(spot_hit); - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_COPY_SPECIAL: //copy special @@ -790,7 +790,7 @@ bool handle_action(Point the_point,EventRecord event) { } if (x < 500) give_error("There wasn't a special on that spot.","",0); - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_PASTE_SPECIAL: //paste special @@ -822,7 +822,7 @@ bool handle_action(Point the_point,EventRecord event) { if (x < 500) give_error("Each town can have at most 50 locations with special encounters. Each outdoor section can have at most 18. You'll need to erase some special spaces before you can place more.","",0); - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_ERASE_SPECIAL: //erase special @@ -840,18 +840,18 @@ bool handle_action(Point the_point,EventRecord event) { x = 500; } } - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_PLACE_SPECIAL: //edit special set_special(spot_hit); - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_EDIT_TOWN_ENTRANCE: //edit town entry town_entry(spot_hit); overall_mode = MODE_DRAWING; - set_cursor(0); + set_cursor(wand_curs); break; case MODE_SET_OUT_START: //edit out start loc if (fancy_choice_dialog(864,0) == 2) @@ -864,7 +864,7 @@ bool handle_action(Point the_point,EventRecord event) { scenario.out_sec_start.x = cur_out.x; scenario.out_sec_start.y = cur_out.y; scenario.out_start = spot_hit; - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_ERASE_CREATURE: //delete monst @@ -872,7 +872,7 @@ bool handle_action(Point the_point,EventRecord event) { if (monst_on_space(spot_hit,x) == true) { town->creatures(x).number = 0; } - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; case MODE_ERASE_ITEM: // delete item @@ -881,7 +881,7 @@ bool handle_action(Point the_point,EventRecord event) { (spot_hit.y == town->preset_items[x].loc.y) && (town->preset_items[x].code >= 0)) { town->preset_items[x].code = -1; } - set_cursor(0); + set_cursor(wand_curs); overall_mode = MODE_DRAWING; break; } @@ -959,37 +959,37 @@ bool handle_action(Point the_point,EventRecord event) { case 0: set_string("Drawing mode",(char*)scenario.ter_types[current_terrain_type].name.c_str()); overall_mode = MODE_DRAWING; - set_cursor(0); + set_cursor(wand_curs); break; case 1: set_string("Paintbrush (large)",(char*)scenario.ter_types[current_terrain_type].name.c_str()); overall_mode = MODE_LARGE_PAINTBRUSH; - set_cursor(2); + set_cursor(brush_curs); break; case 2: set_string("Paintbrush (small)",(char*)scenario.ter_types[current_terrain_type].name.c_str()); - set_cursor(2); + set_cursor(brush_curs); overall_mode = MODE_SMALL_PAINTBRUSH; break; case 3: set_string("Spraycan (large)",(char*)scenario.ter_types[current_terrain_type].name.c_str()); - set_cursor(3); + set_cursor(spray_curs); overall_mode = MODE_LARGE_SPRAYCAN; break; case 4: set_string("Spraycan (small)",(char*)scenario.ter_types[current_terrain_type].name.c_str()); - set_cursor(3); + set_cursor(spray_curs); overall_mode = MODE_SMALL_SPRAYCAN; break; case 5: set_string("Eyedropper","Select terrain to draw"); - set_cursor(1); + set_cursor(eyedropper_curs); overall_mode = MODE_EYEDROPPER; break; case 6: case 7: overall_mode = (i == 6) ? MODE_HOLLOW_RECT : MODE_FILLED_RECT; mode_count = 2; - set_cursor(5); + set_cursor(topleft_curs); if (i == 6) set_string("Fill rectangle (hollow)","Select upper left corner"); else set_string("Fill rectangle (solid)","Select upper left corner"); @@ -1001,23 +1001,23 @@ bool handle_action(Point the_point,EventRecord event) { case 101: set_string("Erase space","Select space to clear"); overall_mode = MODE_ERASER; - set_cursor(4); + set_cursor(eraser_curs); break; case 102: set_string("Edit sign","Select sign to edit"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_EDIT_SIGN; break; case 103: overall_mode = MODE_ROOM_RECT; mode_count = 2; - set_cursor(5); + set_cursor(topleft_curs); set_string("Create room rectangle","Select upper left corner"); break; case 104: overall_mode = MODE_SET_WANDER_POINTS; mode_count = 4; - set_cursor(7); + set_cursor(hand_curs); set_string("Place first wandering monster arrival point",""); break; case 105: // replace terrain @@ -1031,7 +1031,7 @@ bool handle_action(Point the_point,EventRecord event) { break; } set_string("Set town entrance","Select town to edit"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_EDIT_TOWN_ENTRANCE; break; case 200: @@ -1040,7 +1040,7 @@ bool handle_action(Point the_point,EventRecord event) { break; } set_string("Edit placed item","Select item to edit"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_EDIT_ITEM; break; case 201: @@ -1049,7 +1049,7 @@ bool handle_action(Point the_point,EventRecord event) { break; } set_string("Place same item","Select location"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_PLACE_SAME_ITEM; break; case 202: @@ -1057,21 +1057,21 @@ bool handle_action(Point the_point,EventRecord event) { //set_string("Edit placed item","Not while outdoors."); set_string("Toggle special spot","Select location"); overall_mode = MODE_TOGGLE_SPECIAL_DOT; - set_cursor(0); + set_cursor(wand_curs); break; } set_string("Delete an item","Select item"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_ERASE_ITEM; break; case 203: set_string("Create/Edit special","Select special location"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_EDIT_SPECIAL; break; case 204: set_string("Copy special","Select special to copy"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_COPY_SPECIAL; break; case 205: @@ -1080,140 +1080,140 @@ bool handle_action(Point the_point,EventRecord event) { } set_string("Paste special","Select location to paste"); overall_mode = MODE_PASTE_SPECIAL; - set_cursor(7); + set_cursor(hand_curs); break; case 206: set_string("Erase special","Select special to erase"); overall_mode = MODE_ERASE_SPECIAL; - set_cursor(4); + set_cursor(eraser_curs); break; case 207: set_string("Set/place special","Select special location"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_PLACE_SPECIAL; break; case 300: set_string("Edit creature","Select creature to edit"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_EDIT_CREATURE; break; case 301: set_string("Place same creature","Select creature location"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_PLACE_SAME_CREATURE; break; case 302: set_string("Delete a creature","Select creature"); - set_cursor(4); + set_cursor(eraser_curs); overall_mode = MODE_ERASE_CREATURE; break; case 304: set_string("Place north entrace","Select entrance location"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_PLACE_NORTH_ENTRANCE; break; case 305: set_string("Place west entrace","Select entrance location"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_PLACE_WEST_ENTRANCE; break; case 306: set_string("Place south entrace","Select entrance location"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_PLACE_SOUTH_ENTRANCE; break; case 307: set_string("Place east entrace","Select entrance location"); - set_cursor(7); + set_cursor(hand_curs); overall_mode = MODE_PLACE_EAST_ENTRANCE; break; case 400: set_string("Place web","Select location"); overall_mode = MODE_PLACE_WEB; - set_cursor(0); + set_cursor(wand_curs); break; case 401: set_string("Place crate","Select location"); overall_mode = MODE_PLACE_CRATE; - set_cursor(0); + set_cursor(wand_curs); break; case 402: set_string("Place barrel","Select location"); overall_mode = MODE_PLACE_BARREL; - set_cursor(0); + set_cursor(wand_curs); break; case 403: set_string("Place fire barrier","Select location"); overall_mode = MODE_PLACE_FIRE_BARRIER; - set_cursor(0); + set_cursor(wand_curs); break; case 404: set_string("Place force barrier","Select location"); overall_mode = MODE_PLACE_FORCE_BARRIER; - set_cursor(0); + set_cursor(wand_curs); break; case 405: set_string("Place quickfire","Select location"); overall_mode = MODE_PLACE_QUICKFIRE; - set_cursor(0); + set_cursor(wand_curs); break; case 406: set_string("Place special spot","Select location"); overall_mode = MODE_TOGGLE_SPECIAL_DOT; - set_cursor(0); + set_cursor(wand_curs); break; case 407: set_string("Clear space","Select space to clear"); overall_mode = MODE_CLEAR_FIELDS; - set_cursor(4); + set_cursor(eraser_curs); break; case 500: set_string("Place small blood stain","Select stain location"); overall_mode = MODE_PLACE_SFX; mode_count = 0; - set_cursor(0); + set_cursor(wand_curs); break; case 501: set_string("Place ave. blood stain","Select stain location"); overall_mode = MODE_PLACE_SFX; mode_count = 1; - set_cursor(0); + set_cursor(wand_curs); break; case 502: set_string("Place large blood stain","Select stain location"); overall_mode = MODE_PLACE_SFX; mode_count = 2; - set_cursor(0); + set_cursor(wand_curs); break; case 503: set_string("Place small slime pool","Select slime location"); overall_mode = MODE_PLACE_SFX; mode_count = 3; - set_cursor(0); + set_cursor(wand_curs); break; case 504: set_string("Place large slime pool","Select slime location"); overall_mode = MODE_PLACE_SFX; mode_count = 4; - set_cursor(0); + set_cursor(wand_curs); break; case 505: set_string("Place ash","Select ash location"); overall_mode = MODE_PLACE_SFX; mode_count = 5; - set_cursor(0); + set_cursor(wand_curs); break; case 506: set_string("Place bones","Select bones location"); overall_mode = MODE_PLACE_SFX; mode_count = 6; - set_cursor(0); + set_cursor(wand_curs); break; case 507: set_string("Place rocks","Select rocks location"); overall_mode = MODE_PLACE_SFX; mode_count = 7; - set_cursor(0); + set_cursor(wand_curs); break; } } diff --git a/osx/Scenario Editor/scen.btnmg.cpp b/osx/Scenario Editor/scen.btnmg.cpp index 78f2c8a3..92cac3be 100644 --- a/osx/Scenario Editor/scen.btnmg.cpp +++ b/osx/Scenario Editor/scen.btnmg.cpp @@ -1,12 +1,12 @@ -#include -#include +#include +#include #include "scen.global.h" #include "classes.h" #include "graphtool.h" #include "scen.graphics.h" -#include +#include #include "scen.btnmg.h" //extern piles_of_stuff_dumping_type *data_store; diff --git a/osx/Scenario Editor/scen.core.cpp b/osx/Scenario Editor/scen.core.cpp index f3aac6c4..31fe9d91 100644 --- a/osx/Scenario Editor/scen.core.cpp +++ b/osx/Scenario Editor/scen.core.cpp @@ -1,5 +1,6 @@ -#include -#include +#include +#include +#include #include "scen.global.h" #include "classes.h" #include "graphtool.h" @@ -13,6 +14,9 @@ #include "scen.townout.h" #include "scen.fileio.h" #include "scen.actions.h" +#include "dialog.h" +#include "dlogutil.h" +#include "fileio.h" extern short cen_x, cen_y,/* overall_mode,*/cur_town; extern bool mouse_button_held; @@ -787,7 +791,6 @@ cMonster return_monster_template(m_num_t store) { // return i; //} -__attribute__((deprecated)) void init_scenario() { short i; rectangle dummy_rect; @@ -890,186 +893,386 @@ void init_scenario() { scenario.scen_str_len[i] = strlen((char *) scenario.scen_strs(i)); } } -void put_ter_info_in_dlog() { - Str255 str; - strcpy((char*)str,(char*)scenario.ter_types[store_which_ter].name.c_str()); - - cdsin(813,12,store_which_ter); - CDST(813,2,(char*)str); - CDSN(813,5,store_ter.picture); - cd_set_led_range(813,19,24,store_ter.blockage); - cd_set_led(813,25,store_ter.fly_over); - cd_set_led(813,26,store_ter.boat_over); - cd_set_led(813,27,store_ter.block_horse); - cd_set_led_range(813,28,31,store_ter.step_sound); - str[0] = store_ter.shortcut_key; - str[1] = 0; - CDST(813,3,(char *) str); - CDSN(813,4,store_ter.trans_to_what); - CDSN(813,8,store_ter.light_radius); - cd_set_led_range(813,32,55,store_ter.special); - CDSN(813,6,store_ter.flag1.u); - CDSN(813,7,store_ter.flag2.u); - get_str(str,21,40 + store_ter.special); - csit(813,67,(char *) str); - get_str(str,21,80 + store_ter.special); - csit(813,68,(char *) str); - if (store_ter.picture >= 1000) - csp(813,14,store_ter.picture % 1000,PICT_CUSTOM + PICT_TER); - else if (store_ter.picture >= 400) - csp(813,14,store_ter.picture - 400,PICT_TER_ANIM); - else csp(813,14,store_ter.picture,PICT_TER); -} +//void put_ter_info_in_dlog() { +// Str255 str; +// strcpy((char*)str,(char*)scenario.ter_types[store_which_ter].name.c_str()); +// +// cdsin(813,12,store_which_ter); +// CDST(813,2,(char*)str); +// CDSN(813,5,store_ter.picture); +// cd_set_led_range(813,19,24,store_ter.blockage); +// cd_set_led(813,25,store_ter.fly_over); +// cd_set_led(813,26,store_ter.boat_over); +// cd_set_led(813,27,store_ter.block_horse); +// cd_set_led_range(813,28,31,store_ter.step_sound); +// str[0] = store_ter.shortcut_key; +// str[1] = 0; +// CDST(813,3,(char *) str); +// CDSN(813,4,store_ter.trans_to_what); +// CDSN(813,8,store_ter.light_radius); +// cd_set_led_range(813,32,55,store_ter.special); +// CDSN(813,6,store_ter.flag1.u); +// CDSN(813,7,store_ter.flag2.u); +// get_str(str,21,40 + store_ter.special); +// csit(813,67,(char *) str); +// get_str(str,21,80 + store_ter.special); +// csit(813,68,(char *) str); +// if (store_ter.picture >= 1000) +// csp(813,14,store_ter.picture % 1000,PICT_CUSTOM + PICT_TER); +// else if (store_ter.picture >= 400) +// csp(813,14,store_ter.picture - 400,PICT_TER_ANIM); +// else csp(813,14,store_ter.picture,PICT_TER); +//} +// +//bool save_ter_info() { +// Str255 str; +// short i; +// +// +// store_ter.picture = CDGN(813,5); +// if ((store_ter.picture < 0) || +// ((store_ter.picture > PICT_N_TER) && (store_ter.picture < 400)) || +// ((store_ter.picture > 400 + PICT_N_TER_ANIM) && (store_ter.picture < 1000))) { +// give_error("Picture number isn't in the proper range.","",813); +// return false; +// } +// +// if (store_which_ter > 90) { +// store_ter.blockage = cd_get_led_range(813,19,24); +// store_ter.special = (eTerSpec) cd_get_led_range(813,32,55); +// i = CDGN(813,6); +// /*if ((store_ter.special < 2) || (store_ter.special > 6)) { +// if (cre(i,0,256,"First special flag must be from 0 to 255.","",813) == true) return false; +// } +// else*/ if (store_ter.special == TER_SPEC_DAMAGING) { +// if (cre(i,0,256,"First special flag must be from 0 to 100.","",813) == true) return false; +// } +// else if (store_ter.special == TER_SPEC_DANGEROUS) { +// if (cre(i,0,256,"First special flag must be from 0 to 8.","",813) == true) return false; +// } +// store_ter.flag1.u = CDGN(813,6); +// +// i = CDGN(813,7); +// if (store_ter.special == TER_SPEC_TOWN_ENTRANCE) { +// if (cre(i,0,256,"Second special flag must be from 0 to 200.","",813) == true) return false; +// } +// else if ((store_ter.special == TER_SPEC_DAMAGING) || (store_ter.special == TER_SPEC_DANGEROUS)) { +// if (cre(i,0,256,"Second special flag must be from 0 to 100.","",813) == true) return false; +// } +// store_ter.flag2.u = CDGN(813,7); +// +// i = CDGN(813,4); +// if (cre(i,0,255,"Transform To What must be from 0 to 255.","",813) == true) return false; +// store_ter.trans_to_what = CDGN(813,4); +// store_ter.fly_over = cd_get_led(813,25); +// store_ter.boat_over = cd_get_led(813,26); +// store_ter.block_horse = cd_get_led(813,27); +// store_ter.light_radius = CDGN(813,8); +// if (cre(store_ter.light_radius,0,8,"Light radius must be from 0 to 8.","",813) == true) return false; +// +// store_ter.step_sound = cd_get_led_range(813,28,31); +// } +// CDGT(813,3,(char *) str); +// store_ter.shortcut_key = str[0]; +// +// CDGT(813,2,(char *) str); +// str[29] = 0; +// scenario.ter_types[store_which_ter].name = (char*)str; +// +// scenario.ter_types[store_which_ter] = store_ter; +// return true; +//} -bool save_ter_info() { - Str255 str; - short i; - - - store_ter.picture = CDGN(813,5); - if ((store_ter.picture < 0) || - ((store_ter.picture > PICT_N_TER) && (store_ter.picture < 400)) || - ((store_ter.picture > 400 + PICT_N_TER_ANIM) && (store_ter.picture < 1000))) { - give_error("Picture number isn't in the proper range.","",813); +//void edit_ter_type_event_filter (short item_hit) { +// Str255 str; +// short i; +// +// switch (item_hit) { +// case 9: +// toast_dialog(); +// break; +// case 62: +// if (save_ter_info() == true) +// toast_dialog(); +// break; +// case 10: +// if (save_ter_info() == false) break; +// store_which_ter--; +// if (store_which_ter < 0) store_which_ter = 255; +// store_ter = scenario.ter_types[store_which_ter]; +// put_ter_info_in_dlog(); +// break; +// case 11: +// if (save_ter_info() == false) break; +// store_which_ter++; +// if (store_which_ter > 255) store_which_ter = 0; +// store_ter = scenario.ter_types[store_which_ter]; +// put_ter_info_in_dlog(); +// break; +// +// case 13: case 70: +// if (item_hit == 13) +// i = choose_graphic(0,PICT_N_TER,store_ter.picture,PICT_TER,813); +// else i = 400 + choose_graphic(/*300,313*/0,PICT_N_TER_ANIM,store_ter.picture,PICT_TER_ANIM,813); +// if (i >= 0) { +// //if (i >= 300) i += 100; +// store_ter.picture = i; +// } +// else break; +// CDSN(813,5,store_ter.picture); +// if (store_ter.picture >= 1000) +// csp(813,14,store_ter.picture % 1000,PICT_CUSTOM + PICT_TER); +// else if (store_ter.picture >= 400) +// csp(813,14,store_ter.picture - 400,PICT_TER_ANIM); +// else csp(813,14,store_ter.picture,PICT_TER); +// break; +// default: +// cd_hit_led_range(813,32,55,item_hit); +// cd_hit_led_range(813,28,31,item_hit); +// cd_hit_led_range(813,19,24,item_hit); +// cd_flip_led(813,25,item_hit); +// cd_flip_led(813,26,item_hit); +// cd_flip_led(813,27,item_hit); +// if ((item_hit >= 32) && (item_hit <= 55)) { +// get_str(str,21,40 + item_hit - 32); +// csit(813,67,(char *) str); +// get_str(str,21,80 + item_hit - 32); +// csit(813,68,(char *) str); +// } +// break; +// +// } +//} + +bool check_range(cDialog& me,std::string id,bool losing,long min_val,long max_val,std::string fld_name){ + if(!losing) return true; + cTextField& fld_ctrl = dynamic_cast(me[id]); + long n = fld_ctrl.getTextAsNum(); + if(n < min_val || n > max_val){ + // TODO: Display error message return false; } - - if (store_which_ter > 90) { - store_ter.blockage = cd_get_led_range(813,19,24); - store_ter.special = (eTerSpec) cd_get_led_range(813,32,55); - i = CDGN(813,6); - /*if ((store_ter.special < 2) || (store_ter.special > 6)) { - if (cre(i,0,256,"First special flag must be from 0 to 255.","",813) == true) return false; - } - else*/ if (store_ter.special == TER_SPEC_DAMAGING) { - if (cre(i,0,256,"First special flag must be from 0 to 100.","",813) == true) return false; - } - else if (store_ter.special == TER_SPEC_DANGEROUS) { - if (cre(i,0,256,"First special flag must be from 0 to 8.","",813) == true) return false; - } - store_ter.flag1.u = CDGN(813,6); - - i = CDGN(813,7); - if (store_ter.special == TER_SPEC_TOWN_ENTRANCE) { - if (cre(i,0,256,"Second special flag must be from 0 to 200.","",813) == true) return false; - } - else if ((store_ter.special == TER_SPEC_DAMAGING) || (store_ter.special == TER_SPEC_DANGEROUS)) { - if (cre(i,0,256,"Second special flag must be from 0 to 100.","",813) == true) return false; - } - store_ter.flag2.u = CDGN(813,7); - - i = CDGN(813,4); - if (cre(i,0,255,"Transform To What must be from 0 to 255.","",813) == true) return false; - store_ter.trans_to_what = CDGN(813,4); - store_ter.fly_over = cd_get_led(813,25); - store_ter.boat_over = cd_get_led(813,26); - store_ter.block_horse = cd_get_led(813,27); - store_ter.light_radius = CDGN(813,8); - if (cre(store_ter.light_radius,0,8,"Light radius must be from 0 to 8.","",813) == true) return false; - - store_ter.step_sound = cd_get_led_range(813,28,31); - } - CDGT(813,3,(char *) str); - store_ter.shortcut_key = str[0]; - - CDGT(813,2,(char *) str); - str[29] = 0; - scenario.ter_types[store_which_ter].name = (char*)str; - - scenario.ter_types[store_which_ter] = store_ter; return true; } -void edit_ter_type_event_filter (short item_hit) { - Str255 str; - short i; - - switch (item_hit) { - case 9: - toast_dialog(); - break; - case 62: - if (save_ter_info() == true) - toast_dialog(); - break; - case 10: - if (save_ter_info() == false) break; - store_which_ter--; - if (store_which_ter < 0) store_which_ter = 255; - store_ter = scenario.ter_types[store_which_ter]; - put_ter_info_in_dlog(); - break; - case 11: - if (save_ter_info() == false) break; - store_which_ter++; - if (store_which_ter > 255) store_which_ter = 0; - store_ter = scenario.ter_types[store_which_ter]; - put_ter_info_in_dlog(); - break; - - case 13: case 70: - if (item_hit == 13) - i = choose_graphic(0,PICT_N_TER,store_ter.picture,PICT_TER,813); - else i = 400 + choose_graphic(/*300,313*/0,PICT_N_TER_ANIM,store_ter.picture,PICT_TER_ANIM,813); - if (i >= 0) { - //if (i >= 300) i += 100; - store_ter.picture = i; - } - else break; - CDSN(813,5,store_ter.picture); - if (store_ter.picture >= 1000) - csp(813,14,store_ter.picture % 1000,PICT_CUSTOM + PICT_TER); - else if (store_ter.picture >= 400) - csp(813,14,store_ter.picture - 400,PICT_TER_ANIM); - else csp(813,14,store_ter.picture,PICT_TER); - break; - default: - cd_hit_led_range(813,32,55,item_hit); - cd_hit_led_range(813,28,31,item_hit); - cd_hit_led_range(813,19,24,item_hit); - cd_flip_led(813,25,item_hit); - cd_flip_led(813,26,item_hit); - cd_flip_led(813,27,item_hit); - if ((item_hit >= 32) && (item_hit <= 55)) { - get_str(str,21,40 + item_hit - 32); - csit(813,67,(char *) str); - get_str(str,21,80 + item_hit - 32); - csit(813,68,(char *) str); - } - break; - +bool pick_picture(ePicType type, cDialog& parent, std::string result_fld, std::string pic_fld, pic_num_t first, pic_num_t last, pic_num_t modifier){ + pic_num_t cur_sel = 0; + if(result_fld != ""){ + cTextField& fld_ctrl = dynamic_cast(parent[result_fld]); + cur_sel = fld_ctrl.getTextAsNum(); + cur_sel -= modifier; + }else if(pic_fld != ""){ + cPict& pic_ctrl = dynamic_cast(parent[pic_fld]); + if(pic_ctrl.getPicType() == type) + cur_sel = pic_ctrl.getPicNum(); } + std::vector pics; + for(pic_num_t i = first; i <= last; i++) + pics.push_back(i); + cPictChoice pic_dlg(pics,type,&parent); + pic_num_t pic = pic_dlg.show(last+1, cur_sel); + if(pic <= last){ + if(result_fld != ""){ + cTextField& fld_ctrl = dynamic_cast(parent[result_fld]); + fld_ctrl.setTextToNum(pic + modifier); + } + if(pic_fld != ""){ + cPict& pic_ctrl = dynamic_cast(parent[pic_fld]); + pic_ctrl.setPict(pic,type); + } + } + return true; +} + +bool pick_string(std::string from_file, cDialog& parent, std::string result_fld, std::string str_fld){ + size_t cur_sel = 0; + if(result_fld != ""){ + cTextField& fld_ctrl = dynamic_cast(parent[result_fld]); + cur_sel = fld_ctrl.getTextAsNum(); + } + std::vector strings = load_strings(from_file); + cStringChoice str_dlg(strings, &parent); + size_t result = str_dlg.show(strings[cur_sel]); + if(result < strings.size()){ + if(result_fld != ""){ + cTextField& fld_ctrl = dynamic_cast(parent[result_fld]); + fld_ctrl.setTextToNum(result); + } + if(str_fld != ""){ + parent[str_fld].setText(strings[result]); + } + } + return true; +} + +bool show_help(std::string from_file, cDialog& parent, pic_num_t pic){ + std::vector strings = load_strings(from_file); + cThreeChoice help(strings,-1,-1,63,pic,PIC_DLOG,&parent); + help.show(); + return true; +} + +bool fill_ter_flag_info(cDialog& me, std::string id, bool dummy){ + static std::vector flag1_strs = load_strings("ter-flag1.txt"); + static std::vector flag2_strs = load_strings("ter-flag2.txt"); + static std::vector flag3_strs = load_strings("ter-flag3.txt"); + eTerSpec prop; + cLedGroup& led_ctrl = dynamic_cast(me[id]); + std::istringstream sel(led_ctrl.getSelected()); + sel >> prop; + me["flag1text"].setText(flag1_strs[prop]); + me["flag2text"].setText(flag2_strs[prop]); + me["flag3text"].setText(flag3_strs[prop]); + // TODO: Click handlers for the "choose" buttons as necessary, plus hide/show them as needed + return true; +} + +void fill_ter_info(cDialog& me, short ter){ + cTerrain& ter_type = scenario.ter_types[ter]; + { + cPict& pic_ctrl = dynamic_cast(me["graphic"]); + pic_num_t pic = ter_type.picture; + if(pic < 400) + pic_ctrl.setPict(pic, PIC_TER); + else if(pic < 1000) + pic_ctrl.setPict(pic % 400, PIC_TER_ANIM); + else if(pic < 2000) + pic_ctrl.setPict(pic % 1000, PIC_CUSTOM_TER); + else + pic_ctrl.setPict(pic % 2000, PIC_CUSTOM_TER_ANIM); + me["pict"].setTextToNum(pic); + }{ + cPict& pic_ctrl = dynamic_cast(me["seemap"]); + pic_num_t pic = ter_type.map_pic; + if(pic < 1000) + pic_ctrl.setPict(pic, PIC_TER_MAP); + else pic_ctrl.setPict(pic, PIC_CUSTOM_TER_MAP); + me["map"].setTextToNum(pic); + } + me["number"].setTextToNum(ter); + me["name"].setText(ter_type.name); + me["key"].setTextToNum(ter_type.shortcut_key); + me["light"].setTextToNum(ter_type.light_radius); + me["trans"].setTextToNum(ter_type.trans_to_what); + me["ground"].setTextToNum(ter_type.ground_type); + me["trimter"].setTextToNum(ter_type.trim_ter); + me["trim"].setTextToNum(ter_type.trim_type); + fill_ter_flag_info(me, "prop", false); + { + cLedGroup& led_ctrl = dynamic_cast(me["blockage"]); + switch(ter_type.blockage){ + case 0: + led_ctrl.setSelected("clear"); + break; + case 1: + led_ctrl.setSelected("curtain"); + break; + case 2: + led_ctrl.setSelected("special"); + break; + case 3: + led_ctrl.setSelected("window"); + break; + case 4: + led_ctrl.setSelected("obstructed"); + break; + case 5: + led_ctrl.setSelected("opaque"); + break; + } + }{ + cLedGroup& led_ctrl = dynamic_cast(me["sound"]); + switch(ter_type.step_sound){ + case 0: + led_ctrl.setSelected("step"); + break; + case 1: + led_ctrl.setSelected("squish"); + break; + case 2: + led_ctrl.setSelected("crunch"); + break; + case 3: + led_ctrl.setSelected("nosound"); + break; + case 4: + led_ctrl.setSelected("splash"); + break; + } + } + if(ter_type.fly_over){ + cLed& led_ctrl = dynamic_cast(me["flight"]); + led_ctrl.setState(led_red); + } + if(ter_type.boat_over){ + cLed& led_ctrl = dynamic_cast(me["boat"]); + led_ctrl.setState(led_red); + } + if(ter_type.block_horse){ + cLed& led_ctrl = dynamic_cast(me["horse"]); + led_ctrl.setState(led_red); + } + if(ter_type.special == TER_SPEC_NONE) + me["flag1"].setTextToNum(ter_type.flag1.s); + else me["flag1"].setTextToNum(ter_type.flag1.u); + if(false) // flag2 is never signed, apparently; but that could change? + me["flag2"].setTextToNum(ter_type.flag2.s); + else me["flag2"].setTextToNum(ter_type.flag2.u); + if(ter_type.special == TER_SPEC_CALL_SPECIAL || ter_type.special == TER_SPEC_CALL_SPECIAL_WHEN_USED) + me["flag3"].setTextToNum(ter_type.flag3.s); + else me["flag3"].setTextToNum(ter_type.flag3.u); + me["arena"].setTextToNum(ter_type.combat_arena); } short edit_ter_type(short which_ter) { - // ignore parent in Mac version - short item_hit,i; - Str255 temp_str; - char *blocked_strs[6] = {"Clear","Walk through, Opaque","Clear, Special","Clear, Blocked","Blocked, Obstructed", - "Blocked, Opaque"}; - char *sound_strs[4] = {"Footstep","Squish","Crunch","Silence"}; - - store_which_ter = which_ter; - store_ter = scenario.ter_types[which_ter]; - //make_cursor_sword(); - - cd_create_dialog_parent_num(813,0); - printf("Created dialog."); - put_ter_info_in_dlog(); - for (i = 0; i < 24; i++) { - get_str(temp_str,21,i + 1); - cd_add_label(813,32 + i,(char *) temp_str,57); - } - for (i = 0; i < 4; i++) - cd_add_label(813,28 + i,sound_strs[i],35); - for (i = 0; i < 6; i++) - cd_add_label(813,19 + i,blocked_strs[i],57); - cd_attach_key(813,10,0); - cd_attach_key(813,11,0); - - item_hit = cd_run_dialog(); - cd_kill_dialog(813); - return 0; + cDialog ter_dlg("edit-terrain.xml"); + // Attach handlers + ter_dlg["pict"].attachFocusHandler(boost::bind(check_range,_1,_2,_3,0,2999,"terrain graphic")); + ter_dlg["pickpict"].attachClickHandler(boost::bind(pick_picture,PIC_TER,_1,"pict","graphic",0,399,0)); + ter_dlg["pickanim"].attachClickHandler(boost::bind(pick_picture,PIC_TER_ANIM,_1,"pict","graphic",0,99,400)); + ter_dlg["light"].attachFocusHandler(boost::bind(check_range,_1,_2,_3,0,255,"light radius")); + ter_dlg["trans"].attachFocusHandler(boost::bind(check_range,_1,_2,_3,0,65535,"\"transform to what?\"")); + ter_dlg["ground"].attachFocusHandler(boost::bind(check_range,_1,_2,_3,0,255,"ground type")); + ter_dlg["trimter"].attachFocusHandler(boost::bind(check_range,_1,_2,_3,0,255,"trim terrain")); + ter_dlg["trim"].attachFocusHandler(boost::bind(check_range,_1,_2,_3,0,18,"trim type")); + ter_dlg["prop"].attachFocusHandler(fill_ter_flag_info); + ter_dlg["cancel"].attachClickHandler(boost::bind(&cDialog::toast, &ter_dlg)); + ter_dlg["arena"].attachFocusHandler(boost::bind(check_range,_1,_2,_3,0,299,"ground type")); + // TODO: Add focus handler for key + // TODO: Add click handler for object, done, left, right, help + ter_dlg["picktrim"].attachClickHandler(boost::bind(pick_string,"trim-names.txt", _1, "trim", "")); + ter_dlg["pickarena"].attachClickHandler(boost::bind(pick_string,"arena-names.txt", _1, "arena", "")); + ter_dlg["help"].attachClickHandler(boost::bind(show_help, "ter-type-help.txt", _1, 16)); + fill_ter_info(ter_dlg,which_ter); + ter_dlg.run(); +// // ignore parent in Mac version +// short item_hit,i; +// Str255 temp_str; +// char *blocked_strs[6] = {"Clear","Walk through, Opaque","Clear, Special","Clear, Blocked","Blocked, Obstructed", +// "Blocked, Opaque"}; +// char *sound_strs[4] = {"Footstep","Squish","Crunch","Silence"}; +// +// store_which_ter = which_ter; +// store_ter = scenario.ter_types[which_ter]; +// //make_cursor_sword(); +// +// cd_create_dialog_parent_num(813,0); +// printf("Created dialog."); +// put_ter_info_in_dlog(); +// for (i = 0; i < 24; i++) { +// get_str(temp_str,21,i + 1); +// cd_add_label(813,32 + i,(char *) temp_str,57); +// } +// for (i = 0; i < 4; i++) +// cd_add_label(813,28 + i,sound_strs[i],35); +// for (i = 0; i < 6; i++) +// cd_add_label(813,19 + i,blocked_strs[i],57); +// cd_attach_key(813,10,0); +// cd_attach_key(813,11,0); +// +// item_hit = cd_run_dialog(); +// cd_kill_dialog(813); +// return 0; } void put_monst_info_in_dlog() { diff --git a/osx/Scenario Editor/scen.core.h b/osx/Scenario Editor/scen.core.h index af27de68..50bb8f70 100644 --- a/osx/Scenario Editor/scen.core.h +++ b/osx/Scenario Editor/scen.core.h @@ -1,9 +1,8 @@ cMonster return_monster_template(m_num_t store); //item_record_type convert_item (short_item_record_type s_item) ; -__attribute__((deprecated)) -void init_scenario(); +void init_scenario() __attribute__((deprecated)); short edit_ter_type(short which_ter); -void edit_ter_type_event_filter (short item_hit); +//void edit_ter_type_event_filter (short item_hit); bool save_ter_info(); void put_ter_info_in_dlog(); void put_monst_info_in_dlog(); diff --git a/osx/Scenario Editor/scen.fileio.cpp b/osx/Scenario Editor/scen.fileio.cpp index f07018dc..9421e29d 100644 --- a/osx/Scenario Editor/scen.fileio.cpp +++ b/osx/Scenario Editor/scen.fileio.cpp @@ -1,4 +1,4 @@ -#include +#include #include "scen.global.h" #include "classes.h" #include diff --git a/osx/Scenario Editor/scen.graphics.cpp b/osx/Scenario Editor/scen.graphics.cpp index 510145ed..4006c42b 100644 --- a/osx/Scenario Editor/scen.graphics.cpp +++ b/osx/Scenario Editor/scen.graphics.cpp @@ -1,11 +1,12 @@ -#include -#include +#include +#include +#include #include "scen.global.h" #include "classes.h" #include "graphtool.h" #include "scen.graphics.h" -#include +#include #include "dlgtool.h" #include "scen.keydlgs.h" #include "soundtool.h" @@ -64,23 +65,27 @@ extern location cur_out; short num_ir[3] = {12,10,4}; -GWorldPtr monst_gworld[11]; -GWorldPtr terrain_gworld[7]; -GWorldPtr editor_mixed; -GWorldPtr terrain_buttons_gworld; -GWorldPtr anim_gworld; -GWorldPtr fields_gworld; -GWorldPtr dialog_gworld; -GWorldPtr items_gworld; -GWorldPtr tiny_obj_gworld; -GWorldPtr small_ter_gworld; +GWorldPtr monst_gworld[11] = {0}; +GWorldPtr terrain_gworld[7] = {0}; +GWorldPtr editor_mixed = NULL; +GWorldPtr terrain_buttons_gworld = NULL; +GWorldPtr anim_gworld = NULL; +GWorldPtr fields_gworld = NULL; +GWorldPtr dialog_gworld = NULL; +GWorldPtr items_gworld = NULL; +GWorldPtr tiny_obj_gworld = NULL; +GWorldPtr small_ter_gworld = NULL; +GWorldPtr boom_gworld = NULL; GWorldPtr spec_scen_g = NULL; +GWorldPtr vehicle_gworld = NULL; //GWorldPtr dlg_buttons_gworld[NUM_BUTTONS][2] -GWorldPtr ter_draw_gworld; -GWorldPtr dlogpics_gworld; -GWorldPtr talkfaces_gworld; -GWorldPtr roads_gworld; -GWorldPtr mixed_gworld; +GWorldPtr ter_draw_gworld = NULL; +GWorldPtr dlogpics_gworld = NULL; +GWorldPtr talkfaces_gworld = NULL; +GWorldPtr roads_gworld = NULL; +GWorldPtr missiles_gworld = NULL; +GWorldPtr status_gworld = NULL; +GWorldPtr pc_gworld = NULL; PixPatHandle map_pat[25]; // begin new stuff @@ -175,7 +180,7 @@ void init_dialogs(){ cd_register_event_filter(810,edit_add_town_event_filter); cd_register_event_filter(811,edit_scenario_events_event_filter); cd_register_event_filter(812,edit_item_placement_event_filter); - cd_register_event_filter(813,edit_ter_type_event_filter); + //cd_register_event_filter(813,edit_ter_type_event_filter); cd_register_event_filter(814,edit_monst_type_event_filter); cd_register_event_filter(815,edit_monst_abil_event_filter); cd_register_event_filter(816,edit_text_event_filter); @@ -422,20 +427,30 @@ void load_graphics(){ for (i = 0; i < 25; i++) map_pat[i] = GetPixPat (200 + i); - 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); - editor_mixed = load_pict(906); - anim_gworld = load_pict(820); - fields_gworld = load_pict(821); - roads_gworld = load_pict(822); - talkfaces_gworld = load_pict(860); - items_gworld = load_pict(901); - tiny_obj_gworld = load_pict(900); - dlogpics_gworld = load_pict(850); - small_ter_gworld = load_pict(904); - mixed_gworld = load_pict(903); + for (i = 0; i < 11; i++){ + std::ostringstream sout; + sout << "monst" << i + 1 << ".png"; + monst_gworld[i] = load_pict(sout.str()); + } + for (i = 0; i < 7; i++){ + std::ostringstream sout; + sout << "ter" << i + 1 << ".png"; + terrain_gworld[i] = load_pict(sout.str()); + } + editor_mixed = load_pict("edbuttons.png"); + anim_gworld = load_pict("teranim.png"); + fields_gworld = load_pict("fields.png"); + roads_gworld = load_pict("trim.png"); + talkfaces_gworld = load_pict("talkportraits.png"); + items_gworld = load_pict("objects.png"); + tiny_obj_gworld = load_pict("tinyobj.png"); + dlogpics_gworld = load_pict("dlogpics.png"); + small_ter_gworld = load_pict("termap.png"); + //mixed_gworld = load_pict(903); + vehicle_gworld = load_pict("vehicle.png"); + missiles_gworld = load_pict("missiles.png"); + status_gworld = load_pict("staticons.png"); + pc_gworld = load_pict("pcs.png"); } void load_main_screen() { @@ -695,13 +710,11 @@ void draw_terrain(){ Rect draw_rect,clipping_rect = {8,8,332,260}; unsigned char t_to_draw; Rect source_rect,tiny_to,tiny_to_base = {37,29,44,36},tiny_from,from_rect,to_rect; - Rect boat_rect[4] = {{0,0,36,28}, {0,28,36,56},{0,56,36,84},{0,84,36,112}}; + Rect boat_rect = {0,0,36,28}; if (overall_mode >= MODE_MAIN_SCREEN) return; - OffsetRect(&boat_rect[0],61,0); - if (cur_viewing_mode == 0) { SetPort( ter_draw_gworld); FillCRect(&terrain_rect,bg[17]); @@ -798,17 +811,16 @@ void draw_terrain(){ if ((scenario.boats[i].which_town == cur_town) && (scenario.boats[i].loc.x == cen_x + q - 4) && (scenario.boats[i].loc.y == cen_y + r - 4)) - Draw_Some_Item(mixed_gworld,boat_rect[0],ter_draw_gworld,where_draw,1,0); + Draw_Some_Item(vehicle_gworld,boat_rect,ter_draw_gworld,where_draw,1,0); } for (i = 0; i < 30; i++) { - source_rect = boat_rect[0]; - OffsetRect(&source_rect,0,74); - OffsetRect(&source_rect,56,36); + source_rect = boat_rect; + OffsetRect(&source_rect,0,36); if ((scenario.horses[i].which_town == cur_town) && (scenario.horses[i].loc.x == cen_x + q - 4) && (scenario.horses[i].loc.y == cen_y + r - 4)) - Draw_Some_Item(mixed_gworld,source_rect,ter_draw_gworld,where_draw,1,0); + Draw_Some_Item(vehicle_gworld,source_rect,ter_draw_gworld,where_draw,1,0); } for (i = 0; i < 4; i++) diff --git a/osx/Scenario Editor/scen.keydlgs.cpp b/osx/Scenario Editor/scen.keydlgs.cpp index 8e2b8b04..783db101 100644 --- a/osx/Scenario Editor/scen.keydlgs.cpp +++ b/osx/Scenario Editor/scen.keydlgs.cpp @@ -1258,7 +1258,7 @@ void edit_scen_intro() { } void make_cursor_sword() { - set_cursor(0); + set_cursor(wand_curs); } // only used at beginning of program diff --git a/osx/Scenario Editor/scen.main.cpp b/osx/Scenario Editor/scen.main.cpp index 4f5636cf..9e67af1d 100644 --- a/osx/Scenario Editor/scen.main.cpp +++ b/osx/Scenario Editor/scen.main.cpp @@ -1,5 +1,5 @@ -#include +#include #include "scen.global.h" #include "classes.h" @@ -314,7 +314,7 @@ void handle_menu_choice(long choice) { menu = HiWord(choice); menu_item = LoWord(choice); - set_cursor(0); + set_cursor(wand_curs); switch (menu) { case 500: handle_apple_menu(menu_item); @@ -522,7 +522,7 @@ void handle_town_menu(int item_hit) { case 3: overall_mode = MODE_SET_TOWN_RECT; mode_count = 2; - set_cursor(5); + set_cursor(topleft_curs); set_string("Set town boundary","Select upper left corner"); break; case 4: @@ -729,6 +729,7 @@ void Mouse_Pressed() { void close_program() { restore_depth(); if(town != NULL) delete town; + clean_up_graphtool(); } void ding() { diff --git a/osx/Scenario Editor/scen.townout.cpp b/osx/Scenario Editor/scen.townout.cpp index 7743f765..d5c6a7ce 100644 --- a/osx/Scenario Editor/scen.townout.cpp +++ b/osx/Scenario Editor/scen.townout.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include "scen.global.h" #include "classes.h" #include "graphtool.h" @@ -50,7 +50,6 @@ short store_which_talk_node,last_talk_node[60]; cSpeech::cNode store_talk_node; location store_cur_loc; -__attribute__((deprecated)) void init_town(short size) { short i,j; Str255 temp_str; @@ -90,7 +89,6 @@ void init_town(short size) { } } -__attribute__((deprecated)) void init_out() { short i,j; Str255 temp_str; diff --git a/osx/Scenario Editor/scen.townout.h b/osx/Scenario Editor/scen.townout.h index 1325d85b..f93b5d22 100644 --- a/osx/Scenario Editor/scen.townout.h +++ b/osx/Scenario Editor/scen.townout.h @@ -1,7 +1,5 @@ -__attribute__((deprecated)) -void init_town(short size); -__attribute__((deprecated)) -void init_out(); +void init_town(short size) __attribute__((deprecated)); +void init_out() __attribute__((deprecated)); void edit_placed_monst(short which_m); void edit_placed_monst_event_filter (short item_hit); bool get_placed_monst_in_dlog(); diff --git a/osx/Scenario Editor/strings/arena-names.txt b/osx/Scenario Editor/strings/arena-names.txt new file mode 100644 index 00000000..a9f81cbb --- /dev/null +++ b/osx/Scenario Editor/strings/arena-names.txt @@ -0,0 +1,20 @@ +Grassy field +Ordinary cave +Mountain +Surface bridge +Cave bridge +Rubble-strewn cave +Cave tree forest +Cave mushrooms +Cave swamp +Surface rocks +Surface swamp +Surface woods +Shrubbery +Stalagmites +Cave fumarole +Curface fumarole +Cave road +Surface road +Hills road +Crops \ No newline at end of file diff --git a/osx/Scenario Editor/strings/ter-flag1.txt b/osx/Scenario Editor/strings/ter-flag1.txt new file mode 100644 index 00000000..15331ea7 --- /dev/null +++ b/osx/Scenario Editor/strings/ter-flag1.txt @@ -0,0 +1,24 @@ +Small Icon +What to change to? +Amount of damage done +Unused +Graphic when occupied +Strength (1-8) +Unused +Terrain to change to +Terrain to change to when locked +Terrain to change to when unlocked +Unused +Unused +Number of special to call +Unused +Unused +Direction +Direction +Unused +Unused +Unused +Unused +Terrain type if hidden +Terrain to change to when used +Number of special to call \ No newline at end of file diff --git a/osx/Scenario Editor/strings/ter-flag2.txt b/osx/Scenario Editor/strings/ter-flag2.txt new file mode 100644 index 00000000..b76c19af --- /dev/null +++ b/osx/Scenario Editor/strings/ter-flag2.txt @@ -0,0 +1,24 @@ +Unused +Number of sound (99 - no sound) +Damage multiplier +Unused +Unused +Percentage chance +Unused +Strength +Unused +Difficulty (0-4 L, 5-9 M, 10 I) +Unused +Unused +Type of special (0 - local, 1 - town/global, 2 - out/global, 3 - global) +Unused +Unused +Unused +Unused +Unused +Unused +Unused +Unused +Unused +Number of sound (99 - no sound) +Type of special (0 - local, 1 - town/global, 2 - out/global, 3 - global) \ No newline at end of file diff --git a/osx/Scenario Editor/strings/ter-flag3.txt b/osx/Scenario Editor/strings/ter-flag3.txt new file mode 100644 index 00000000..24cb6bff --- /dev/null +++ b/osx/Scenario Editor/strings/ter-flag3.txt @@ -0,0 +1,24 @@ +Unused +Unused +Damage type +Unused +Unused +Status type +Unused +Method (1 - Move Mountains, 2 - quickfire, 0 - either) +Unused +Can be bashed? (0 - can't, 1 - can) +Unused +Unused +Small icon +Unused +Unused +Unused +Unused +Unused +Unused +Unused +Unused +Unused +Unused +Unused \ No newline at end of file diff --git a/osx/Scenario Editor/strings/trim-names.txt b/osx/Scenario Editor/strings/trim-names.txt new file mode 100644 index 00000000..25c6e81c --- /dev/null +++ b/osx/Scenario Editor/strings/trim-names.txt @@ -0,0 +1,19 @@ +Not a trim +Wall (round off corners) +South edge trim +Southeast outer corner trim +East edge trim +Northeast outer corner trim +North edge trim +Northwest outer corner trim +West edge trim +Southwest outer corner trim +Northeast inner corner trim +Southeast inner corner trim +Southwest inner corner trim +Northwest inner corner trim +Frills (draw edge frills) +Road (connect with roads) +Walkway (round off corners) +Waterfall (both wall and water) +City trim (connect to roads) \ No newline at end of file diff --git a/osx/boe.actions.cpp b/osx/boe.actions.cpp index 72f42151..a369d731 100644 --- a/osx/boe.actions.cpp +++ b/osx/boe.actions.cpp @@ -1,5 +1,5 @@ -#include +#include //#include "item.h" @@ -2476,19 +2476,19 @@ location get_cur_direction(Point the_point) the_point.v += 5; the_point.h += 5; - if ((the_point.h < 135) & (the_point.v >= ((the_point.h * 34) / 10) - 293) - & (the_point.v <= (-1 * ((the_point.h * 34) / 10) + 663))) - store_dir.x--; - if ((the_point.h > 163) & (the_point.v <= ((the_point.h * 34) / 10) - 350) - & (the_point.v >= (-1 * ((the_point.h * 34) / 10) + 721))) - store_dir.x++; - - if ((the_point.v < 167) & (the_point.v <= (the_point.h / 2) + 102) - & (the_point.v <= (-1 * (the_point.h / 2) + 249))) - store_dir.y--; - if ((the_point.v > 203) & (the_point.v >= (the_point.h / 2) + 123) - & (the_point.v >= (-1 * (the_point.h / 2) + 268))) - store_dir.y++; + if ((the_point.h < 135) & (the_point.v >= ((the_point.h * 34) / 10) - 293) + & (the_point.v <= (-1 * ((the_point.h * 34) / 10) + 663))) + store_dir.x--; + if ((the_point.h > 163) & (the_point.v <= ((the_point.h * 34) / 10) - 350) + & (the_point.v >= (-1 * ((the_point.h * 34) / 10) + 721))) + store_dir.x++; + + if ((the_point.v < 167) & (the_point.v <= (the_point.h / 2) + 102) + & (the_point.v <= (-1 * (the_point.h / 2) + 249))) + store_dir.y--; + if ((the_point.v > 203) & (the_point.v >= (the_point.h / 2) + 123) + & (the_point.v >= (-1 * (the_point.h / 2) + 268))) + store_dir.y++; return store_dir; } diff --git a/osx/boe.combat.cpp b/osx/boe.combat.cpp index e1effeb0..11e59928 100644 --- a/osx/boe.combat.cpp +++ b/osx/boe.combat.cpp @@ -1,4 +1,4 @@ -#include +#include //#include "item.h" @@ -1938,7 +1938,8 @@ void do_monster_turn() r1 = get_ran(1,1,6); if (r1 == 3) cur_monst->morale++; - if ((univ.party[univ.town.monst[i].target].main_status == 1) && (cur_monst->mobility == 1)) { + short targ = univ.town.monst[i].target; + if (targ < 6 && (univ.party[targ].main_status == 1) && (cur_monst->mobility == 1)) { acted_yet = flee_party (i,cur_monst->cur_loc,targ_space); if (acted_yet == true) take_m_ap(1,cur_monst); } diff --git a/osx/boe.consts.h b/osx/boe.consts.h index 27c262b8..579b8b1d 100644 --- a/osx/boe.consts.h +++ b/osx/boe.consts.h @@ -71,6 +71,7 @@ enum eGameMode { MODE_TOWN_TARGET = 3, // spell target, that is MODE_USE_TOWN = 4, MODE_DROP_TOWN = 5, + MODE_BASH_TOWN = 6, // unused MODE_COMBAT = 10, MODE_SPELL_TARGET = 11, MODE_FIRING = 12, // firing from bow or crossbow diff --git a/osx/boe.dlgutil.cpp b/osx/boe.dlgutil.cpp index 324c739f..61fcde72 100644 --- a/osx/boe.dlgutil.cpp +++ b/osx/boe.dlgutil.cpp @@ -1,5 +1,5 @@ -#include +#include //#include "item.h" @@ -21,7 +21,7 @@ #include "boe.main.h" #include "boe.items.h" #include "soundtool.h" -#include +#include #include "dlgtool.h" #include "dlgconsts.h" #include "boe.newgraph.h" @@ -56,14 +56,12 @@ extern cScenario scenario; extern cUniverse univ; //extern piles_of_stuff_dumping_type *data_store; //extern talking_record_type talking; - +extern GWorldPtr pc_gworld; short terrain_pic[256]; extern cScenarioList scen_headers; - -GWorldPtr pcs_gworld = NULL; short sign_mode,person_graphic,store_person_graphic,store_sign_mode; long num_talk_entries; @@ -1697,9 +1695,9 @@ void edit_party(short can_create,short can_cancel) make_cursor_sword(); - if (pcs_gworld == NULL) { + if (pc_gworld == NULL) { munch_pc_graphic = true; - pcs_gworld = load_pict(902); + pc_gworld = load_pict(902); } cd_create_dialog(989,mainPtr); @@ -1715,8 +1713,8 @@ void edit_party(short can_create,short can_cancel) cd_kill_dialog(989); if (munch_pc_graphic == true) { - DisposeGWorld(pcs_gworld); - pcs_gworld = NULL; + DisposeGWorld(pc_gworld); + pc_gworld = NULL; } if (univ.party[current_pc].main_status != 1) diff --git a/osx/boe.fileio.cpp b/osx/boe.fileio.cpp index c8d878dc..33570764 100644 --- a/osx/boe.fileio.cpp +++ b/osx/boe.fileio.cpp @@ -522,7 +522,6 @@ void change_val (unsigned char *val,short a,short b) // // // Now more initialization is needed. First need to properly create the misc_i array. // -__attribute__((deprecated)) void init_town(){ // formerly part of load_town // Initialize barriers, etc. Note non-sfx gets forgotten if this is a town recently visited. // if (mode == 0) { diff --git a/osx/boe.fileio.h b/osx/boe.fileio.h index e5e6f346..e1578451 100644 --- a/osx/boe.fileio.h +++ b/osx/boe.fileio.h @@ -42,8 +42,8 @@ bool load_scenario_header(FSRef filename/*,short header_entry*/); //short str_size_3(short flag); //short get_buf_ptr(short flag); //bool check_p (short pword); -__attribute__((deprecated)) -void init_town(); + +void init_town() __attribute__((deprecated)); //void port_talk_nodes(); //void port_town(); diff --git a/osx/boe.graphics.cpp b/osx/boe.graphics.cpp index 26f79ecb..7943fa0b 100644 --- a/osx/boe.graphics.cpp +++ b/osx/boe.graphics.cpp @@ -1,6 +1,6 @@ -#include -#include +#include +#include //#include "item.h" @@ -128,36 +128,38 @@ char light_area[13][13]; char unexplored_area[13][13]; // Declare the graphics -GWorldPtr mixed_gworld; -GWorldPtr pc_stats_gworld; -GWorldPtr item_stats_gworld; -GWorldPtr text_area_gworld; -GWorldPtr storage_gworld; -GWorldPtr terrain_screen_gworld; -GWorldPtr text_bar_gworld; -GWorldPtr orig_text_bar_gworld; -GWorldPtr buttons_gworld; -GWorldPtr party_template_gworld; -GWorldPtr items_gworld; -GWorldPtr tiny_obj_gworld; -GWorldPtr fields_gworld; -GWorldPtr boom_gworld; -GWorldPtr roads_gworld; -GWorldPtr map_gworld; -GWorldPtr tiny_map_graphics; -GWorldPtr missiles_gworld; -GWorldPtr dlogpics_gworld; -GWorldPtr anim_gworld; -GWorldPtr talkfaces_gworld; -GWorldPtr pc_gworld; -GWorldPtr monst_gworld[11]; -GWorldPtr terrain_gworld[7]; +GWorldPtr status_gworld = NULL; +GWorldPtr invenbtn_gworld = NULL; +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; +GWorldPtr boom_gworld = NULL; +GWorldPtr roads_gworld = NULL; +GWorldPtr map_gworld = NULL; +GWorldPtr small_ter_gworld = NULL; +GWorldPtr missiles_gworld = NULL; +GWorldPtr dlogpics_gworld = NULL; +GWorldPtr anim_gworld = NULL; +GWorldPtr talkfaces_gworld = NULL; +GWorldPtr pc_gworld = NULL; +GWorldPtr monst_gworld[11] = {0}; +GWorldPtr terrain_gworld[7] = {0}; // Startup graphics, will die when play starts -GWorldPtr startup_gworld; -GWorldPtr startup_button_orig; -GWorldPtr startup_button_g; -GWorldPtr anim_mess; +GWorldPtr startup_gworld = NULL; +GWorldPtr startup_button_orig = NULL; +GWorldPtr startup_button_g = NULL; +GWorldPtr anim_mess = NULL; // Graphics storage vals short which_g_stored[STORED_GRAPHICS]; @@ -213,7 +215,7 @@ void init_dialogs(){ &dlogpics_gworld, monst_gworld, terrain_gworld, - &tiny_map_graphics, + &small_ter_gworld, &fields_gworld, &pc_stats_gworld, &item_stats_gworld,/* @@ -224,7 +226,7 @@ void init_dialogs(){ &orig_text_bar_gworld, &buttons_gworld, &party_template_gworld,*/ - &mixed_gworld, + NULL, &spec_scen_g ); //cd_register_event_filter(823,give_password_filter); @@ -287,7 +289,7 @@ void adjust_window_mode() } create_clip_region(); undo_clip(); - if (overall_mode != MODE_STARTUP) { + if (overall_mode != MODE_STARTUP) { // TODO: This is odd – fix it if (in_startup_mode == true) draw_startup(0); if (in_startup_mode == false) @@ -304,12 +306,12 @@ void adjust_window_mode() void plop_fancy_startup() { - PicHandle pict_to_draw; + GWorldPtr pict_to_draw; short i,j; GDHandle md; - Rect whole_window; + Rect whole_window,from_rect; Rect logo_from = {0,0,350,350}; Rect intro_from = {0,0,483,643}; GDHandle mainScreen; @@ -327,7 +329,7 @@ void plop_fancy_startup() md = GetMainDevice(); - if (fry_startup == false) { + if (fry_startup == false) { // TODO: What on earth is this for? //color_pat = GetCTable(72); //old_palette = NewPalette(256,color_pat,pmTolerant + pmExplicit,0x0000); //GetPictInfo(pict_to_draw,&p2,1,256,0,0); @@ -364,7 +366,7 @@ void plop_fancy_startup() SetPort(oldPort); */ } - // initialize buffers and rects + // 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; @@ -385,10 +387,14 @@ void plop_fancy_startup() ForeColor(blackColor); PaintRect(&whole_window); - pict_to_draw = GetPicture(3001); OffsetRect(&logo_from,(whole_window.right - logo_from.right) / 2,(whole_window.bottom - logo_from.bottom) / 2); - DrawPicture(pict_to_draw, &logo_from); - ReleaseResource((Handle) pict_to_draw); +// pict_to_draw = GetPicture(3001); // TODO: Read from file instead +// DrawPicture(pict_to_draw, &logo_from); +// ReleaseResource((Handle) pict_to_draw); + pict_to_draw = load_pict("spidlogo.png"); + GetPortBounds(pict_to_draw,&from_rect); + rect_draw_some_item(pict_to_draw, from_rect, pict_to_draw, logo_from, 0, 1); + DisposeGWorld(pict_to_draw); RgnHandle wholeRegion = NewRgn(); GetWindowRegion(mainPtr, kWindowContentRgn, wholeRegion); @@ -413,17 +419,17 @@ void plop_fancy_startup() int delay = 220; if(show_startup_splash){ //init_anim(0); - pict_to_draw = GetPicture(3000); + //pict_to_draw = GetPicture(3000); // TODO: Read from file instead if (fry_startup == false) { //for(i=100; i >= 0; i-=2) DoOneGammaFade(md, i); - PaintRect(&whole_window); - // load and switch to new palette - GetPictInfo(pict_to_draw,&p,2,256,0,0); - new_palette = p.thePalette; - SetPalette(mainPtr,new_palette,false); - ActivatePalette(mainPtr); +// PaintRect(&whole_window); +// // load and switch to new palette +// GetPictInfo(pict_to_draw,&p,2,256,0,0); +// new_palette = p.thePalette; +// SetPalette(mainPtr,new_palette,false); +// ActivatePalette(mainPtr); // reerase menu /* GetPort(&oldPort); GetDeskTopGrafPort(&wMgrPort); @@ -445,8 +451,12 @@ void plop_fancy_startup() PaintRect(&whole_window); OffsetRect(&intro_from,(whole_window.right - intro_from.right) / 2,(whole_window.bottom - intro_from.bottom) / 2); - DrawPicture(pict_to_draw, &intro_from); - ReleaseResource((Handle) pict_to_draw); +// DrawPicture(pict_to_draw, &intro_from); + // ReleaseResource((Handle) pict_to_draw); + pict_to_draw = load_pict("startsplash.png"); + GetPortBounds(pict_to_draw,&from_rect); + rect_draw_some_item(pict_to_draw, from_rect, pict_to_draw, intro_from, 0, 1); + DisposeGWorld(pict_to_draw); // NSetPalette(mainPtr,old_palette,pmAllUpdates); // ActivatePalette(mainPtr); @@ -507,10 +517,14 @@ 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(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"); + anim_mess = load_pict("startanim.png"); } void init_animation() @@ -821,32 +835,32 @@ void Set_up_win () SysBeep(2); ExitToShell(); } - - temp_gworld = load_pict(800); + // 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,0,0); DisposeGWorld(temp_gworld); - terrain_screen_gworld = load_pict(705); + terrain_screen_gworld = load_pict("terscreen.png"); err = NewGWorld(&party_template_gworld, 0 /*8*/,&pc_rect, NULL, NULL, kNativeEndianPixMap); if (err != 0) SysBeep(2); - - 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); + // 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); @@ -872,21 +886,16 @@ void Set_up_win () void load_main_screen() { - if (tiny_map_graphics != NULL) + if (invenbtn_gworld != NULL) return; - - tiny_map_graphics = load_pict(904); - mixed_gworld = load_pict(903); - - pc_stats_gworld = load_pict(700); - - item_stats_gworld = load_pict(701); - - text_area_gworld = load_pict(702); - - text_bar_gworld = load_pict(703); - orig_text_bar_gworld = load_pict(703); - buttons_gworld = load_pict(704); + + invenbtn_gworld = load_pict("invenbtns.png"); + pc_stats_gworld = load_pict("statarea.png"); + item_stats_gworld = load_pict("inventory.png"); + text_area_gworld = load_pict("transcript.png"); + text_bar_gworld = load_pict("textbar.png"); + orig_text_bar_gworld = load_pict("textbar.png"); + buttons_gworld = load_pict("buttons.png"); set_gworld_fonts(geneva_font_num); @@ -1109,7 +1118,7 @@ void draw_buttons(short mode) buttons_to_draw = buttons_gworld; store_source = GetPortPixMap(buttons_to_draw); - if (is_combat()) { + if (is_combat()) { // TODO: Draw buttons one at a time instead of singly source_rect.top += 37; source_rect.bottom += 37; } @@ -1518,10 +1527,10 @@ void load_town_graphics() // Setting up town monsters takes some finess, due to } } -void update_pc_graphics() +void update_pc_graphics() // TODO: The party_template_gworld isn't really necessary; abolish it { short i; - GWorldPtr temp_gworld,temp_gworld2; + GWorldPtr temp_gworld;//,temp_gworld2; Rect template_rect = {0,0,36,28}; PixMapHandle store_source, store_dest; Rect source_rect; @@ -1532,8 +1541,9 @@ void update_pc_graphics() GetPort(&old_port); SetPortWindowPort(mainPtr); - temp_gworld = load_pict(902); - temp_gworld2 = load_pict(905); +// 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) @@ -1558,7 +1568,7 @@ void update_pc_graphics() &source_rect, &template_rect, 0 , NULL); - store_source = GetPortPixMap(temp_gworld2); + OffsetRect(&source_rect,0,288); OffsetRect(&template_rect,0,108); CopyBits ( (BitMap *) *store_source , (BitMap *) *store_dest , @@ -1568,7 +1578,7 @@ void update_pc_graphics() which_graphic_index[i] = univ.party[i].which_graphic; } DisposeGWorld (temp_gworld); - DisposeGWorld (temp_gworld2); + //DisposeGWorld (temp_gworld2); SetPort(old_port); @@ -1577,7 +1587,7 @@ void update_pc_graphics() // 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() +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; @@ -2562,7 +2572,13 @@ void boom_space(location where,short mode,short type,short damage,short sound) void draw_pointing_arrows() { - Rect sources[4] = {{65,46,73,54},{56,46,64,54},{56,37,64,45},{65,37,73,45}}; + //Rect sources[4] = {{65,46,73,54},{56,46,64,54},{56,37,64,45},{65,37,73,45}}; + Rect sources[4] = { + {352,58,360,76}, // up + {352,20,360,38}, // left + {352,01,360,19}, // down + {352,39,360,57} // right + }; Rect dests[8] = {{7,100,15,108},{7,170,15,178},{140,7,148,15},{212,7,220,15}, {346,100,354,108},{346,170,354,178},{140,274,148,282},{212,274,220,282}}; short i; @@ -2571,8 +2587,8 @@ void draw_pointing_arrows() || (overall_mode == MODE_LOOK_OUTDOORS)) return; for (i = 0; i < 4; i++) { - rect_draw_some_item (mixed_gworld,sources[i],mixed_gworld,dests[i * 2],1,1); - rect_draw_some_item (mixed_gworld,sources[i],mixed_gworld,dests[i * 2 + 1],1,1); + rect_draw_some_item (terrain_screen_gworld,sources[i],terrain_screen_gworld,dests[i * 2],1,1); + rect_draw_some_item (terrain_screen_gworld,sources[i],terrain_screen_gworld,dests[i * 2 + 1],1,1); } } @@ -2609,9 +2625,9 @@ void draw_targets(location center) for (i = 0; i < 8; i++) if ((spell_targets[i].x != 120) && (point_onscreen(center,spell_targets[i]) == true)) { dest_rect = coord_to_rect(spell_targets[i].x - center.x + 4,spell_targets[i].y - center.y + 4); - OffsetRect(&dest_rect,5,5); - InsetRect(&dest_rect,8,12); - rect_draw_some_item (mixed_gworld,source_rect,mixed_gworld,dest_rect,1,1); + //OffsetRect(&dest_rect,5,5); + //InsetRect(&dest_rect,8,12); + rect_draw_some_item (roads_gworld,calc_rect(6,0),roads_gworld,dest_rect,1,1); } } @@ -2928,56 +2944,4 @@ void HideShowMenuBar( ) LMSetGrayRgn( originalGrayRgn ); } -*/ -void tileImage(Rect area, GWorldPtr img, short mode){ - RgnHandle clip= NewRgn(); - RectRgn(clip,&area); - - GrafPtr cur_port; - GetPort(&cur_port); - const BitMap* drawDest = GetPortBitMapForCopyBits(cur_port); - PixMapHandle drawSource = GetPortPixMap(img); - - Rect imgRect; - GetPortBounds(img, &imgRect); - - int imgWidth=imgRect.right-imgRect.left; - int imgHeight=imgRect.bottom-imgRect.top; - int x,y; - unsigned int hrep = (int)((double(area.right-area.left)/imgWidth)+0.5); - unsigned int vrep = (int)((double(area.bottom-area.top)/imgHeight)+0.5); - for(unsigned int i=0; i +#include //#include "item.h" @@ -47,7 +47,7 @@ extern short combat_posing_monster , current_working_monster ; // 0-5 PC 100 + 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,mixed_gworld,anim_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 @@ -485,27 +485,27 @@ void draw_outd_boats(location center) short i; for (i = 0; i < 30; i++) - if ((point_onscreen(center, univ.party.boats[i].loc) == true) && (univ.party.boats[i].exists == true) && - (univ.party.boats[i].which_town == 200) && - (can_see(center, univ.party.boats[i].loc,0) < 5) && (univ.party.in_boat != i)) { - where_draw.x = univ.party.boats[i].loc.x - center.x + 4; - where_draw.y = univ.party.boats[i].loc.y - center.y + 4; - source_rect = boat_rects[0]; - OffsetRect(&source_rect,61,0); - Draw_Some_Item(mixed_gworld, source_rect, terrain_screen_gworld, where_draw, 1, 0); - } + if ((point_onscreen(center, univ.party.boats[i].loc) == true) && (univ.party.boats[i].exists == true) && + (univ.party.boats[i].which_town == 200) && + (can_see(center, univ.party.boats[i].loc,0) < 5) && (univ.party.in_boat != i)) { + where_draw.x = univ.party.boats[i].loc.x - center.x + 4; + where_draw.y = univ.party.boats[i].loc.y - center.y + 4; + //source_rect = boat_rects[0]; + //OffsetRect(&source_rect,61,0); + Draw_Some_Item(vehicle_gworld, calc_rect(0,0), terrain_screen_gworld, where_draw, 1, 0); + } for (i = 0; i < 30; i++) - if ((point_onscreen(center, univ.party.horses[i].loc) == true) && (univ.party.horses[i].exists == true) && - (univ.party.horses[i].which_town == 200) && - (can_see(center, univ.party.horses[i].loc,0) < 5) && (univ.party.in_horse != i)) { - where_draw.x = univ.party.horses[i].loc.x - center.x + 4; - where_draw.y = univ.party.horses[i].loc.y - center.y + 4; - source_rect = boat_rects[0]; - OffsetRect(&source_rect,61,0); - OffsetRect(&source_rect,0,74); - OffsetRect(&source_rect,56,36); - Draw_Some_Item(mixed_gworld, source_rect, terrain_screen_gworld, where_draw, 1, 0); - } + if ((point_onscreen(center, univ.party.horses[i].loc) == true) && (univ.party.horses[i].exists == true) && + (univ.party.horses[i].which_town == 200) && + (can_see(center, univ.party.horses[i].loc,0) < 5) && (univ.party.in_horse != i)) { + where_draw.x = univ.party.horses[i].loc.x - center.x + 4; + where_draw.y = univ.party.horses[i].loc.y - center.y + 4; + //source_rect = boat_rects[0]; + //OffsetRect(&source_rect,61,0); + //OffsetRect(&source_rect,0,74); + //OffsetRect(&source_rect,56,36); + Draw_Some_Item(vehicle_gworld, calc_rect(0,1), terrain_screen_gworld, where_draw, 1, 0); + } } void draw_town_boat(location center) @@ -521,24 +521,23 @@ void draw_town_boat(location center) && (pt_in_light(center,univ.party.boats[i].loc) == true))) { where_draw.x = univ.party.boats[i].loc.x - center.x + 4; where_draw.y = univ.party.boats[i].loc.y - center.y + 4; - source_rect = boat_rects[0]; - OffsetRect(&source_rect,61,0); - Draw_Some_Item(mixed_gworld, source_rect, terrain_screen_gworld, where_draw, 1, 0); - } - for (i = 0; i < 30; i++) + //source_rect = boat_rects[0]; + //OffsetRect(&source_rect,61,0); + Draw_Some_Item(vehicle_gworld, calc_rect(1,0), terrain_screen_gworld, where_draw, 1, 0); + } + for (i = 0; i < 30; i++) if ((univ.party.horses[i].which_town == univ.town.num) && ((point_onscreen(center, univ.party.horses[i].loc) == true) && (can_see(center, univ.party.horses[i].loc,0) < 5) && (univ.party.in_horse != i) && (pt_in_light(center,univ.party.horses[i].loc) == true))) { where_draw.x = univ.party.horses[i].loc.x - center.x + 4; where_draw.y = univ.party.horses[i].loc.y - center.y + 4; - - source_rect = boat_rects[0]; - OffsetRect(&source_rect,61,0); - OffsetRect(&source_rect,0,74); - OffsetRect(&source_rect,56,36); - Draw_Some_Item(mixed_gworld, source_rect, terrain_screen_gworld, where_draw, 1, 0); - } + //source_rect = boat_rects[0]; + //OffsetRect(&source_rect,61,0); + //OffsetRect(&source_rect,0,74); + //OffsetRect(&source_rect,56,36); + Draw_Some_Item(vehicle_gworld, calc_rect(1,1), terrain_screen_gworld, where_draw, 1, 0); + } } void draw_fields(location where){ @@ -615,28 +614,29 @@ void draw_party_symbol(short mode,location center) if (overall_mode == MODE_LOOK_TOWN) { target.x += univ.town.p_loc.x - center.x; target.y += univ.town.p_loc.y - center.y; - } + } - 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 < 4) ? 0 : 1); + 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); 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,0); //// - else Draw_Some_Item(party_template_gworld, source_rect, terrain_screen_gworld, target, 1, 0); + // 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,0); + else Draw_Some_Item(party_template_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]]; - OffsetRect(&source_rect,61,0); - Draw_Some_Item(mixed_gworld, source_rect, terrain_screen_gworld, target, 1, 0); - } - else { - source_rect = boat_rects[(univ.party.direction < 4) ? 0 : 1]; - OffsetRect(&source_rect,61,0); - OffsetRect(&source_rect,0,74); - Draw_Some_Item(mixed_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]]; + //OffsetRect(&source_rect,61,0); + if(univ.party.direction == 0 || univ.party.direction > 4) i = 4; + else i = 3; + Draw_Some_Item(vehicle_gworld, calc_rect(i,0), terrain_screen_gworld, target, 1, 0); + }else { + //source_rect = boat_rects[(univ.party.direction < 4) ? 0 : 1]; + //OffsetRect(&source_rect,61,0); + //OffsetRect(&source_rect,0,74); + Draw_Some_Item(vehicle_gworld, calc_rect( univ.party.direction > 3 , 1), terrain_screen_gworld, target, 1, 0); + } } diff --git a/osx/boe.infodlg.cpp b/osx/boe.infodlg.cpp index 673261eb..f79cb8a4 100644 --- a/osx/boe.infodlg.cpp +++ b/osx/boe.infodlg.cpp @@ -1,4 +1,4 @@ -#include +#include //#include "item.h" @@ -9,7 +9,7 @@ #include "boe.graphics.h" #include "boe.newgraph.h" #include "boe.items.h" -#include +#include #include "boe.monster.h" #include "dlgtool.h" #include "dlgconsts.h" diff --git a/osx/boe.itemdata.cpp b/osx/boe.itemdata.cpp index e2c05e67..b89ab682 100644 --- a/osx/boe.itemdata.cpp +++ b/osx/boe.itemdata.cpp @@ -1,6 +1,6 @@ -#include -#include +#include +#include //#include "item.h" diff --git a/osx/boe.items.cpp b/osx/boe.items.cpp index 87898e16..96b13ccd 100644 --- a/osx/boe.items.cpp +++ b/osx/boe.items.cpp @@ -1,6 +1,6 @@ -#include -#include +#include +#include //#include "item.h" @@ -26,7 +26,7 @@ #include "mathutil.h" #include "dlgutil.h" -extern short stat_window,current_cursor,which_combat_type,current_pc; +extern short stat_window,which_combat_type,current_pc; extern eGameMode overall_mode; //extern party_record_type party; //extern current_town_type univ.town; @@ -44,9 +44,8 @@ extern short modeless_key[18]; extern DialogPtr modeless_dialogs[18]; //extern short town_size[3]; extern short town_type; - +extern GWorldPtr pc_gworld; extern short dialog_answer; -extern GWorldPtr pcs_gworld; extern ModalFilterUPP main_dialog_UPP; extern cScenario scenario; extern cUniverse univ; @@ -1049,8 +1048,8 @@ short display_item(location from_loc,short pc_num,short mode, bool check_contain } } - if (pcs_gworld == NULL) - pcs_gworld = load_pict(902); + if (pc_gworld == NULL) + pc_gworld = load_pict(902); cd_create_dialog(987,mainPtr); if (check_container == true) @@ -1074,8 +1073,8 @@ short display_item(location from_loc,short pc_num,short mode, bool check_contain item_hit = cd_run_dialog(); cd_kill_dialog(987); - DisposeGWorld(pcs_gworld); - pcs_gworld = NULL; + DisposeGWorld(pc_gworld); + pc_gworld = NULL; put_item_screen(stat_window,0); put_pc_screen(); diff --git a/osx/boe.main.cpp b/osx/boe.main.cpp index 6a4c4e3a..ca5f001b 100644 --- a/osx/boe.main.cpp +++ b/osx/boe.main.cpp @@ -64,9 +64,6 @@ short on_monst_menu[256]; signed char dir_x_dif[9] = {0,1,1,1,0,-1,-1,-1,0}; signed char dir_y_dif[9] = {-1,-1,0,1,1,1,0,-1,0}; -// Cursors -extern short current_cursor; - bool game_run_before = false; bool debug_on = false; bool give_intro_hint = true; @@ -232,8 +229,8 @@ int main(void) init_spell_menus(); - if (overall_mode == MODE_STARTUP) - overall_mode = MODE_OUTDOORS; +// if (overall_mode == MODE_STARTUP) +// overall_mode = MODE_OUTDOORS; if (!game_run_before) FCD(986,0); @@ -416,7 +413,7 @@ void Handle_One_Event() gInBackground = (event.message & 1) == 0; // 1 is Resume Mask //switch_bg_music(gInBackground); // DoActivate(FrontWindow(), !gInBackground); - current_cursor = 300; + //current_cursor = 300; break; } break; @@ -719,6 +716,7 @@ void close_program() //end_music(); if(univ.town.loaded()) univ.town.unload(); if(univ.town.cur_talk != NULL) delete univ.town.cur_talk; + clean_up_graphtool(); } void handle_menu_choice(long choice) @@ -1074,17 +1072,40 @@ void handle_music_menu(int item_hit) // HUnlock((Handle) which_curs); //} +cursor_type get_mode_cursor(){ + switch(overall_mode){ + case MODE_TOWN_TARGET: + case MODE_SPELL_TARGET: + case MODE_FIRING: + case MODE_THROWING: + case MODE_FANCY_TARGET: + return target_curs; + case MODE_TALK_TOWN: + return talk_curs; + case MODE_USE_TOWN: + return key_curs; + case MODE_BASH_TOWN: + return boot_curs; + case MODE_DROP_TOWN: + case MODE_DROP_COMBAT: + return drop_curs; + case MODE_LOOK_OUTDOORS: + case MODE_LOOK_TOWN: + case MODE_LOOK_COMBAT: + return look_curs; + case MODE_RESTING: + return wait_curs; + default: + return sword_curs; + } + return sword_curs; // this should never be reached, though +} + void change_cursor(Point where_curs) { - short curs_types[50] = {0,0,126,124,122,122,0,0,0,0, - 0,124,124,124,124,122,0,0,0,0, - 120,120,0,0,0,0,0,0,0,0, - 0,0,0,0,0,129,129,129,0,0, - 0,0,0,0,0,120,0,0,0,0},cursor_needed; + cursor_type cursor_needed; location cursor_direction; Rect world_screen = {23, 23, 346, 274}; - - SetPortWindowPort(mainPtr); GlobalToLocal(&where_curs); @@ -1093,50 +1114,16 @@ void change_cursor(Point where_curs) where_curs.v -= ul.v; if (PtInRect(where_curs,&world_screen) == false) - cursor_needed = 120; - else cursor_needed = curs_types[overall_mode]; + cursor_needed = sword_curs; + else cursor_needed = get_mode_cursor(); - if (cursor_needed == 0) { - if ((PtInRect(where_curs,&world_screen) == false) || (in_startup_mode == true)) - cursor_needed = 120; - else { - cursor_direction = get_cur_direction(where_curs); - cursor_needed = 100 + (cursor_direction.x) + 10 * ( cursor_direction.y); - if (cursor_needed == 100) - cursor_needed = 120; - } - } + if ((overall_mode == MODE_OUTDOORS || overall_mode == MODE_TOWN || overall_mode == MODE_COMBAT) && PtInRect(where_curs,&world_screen)){ + cursor_direction = get_cur_direction(where_curs); + cursor_needed = arrow_curs[cursor_direction.x + 1][cursor_direction.y + 1];// 100 + (cursor_direction.x) + 10 * ( cursor_direction.y); + } - if (cursor_needed == current_cursor) - return; - - current_cursor = cursor_needed; - - switch (cursor_needed) { - case 120: - set_cursor(sword_curs); - break; - case 121: - set_cursor(boot_curs); - break; - case 122: - set_cursor(key_curs); - break; - case 124: - set_cursor(target_curs); - break; - case 126: - set_cursor(talk_curs); - break; - case 129: - set_cursor(look_curs); - break; - - - default: // an arrow - set_cursor(arrow_curs[cursor_direction.x + 1][cursor_direction.y + 1]); - break; - } + if (cursor_needed != current_cursor) + set_cursor(cursor_needed); } void find_quickdraw() { @@ -1248,7 +1235,7 @@ pascal OSErr handle_quit(AppleEvent *theAppleEvent,AppleEvent *reply,long handle { short choice; - if ((overall_mode > MODE_STARTUP/*40*/) || (in_startup_mode == true)) { + if ((overall_mode == MODE_STARTUP/*40*/) || (in_startup_mode)) { All_Done = true; return noErr; } diff --git a/osx/boe.monster.cpp b/osx/boe.monster.cpp index 55737d94..852618db 100644 --- a/osx/boe.monster.cpp +++ b/osx/boe.monster.cpp @@ -1,4 +1,4 @@ -#include +#include //#include "item.h" diff --git a/osx/boe.newgraph.cpp b/osx/boe.newgraph.cpp index e8e38c83..843861d8 100644 --- a/osx/boe.newgraph.cpp +++ b/osx/boe.newgraph.cpp @@ -1,6 +1,6 @@ -#include -#include +#include +#include //#include "item.h" @@ -50,7 +50,7 @@ extern WindowPtr mainPtr; extern short dungeon_font_num,geneva_font_num,town_type,which_combat_type; extern eGameMode overall_mode; extern bool play_sounds,boom_anim_active,cartoon_happening,in_startup_mode; -extern GWorldPtr fields_gworld,boom_gworld,mixed_gworld,dlg_buttons_gworld[NUM_BUTTONS][2],terrain_screen_gworld,missiles_gworld; +extern GWorldPtr fields_gworld,boom_gworld,dlg_buttons_gworld[NUM_BUTTONS][2],terrain_screen_gworld,missiles_gworld,invenbtn_gworld; //extern party_record_type party; extern Rect sbar_rect,item_sbar_rect,shop_sbar_rect; extern ControlHandle text_sbar,item_sbar,shop_sbar; @@ -930,7 +930,7 @@ char *cost_strs[] = {"Extremely Cheap","Very Reasonable","Pretty Average","Somew TextSize(10); char_port_draw_string( talk_gworld,shopping_rects[i][5],cur_info_str,0,12,false); if ((store_shop_type != 3) && (store_shop_type != 4)) - rect_draw_some_item(mixed_gworld,item_info_from,talk_gworld,shopping_rects[i][6],1 - draw_mode,0); + rect_draw_some_item(invenbtn_gworld,item_info_from,talk_gworld,shopping_rects[i][6],1 - draw_mode,0); } diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index 000a26e6..207f1812 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -14,7 +14,7 @@ #include "boe.itemdata.h" #include "boe.infodlg.h" #include "boe.items.h" -#include +#include #include "boe.party.h" #include "boe.monster.h" #include "dlgtool.h" @@ -147,7 +147,7 @@ extern location golem_m_locs[16]; extern cScenario scenario; extern cUniverse univ; //extern piles_of_stuff_dumping_type *data_store; - +extern GWorldPtr pc_gworld; char c_line[60]; // Variables for spell selection @@ -167,8 +167,7 @@ char c_line[60]; short store_skills[20],store_h,store_sp,i,store_skp,which_skill; long store_g; short store_train_mode,store_train_pc; - -extern GWorldPtr pcs_gworld; + extern ModalFilterUPP main_dialog_UPP; // Dialog vars @@ -193,7 +192,6 @@ void put_pick_spell_graphics(); //mode; // 0 - prefab 1 - regular 2 - debug -__attribute__((deprecated)) void init_party(short mode) { short i,j,k,l; @@ -324,7 +322,6 @@ void init_party(short mode) // Until that time, the party scen vals are uninited // Then, it inits the party properly for starting the scenario based // on the loaded scenario -__attribute__((deprecated)) void init_party_scen_data() { short i,j,k,l; @@ -3026,9 +3023,9 @@ bool pick_pc_graphic(short pc_num,short mode,short parent_num) make_cursor_sword(); - if (pcs_gworld == NULL) { + if (pc_gworld == NULL) { munch_pc_graphic = true; - pcs_gworld = load_pict(902); + pc_gworld = load_pict(902); } cd_create_dialog_parent_num(1050,parent_num); @@ -3044,8 +3041,8 @@ bool pick_pc_graphic(short pc_num,short mode,short parent_num) cd_kill_dialog(1050); if (munch_pc_graphic == true) { - DisposeGWorld(pcs_gworld); - pcs_gworld = NULL; + DisposeGWorld(pc_gworld); + pc_gworld = NULL; } return dialog_answer; } @@ -3541,7 +3538,7 @@ void adjust_spell_menus() short old_on_spell_menu[2][62]; bool need_menu_change = false; - if (in_startup_mode == true) + if (in_startup_mode == true || current_pc == 6) return; for (i = 0; i < 2; i++) diff --git a/osx/boe.party.h b/osx/boe.party.h index f3fd119b..40cf09f8 100644 --- a/osx/boe.party.h +++ b/osx/boe.party.h @@ -1,7 +1,5 @@ -__attribute__((deprecated)) -void init_party(short mode); -__attribute__((deprecated)) -void init_party_scen_data(); +void init_party(short mode) __attribute__((deprecated)); +void init_party_scen_data() __attribute__((deprecated)); void make_boats(); bool create_pc(short spot,short parent_num); bool take_sp(short pc_num,short amt); diff --git a/osx/boe.specials.cpp b/osx/boe.specials.cpp index 2901bea5..a4873df8 100644 --- a/osx/boe.specials.cpp +++ b/osx/boe.specials.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include //#include "item.h" diff --git a/osx/boe.startup.cpp b/osx/boe.startup.cpp index e40e2f60..bdb6184c 100644 --- a/osx/boe.startup.cpp +++ b/osx/boe.startup.cpp @@ -33,6 +33,7 @@ extern cScenarioList scen_headers;; extern bool unreg_party_in_scen_not_check; //extern std::vector scen_names;; extern cUniverse univ; +extern eGameMode overall_mode; //void start_game(); @@ -137,6 +138,7 @@ void startup_load()//// else { menu_activate(0); draw_startup(0); + overall_mode = MODE_STARTUP; } } diff --git a/osx/boe.text.cpp b/osx/boe.text.cpp index a488da34..c9b70b53 100644 --- a/osx/boe.text.cpp +++ b/osx/boe.text.cpp @@ -1,8 +1,8 @@ #define LINES_IN_TEXT_WIN 11 #define TEXT_BUF_LEN 70 -#include -#include +#include +#include //#include "item.h" @@ -59,7 +59,7 @@ extern short which_combat_type,stat_window; extern eGameMode overall_mode; extern WindowPtr mainPtr; extern Rect more_info_button; -extern short which_item_page[6],current_cursor; +extern short which_item_page[6]; //extern CursHandle sword_curs; extern ControlHandle text_sbar,item_sbar; extern Point store_anim_ul; @@ -70,7 +70,7 @@ extern location dest_locs[40] ; //extern piles_of_stuff_dumping_type *data_store; extern cScenario scenario; -extern GWorldPtr spec_scen_g,mixed_gworld, pc_stats_gworld, item_stats_gworld, text_area_gworld,tiny_obj_gworld,party_template_gworld; +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 short terrain_there[9][9]; // game globals @@ -221,7 +221,7 @@ void put_pc_screen() to_draw_rect.right = pc_buttons[i][4].right + 1; from_rect = info_from; from_rect.right = from_rect.left + to_draw_rect.right - to_draw_rect.left; - rect_draw_some_item(mixed_gworld,from_rect,pc_stats_gworld,to_draw_rect,1,0); + rect_draw_some_item(invenbtn_gworld,from_rect,pc_stats_gworld,to_draw_rect,1,0); } else { for (j = 0; j < 5; j++) @@ -418,7 +418,7 @@ void put_item_screen(short screen_num,short suppress_buttons) void place_buy_button(short position,short pc_num,short item_num) { Rect dest_rect,source_rect; - Rect button_sources[3] = {{24,0,36,30},{24,30,36,60},{36,0,48,30}}; + Rect button_sources[3] = {{24,0,36,30},{36,0,48,30},{48,0,60,30}}; short val_to_place; char store_str[60]; short aug_cost[10] = {4,7,10,8, 15,15,10, 0,0,0}; @@ -483,8 +483,7 @@ void place_buy_button(short position,short pc_num,short item_num) store_selling_values[position] = val_to_place; dest_rect = item_buttons[position][5]; dest_rect.right = dest_rect.left + 30; - rect_draw_some_item (mixed_gworld, source_rect, - item_stats_gworld, dest_rect, 1, 0); + rect_draw_some_item (invenbtn_gworld, source_rect, item_stats_gworld, dest_rect, 1, 0); sprintf((char *) store_str," %d",val_to_place); if (val_to_place >= 10000) TextFace(0); @@ -512,17 +511,14 @@ void place_item_button(short which_button_to_put,short which_slot,short which_bu InsetRect(&from_rect,2,2); if (extra_val >= 150) { from_rect = get_custom_rect(extra_val - 150); - rect_draw_some_item (spec_scen_g, from_rect, - item_stats_gworld, to_rect, 1, 0); + rect_draw_some_item (spec_scen_g, from_rect, item_stats_gworld, to_rect, 1, 0); } - else rect_draw_some_item (tiny_obj_gworld, from_rect, - item_stats_gworld, to_rect, 1, 0); + else rect_draw_some_item (tiny_obj_gworld, from_rect, item_stats_gworld, to_rect, 1, 0); return; } if (which_button_to_put < 4) { // this means put a regular item button item_area_button_active[which_slot][which_button_position] = true; - rect_draw_some_item (mixed_gworld, item_buttons_from[which_button_to_put], - item_stats_gworld, item_buttons[which_slot][which_button_position], 1, 0); + rect_draw_some_item (invenbtn_gworld, item_buttons_from[which_button_to_put], item_stats_gworld, item_buttons[which_slot][which_button_position], 1, 0); } if (which_button_to_put == 10) { // this means put all 4 item_area_button_active[which_slot][1] = true; @@ -532,8 +528,7 @@ void place_item_button(short which_button_to_put,short which_slot,short which_bu from_rect = item_buttons_from[0]; from_rect.right = item_buttons_from[3].right; to_rect = item_buttons[which_slot][1]; to_rect.right = to_rect.left + from_rect.right - from_rect.left; - rect_draw_some_item (mixed_gworld, from_rect, - item_stats_gworld, to_rect, 1, 0); + rect_draw_some_item (invenbtn_gworld, from_rect, item_stats_gworld, to_rect, 1, 0); } if (which_button_to_put == 11) { // this means put right 3 item_area_button_active[which_slot][2] = true; @@ -542,8 +537,7 @@ void place_item_button(short which_button_to_put,short which_slot,short which_bu from_rect = item_buttons_from[1]; from_rect.right = item_buttons_from[3].right; to_rect = item_buttons[which_slot][2]; to_rect.right = to_rect.left + from_rect.right - from_rect.left; - rect_draw_some_item (mixed_gworld, from_rect, - item_stats_gworld, to_rect, 1, 0); + rect_draw_some_item (invenbtn_gworld, from_rect, item_stats_gworld, to_rect, 1, 0); } } //Rect get_custom_rect (short which_rect) //// @@ -555,20 +549,27 @@ void place_item_button(short which_button_to_put,short which_slot,short which_bu //} void place_item_bottom_buttons() { - Rect pc_from_rect = {0,0,36,28},but_from_rect = {85,36,101,54},to_rect; + Rect pc_from_rect = {0,0,36,28},but_from_rect = {60,30,78,46},to_rect; + Rect spec_from_rect = {0,30,15,65}, job_from_rect = {15,30,15,65}, help_from_rect = {78,30,91,44}; short i; for (i = 0; i < 6; i++) { if (univ.party[i].main_status == 1) { item_bottom_button_active[i] = true; to_rect = item_screen_button_rects[i]; - rect_draw_some_item (mixed_gworld, but_from_rect, item_stats_gworld, to_rect, 0, 0); + rect_draw_some_item (invenbtn_gworld, but_from_rect, item_stats_gworld, to_rect, 1, 0); pc_from_rect = get_party_template_rect(i,0); InsetRect(&to_rect,2,2); - rect_draw_some_item (party_template_gworld, pc_from_rect, item_stats_gworld, to_rect, 0, 0); + rect_draw_some_item (party_template_gworld, pc_from_rect, item_stats_gworld, to_rect, 1, 0); } else item_bottom_button_active[i] = false; - } + } + to_rect = item_screen_button_rects[6]; + rect_draw_some_item(invenbtn_gworld, spec_from_rect, item_stats_gworld, to_rect, 1, 0); + to_rect = item_screen_button_rects[7]; + rect_draw_some_item(invenbtn_gworld, job_from_rect, item_stats_gworld, to_rect, 1, 0); + to_rect = item_screen_button_rects[8]; + rect_draw_some_item(invenbtn_gworld, help_from_rect, item_stats_gworld, to_rect, 1, 0); } Rect get_party_template_rect(short pc_num,short mode) @@ -685,12 +686,14 @@ short total_encumberance(short pc_num) void draw_pc_effects(short pc) //short pc; // 10 + x -> draw for pc x, but on spell dialog { - Rect source_rects[18] = {{55,0,67,12},{55,12,67,24},{55,24,67,36}, - {67,0,79,12},{67,12,79,24},{67,24,79,36}, - {79,0,91,12},{79,12,91,24},{79,24,91,36}, - {91,0,103,12},{91,12,103,24},{91,24,103,36}, - {103,0,115,12},{103,12,115,24},{103,24,115,36}, - {115,0,127,12},{115,12,127,24},{115,24,127,36}}; + Rect source_rects[18] = { + {00,0,12,12},{00,12,12,24},{00,24,12,36}, + {12,0,24,12},{12,12,24,24},{12,24,24,36}, + {24,0,36,12},{24,12,36,24},{24,24,36,36}, + {36,0,47,12},{36,12,47,24},{36,24,47,36}, + {47,0,60,12},{47,12,60,24},{47,24,60,36}, + {60,0,72,12},{60,12,72,24},{60,24,72,36} + }; Rect dest_rect = {18,15,30,27},dlog_dest_rect = {66,354,78,366}; short right_limit = 250; short dest = 0; // 0 - in gworld 2 - on dialog @@ -722,83 +725,87 @@ void draw_pc_effects(short pc) if (univ.party[pc].main_status % 10 != 1) return; - if ((univ.party[pc].status[0] > 0) && (dest_rect.right < right_limit)) { - rect_draw_some_item (mixed_gworld,source_rects[4],pc_stats_gworld,dest_rect,1,dest); + if ((univ.party[pc].status[STATUS_POISONED_WEAPON] > 0) && (dest_rect.right < right_limit)) { + rect_draw_some_item (status_gworld,source_rects[4],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if (univ.party[pc].status[1] > 0) { - rect_draw_some_item (mixed_gworld,source_rects[2],pc_stats_gworld,dest_rect,1,dest); + if (univ.party[pc].status[STATUS_BLESS_CURSE] > 0) { + rect_draw_some_item (status_gworld,source_rects[2],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if (univ.party[pc].status[1] < 0) { - rect_draw_some_item (mixed_gworld,source_rects[3],pc_stats_gworld,dest_rect,1,dest); + else if (univ.party[pc].status[STATUS_BLESS_CURSE] < 0) { + rect_draw_some_item (status_gworld,source_rects[3],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if (univ.party[pc].status[2] > 0) { - rect_draw_some_item (mixed_gworld,source_rects[(univ.party[pc].status[2] > 4) ? 1 : 0],pc_stats_gworld,dest_rect,1,dest); + if (univ.party[pc].status[STATUS_POISON] > 0) { + rect_draw_some_item (status_gworld,source_rects[(univ.party[pc].status[STATUS_POISON] > 4) ? 1 : 0],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if (univ.party[pc].status[4] > 0) { - rect_draw_some_item (mixed_gworld,source_rects[5],pc_stats_gworld,dest_rect,1,dest); + if (univ.party[pc].status[STATUS_INVULNERABLE] > 0) { + rect_draw_some_item (status_gworld,source_rects[5],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if (univ.party[pc].status[3] > 0) { - rect_draw_some_item (mixed_gworld,source_rects[6],pc_stats_gworld,dest_rect,1,dest); + if (univ.party[pc].status[STATUS_HASTE_SLOW] > 0) { + rect_draw_some_item (status_gworld,source_rects[6],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if (univ.party[pc].status[3] < 0) { - rect_draw_some_item (mixed_gworld,source_rects[8],pc_stats_gworld,dest_rect,1,dest); + else if (univ.party[pc].status[STATUS_HASTE_SLOW] < 0) { + rect_draw_some_item (status_gworld,source_rects[8],pc_stats_gworld,dest_rect,1,dest); + dest_rect.left += 13; + dest_rect.right += 13; + }else{ + rect_draw_some_item (status_gworld,source_rects[7],pc_stats_gworld,dest_rect,1,dest); + dest_rect.left += 13; + dest_rect.right += 13; + } + if ((univ.party[pc].status[STATUS_MAGIC_RESISTANCE] > 0) && (dest_rect.right < right_limit)) { + rect_draw_some_item (status_gworld,source_rects[9],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if ((univ.party[pc].status[5] > 0) && (dest_rect.right < right_limit)) { - rect_draw_some_item (mixed_gworld,source_rects[9],pc_stats_gworld,dest_rect,1,dest); + if ((univ.party[pc].status[STATUS_WEBS] > 0) && (dest_rect.right < right_limit)) { + rect_draw_some_item (status_gworld,source_rects[10],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if ((univ.party[pc].status[6] > 0) && (dest_rect.right < right_limit)) { - rect_draw_some_item (mixed_gworld,source_rects[10],pc_stats_gworld,dest_rect,1,dest); + if ((univ.party[pc].status[STATUS_DISEASE] > 0) && (dest_rect.right < right_limit)){ + rect_draw_some_item (status_gworld,source_rects[11],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if ((univ.party[pc].status[7] > 0) && (dest_rect.right < right_limit)){ - rect_draw_some_item (mixed_gworld,source_rects[11],pc_stats_gworld,dest_rect,1,dest); + if ((univ.party[pc].status[STATUS_INVISIBLE] > 0) && (dest_rect.right < right_limit)){ + rect_draw_some_item (status_gworld,source_rects[12],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if ((univ.party[pc].status[8] > 0) && (dest_rect.right < right_limit)){ - rect_draw_some_item (mixed_gworld,source_rects[12],pc_stats_gworld,dest_rect,1,dest); - dest_rect.left += 13; - dest_rect.right += 13; - } - if ((univ.party[pc].status[9] > 0) && (dest_rect.right < right_limit)){ - rect_draw_some_item (mixed_gworld,source_rects[13],pc_stats_gworld,dest_rect,1,dest); + if ((univ.party[pc].status[STATUS_DUMB] > 0) && (dest_rect.right < right_limit)){ + rect_draw_some_item (status_gworld,source_rects[13],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if ((univ.party[pc].status[10] > 0) && (dest_rect.right < right_limit)){ - rect_draw_some_item (mixed_gworld,source_rects[14],pc_stats_gworld,dest_rect,1,dest); + if ((univ.party[pc].status[STATUS_MARTYRS_SHIELD] > 0) && (dest_rect.right < right_limit)){ + rect_draw_some_item (status_gworld,source_rects[14],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if ((univ.party[pc].status[11] > 0) && (dest_rect.right < right_limit)){ - rect_draw_some_item (mixed_gworld,source_rects[15],pc_stats_gworld,dest_rect,1,dest); + if ((univ.party[pc].status[STATUS_ASLEEP] > 0) && (dest_rect.right < right_limit)){ + rect_draw_some_item (status_gworld,source_rects[15],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if ((univ.party[pc].status[12] > 0) && (dest_rect.right < right_limit)){ - rect_draw_some_item (mixed_gworld,source_rects[16],pc_stats_gworld,dest_rect,1,dest); + if ((univ.party[pc].status[STATUS_PARALYZED] > 0) && (dest_rect.right < right_limit)){ + rect_draw_some_item (status_gworld,source_rects[16],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } - if ((univ.party[pc].status[13] > 0) && (dest_rect.right < right_limit)){ - rect_draw_some_item (mixed_gworld,source_rects[17],pc_stats_gworld,dest_rect,1,dest); + if ((univ.party[pc].status[STATUS_ACID] > 0) && (dest_rect.right < right_limit)){ + rect_draw_some_item (status_gworld,source_rects[17],pc_stats_gworld,dest_rect,1,dest); dest_rect.left += 13; dest_rect.right += 13; } diff --git a/osx/boe.town.cpp b/osx/boe.town.cpp index f80eb32a..bbc39f7b 100644 --- a/osx/boe.town.cpp +++ b/osx/boe.town.cpp @@ -1,4 +1,4 @@ -#include +#include //#include "item.h" @@ -76,7 +76,7 @@ extern cUniverse univ; //extern piles_of_stuff_dumping_type *data_store; extern GWorldPtr spec_scen_g; bool need_map_full_refresh = true,forcing_map_button_redraw = false; -extern GWorldPtr map_gworld,tiny_map_graphics; +extern GWorldPtr map_gworld,small_ter_gworld; RGBColor parchment = {65535,65535,52428}; PixPatHandle map_pat[25]; @@ -1641,7 +1641,7 @@ pascal void draw_map (DialogPtr the_dialog, short the_item) 6 * (terrain_pic[what_ter] % 10),6 * (terrain_pic[what_ter] / 10)); else OffsetRect(&ter_temp_from, 24 * ((terrain_pic[what_ter] - 400) / 5),6 * ((terrain_pic[what_ter] - 400) % 5) + 156); - rect_draw_some_item(tiny_map_graphics,ter_temp_from, + rect_draw_some_item(small_ter_gworld,ter_temp_from, map_gworld,draw_rect,0,0); break; @@ -1670,7 +1670,7 @@ pascal void draw_map (DialogPtr the_dialog, short the_item) //OffsetRect(&ter_temp_from, // 24 * ((map_pats[pic] - 30) / 5), // 138 + 6 * ((map_pats[pic] - 30) % 5)); - //rect_draw_some_item(tiny_map_graphics,ter_temp_from, + //rect_draw_some_item(small_ter_gworld,ter_temp_from, // map_gworld,draw_rect,0,0); break; } diff --git a/osx/classes/outdoors.cpp b/osx/classes/outdoors.cpp index eb80322d..db891f10 100644 --- a/osx/classes/outdoors.cpp +++ b/osx/classes/outdoors.cpp @@ -109,7 +109,6 @@ cOutdoors::cOutdoors(){ } -__attribute__((deprecated)) char(& cOutdoors::out_strs(short i))[256]{ if(i == 0) return out_name; if(i >= 1 && i < 9) return rect_names[i - 1]; diff --git a/osx/classes/outdoors.h b/osx/classes/outdoors.h index 5aa1b276..3eb7adac 100644 --- a/osx/classes/outdoors.h +++ b/osx/classes/outdoors.h @@ -58,7 +58,7 @@ public: char comment[256]; char spec_strs[90][256]; char sign_strs[8][256]; - char(& out_strs(short i))[256]; + char(& out_strs(short i))[256] __attribute__((deprecated)); bool special_spot[48][48]; cOutdoors(); diff --git a/osx/classes/scenario.cpp b/osx/classes/scenario.cpp index 631fecd9..e9678585 100644 --- a/osx/classes/scenario.cpp +++ b/osx/classes/scenario.cpp @@ -113,7 +113,6 @@ void cScenario::append(legacy::scen_item_data_type& old){ ter_types[i].name = old.ter_names[i]; } -__attribute__((deprecated)) char(& cScenario::scen_strs(short i))[256]{ if(i == 0) return scen_name; if(i == 1) return who_wrote[0]; diff --git a/osx/classes/scenario.h b/osx/classes/scenario.h index 3523f9b7..b8ce151d 100644 --- a/osx/classes/scenario.h +++ b/osx/classes/scenario.h @@ -92,7 +92,7 @@ public: cOutdoors* outdoors; cTown* towns; - char(& scen_strs(short i))[256]; + char(& scen_strs(short i))[256] __attribute__((deprecated)); cScenario& operator = (legacy::scenario_data_type& old); void append(legacy::scen_item_data_type& old); void writeTo(std::ostream& file); diff --git a/osx/classes/terrain.cpp b/osx/classes/terrain.cpp index 757b39fa..f420b2a5 100644 --- a/osx/classes/terrain.cpp +++ b/osx/classes/terrain.cpp @@ -34,10 +34,10 @@ cTerrain& cTerrain::operator = (legacy::terrain_type_type& old){ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 13 - stalagmites 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 14 - cave fumarole (proposed) 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,/* 150 */ // 15 - surface fumarole (proposed) - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 101 - cave road (proposed) - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 102 - surface road (proposed) - 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, // 103 - hills road (proposed) - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, // 104 - crops (proposed) + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 16 - cave road (proposed) + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 17 - surface road (proposed) + 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, // 18 - hills road (proposed) + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, // 19 - crops (proposed) 0, 0, 1, 0, 2, 0, 0, 1, 1, 1,/* 200 */ // (note: fumaroles would have lava.) 1, 0, 2, 1, 1, 0, 1, 1, 1, 1, // the numbers in this array are indices into the other arrays 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, // (ter_base, ground_type, and terrain_odds first index) @@ -105,7 +105,7 @@ cTerrain& cTerrain::operator = (legacy::terrain_type_type& old){ ground_type = ground[picture - 140]; trim_type = (eTrimType) trims[picture - 140]; trim_ter = trim_ters[picture - 140]; - }else{ // TODO: Implement new-style road and walkway handling, and deprecate picture 216. + }else{ ground_type = 255; trim_type = TRIM_NONE; trim_ter = 0; @@ -253,6 +253,7 @@ cTerrain& cTerrain::operator = (legacy::terrain_type_type& old){ else block_horse = old.block_horse; light_radius = old.light_radius; step_sound = old.step_sound; + if(step_sound > 99) step_sound = 99; shortcut_key = old.shortcut_key; switch(picture){ // Rubbles, plus pentagram as a bonus @@ -349,3 +350,16 @@ cTerrain& cTerrain::operator = (legacy::terrain_type_type& old){ }; return *this; } + +std::ostream& operator << (std::ostream& out, eTerSpec& e){ + return out << (int) e; +} + +std::istream& operator >> (std::istream& in, eTerSpec& e){ + int i; + in >> i; + if(i > 0 && i < 24) + e = (eTerSpec) i; + else e = TER_SPEC_NONE; + return in; +} diff --git a/osx/classes/terrain.h b/osx/classes/terrain.h index d1b2861b..689a9973 100644 --- a/osx/classes/terrain.h +++ b/osx/classes/terrain.h @@ -11,6 +11,7 @@ #include #include +#include "graphtool.h" // for pic_num_t namespace legacy { struct terrain_type_type; }; @@ -20,7 +21,7 @@ union ter_flag_t {signed short s; unsigned short u;}; class cTerrain { public: std::string name; - short picture; + pic_num_t picture; unsigned char blockage; ter_flag_t flag1; ter_flag_t flag2; @@ -40,10 +41,14 @@ public: unsigned short combat_arena; location obj_pos; // editor use only location obj_size; // editor use only + pic_num_t map_pic; unsigned short i; // for temporary use in porting cTerrain& operator = (legacy::terrain_type_type& old); void writeTo(std::ostream& file); }; +std::ostream& operator << (std::ostream& out, eTerSpec& e); +std::istream& operator >> (std::istream& in, eTerSpec& e); + #endif \ No newline at end of file diff --git a/osx/classes/town.cpp b/osx/classes/town.cpp index 59be5d47..414b04c1 100644 --- a/osx/classes/town.cpp +++ b/osx/classes/town.cpp @@ -147,7 +147,6 @@ cTown::cTown(short size){ difficulty = 0; } -__attribute__((deprecated)) char(& cTown::town_strs(short i))[256]{ if(i == 0) return town_name; if(i >= 1 && i < 17 ) return rect_names[i - 1]; diff --git a/osx/classes/town.h b/osx/classes/town.h index f1928eef..e241b74a 100644 --- a/osx/classes/town.h +++ b/osx/classes/town.h @@ -88,7 +88,7 @@ public: char comment[3][256]; char spec_strs[100][256]; char sign_strs[20][256]; - char(& town_strs(short i))[256]; + char(& town_strs(short i))[256] __attribute__((deprecated)); cSpeech talking; virtual ~cTown(){} diff --git a/osx/dialogxml/1str-lg.xml b/osx/dialogxml/1str-lg.xml new file mode 100644 index 00000000..e0e76e7d --- /dev/null +++ b/osx/dialogxml/1str-lg.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/osx/dialogxml/1str-title-lg.xml b/osx/dialogxml/1str-title-lg.xml new file mode 100644 index 00000000..1873d22a --- /dev/null +++ b/osx/dialogxml/1str-title-lg.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/osx/dialogxml/1str-title.xml b/osx/dialogxml/1str-title.xml new file mode 100644 index 00000000..8a2e35ea --- /dev/null +++ b/osx/dialogxml/1str-title.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/osx/dialogxml/1str.xml b/osx/dialogxml/1str.xml new file mode 100644 index 00000000..e17f03ef --- /dev/null +++ b/osx/dialogxml/1str.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/osx/dialogxml/2str-lg.xml b/osx/dialogxml/2str-lg.xml new file mode 100644 index 00000000..23ec4507 --- /dev/null +++ b/osx/dialogxml/2str-lg.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/osx/dialogxml/2str-title-lg.xml b/osx/dialogxml/2str-title-lg.xml new file mode 100644 index 00000000..4da7def4 --- /dev/null +++ b/osx/dialogxml/2str-title-lg.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/osx/dialogxml/2str-title.xml b/osx/dialogxml/2str-title.xml new file mode 100644 index 00000000..11d3ee29 --- /dev/null +++ b/osx/dialogxml/2str-title.xml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/osx/dialogxml/2str.xml b/osx/dialogxml/2str.xml new file mode 100644 index 00000000..1426d8eb --- /dev/null +++ b/osx/dialogxml/2str.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/osx/dialogxml/button.cpp b/osx/dialogxml/button.cpp index cad8d91d..955fdef3 100644 --- a/osx/dialogxml/button.cpp +++ b/osx/dialogxml/button.cpp @@ -101,8 +101,17 @@ GWorldPtr cButton::buttons[7] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL}; Rect cButton::btnRects[13][2]; void cButton::init(){ + static const char*const buttonFiles[7] = { + "dlogbtnsm.png", + "dlogbtnmed.png", + "dlogbtnlg.png", + "dlogbtntall.png", + "dlogbtnhelp.png", + "dlogbtnled.png", + "dlogbtnred.png" + }; for(int i = 0; i < 7; i++) - buttons[i] = load_pict(i + 2030); + buttons[i] = load_pict(buttonFiles[i]); SetRect(&btnRects[BTN_SM][0],0,0,23,23); SetRect(&btnRects[BTN_REG][0],0,0,63,23); SetRect(&btnRects[BTN_LEFT][0],0,23,63,46); @@ -267,7 +276,9 @@ bool cLedGroup::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, P iter++; } - if(choices[which_clicked]->triggerClickHandler(me,curSelect,mods,where)){ + if(which_clicked == "") return false; + + if(choices[which_clicked]->triggerClickHandler(me,which_clicked,mods,where)){ eLedState a, b; a = choices[curSelect]->getState(); b = choices[which_clicked]->getState(); @@ -278,7 +289,7 @@ bool cLedGroup::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, P choices[which_clicked]->setState(b); return false; } - if(!choices[which_clicked]->triggerFocusHandler(me,curSelect,false)){ + if(!choices[which_clicked]->triggerFocusHandler(me,which_clicked,false)){ choices[curSelect]->setState(a); choices[which_clicked]->setState(b); return false; @@ -328,7 +339,17 @@ cLed& cLedGroup::operator[](std::string id){ return *(iter->second); } -void cLedGroup::setSelection(std::string id){ +void cLedGroup::setSelected(std::string id){ + if(id == "") { // deselect all + eLedState was = choices[curSelect]->getState(); + choices[curSelect]->setState(led_off); + if(choices[curSelect]->triggerFocusHandler(*parent,curSelect,true)) + curSelect = ""; + else + choices[curSelect]->setState(was); + return; + } + ledIter iter = choices.find(id); if(iter == choices.end()) throw std::invalid_argument(id + " does not exist in the ledgroup."); @@ -350,7 +371,7 @@ void cLedGroup::setSelection(std::string id){ curSelect = iter->first; } -std::string cLedGroup::getSelection(){ +std::string cLedGroup::getSelected(){ return curSelect; } @@ -365,3 +386,12 @@ void cLedGroup::draw(){ iter++; } } + +void cButton::setType(eBtnType newType){ + if(type == BTN_LED) return; // can't change type + type = newType; +} + +eBtnType cButton::getType(){ + return type; +} diff --git a/osx/dialogxml/button.h b/osx/dialogxml/button.h index 4c59b642..9f1ced21 100644 --- a/osx/dialogxml/button.h +++ b/osx/dialogxml/button.h @@ -43,14 +43,16 @@ public: void setFormat(eFormat prop, short val) throw(xUnsupportedProp); short getFormat(eFormat prop) throw(xUnsupportedProp); explicit cButton(cDialog* parent); - cButton(cDialog* parent,eControlType t); bool isClickable(); + void setType(eBtnType newType); + eBtnType getType(); virtual ~cButton(); protected: //friend class cDialog; void draw(); eBtnType type; click_callback_t onClick; + cButton(cDialog* parent,eControlType t); private: friend class cDialog; bool wrapLabel; @@ -101,8 +103,6 @@ public: void attachFocusHandler(focus_callback_t f) throw(); // activated only when the selection changes bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where); bool triggerFocusHandler(cDialog& me, std::string id, bool losingFocus); - void setSelected(std::string id); - std::string getSelected(); void disable(std::string id); void enable(std::string id); using cControl::show; @@ -115,8 +115,8 @@ public: bool isClickable(); virtual ~cLedGroup(); cLed& operator[](std::string id); - void setSelection(std::string id); - std::string getSelection(); + void setSelected(std::string id); + std::string getSelected(); std::string getPrevSelection(); // The id of the element that was last selected before the selection changed to the current selection. typedef std::map::iterator ledIter; protected: diff --git a/osx/dialogxml/choose-pict.xml b/osx/dialogxml/choose-pict.xml new file mode 100644 index 00000000..18f9b184 --- /dev/null +++ b/osx/dialogxml/choose-pict.xml @@ -0,0 +1,86 @@ + + + + + + Select a graphic: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Click button to left of graphic to select. Use arrows to change pages. + + \ No newline at end of file diff --git a/osx/dialogxml/choose-string.xml b/osx/dialogxml/choose-string.xml new file mode 100644 index 00000000..925364e9 --- /dev/null +++ b/osx/dialogxml/choose-string.xml @@ -0,0 +1,53 @@ + + + + + + Select: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/osx/dialogxml/control.cpp b/osx/dialogxml/control.cpp index 0213c029..af9a3dd9 100644 --- a/osx/dialogxml/control.cpp +++ b/osx/dialogxml/control.cpp @@ -303,3 +303,21 @@ cControl::~cControl() {} eControlType cControl::getType(){ return type; } + +void cControl::setTextToNum(long what){ + std::ostringstream sout; + sout << what; + setText(sout.str()); +} + +long cControl::getTextAsNum(){ + std::istringstream sin(getText()); + long n; + sin >> n; + return n; +} + +bool cControl::hasKey(){ + if(key.spec) return true; + return key.c != 0; +} diff --git a/osx/dialogxml/control.h b/osx/dialogxml/control.h index 9748b30f..03068522 100644 --- a/osx/dialogxml/control.h +++ b/osx/dialogxml/control.h @@ -11,6 +11,7 @@ #include #include +#include //struct cPict { // short pict; @@ -67,8 +68,10 @@ enum eControlType { enum eTextFont {DUNGEON, GENEVA, SILOM, MAIDENWORD}; class cDialog; -typedef bool (*click_callback_t)(cDialog&/*me*/,std::string/*id*/, eKeyMod/*mods*/); -typedef bool (*focus_callback_t)(cDialog&/*me*/,std::string/*id*/,bool/*losing*/); // losing is true if losing focus, false if gaining focus. +//typedef bool (*click_callback_t)(cDialog&/*me*/,std::string/*id*/, eKeyMod/*mods*/); +//typedef bool (*focus_callback_t)(cDialog&/*me*/,std::string/*id*/,bool/*losing*/); // losing is true if losing focus, false if gaining focus. +typedef boost::function click_callback_t; +typedef boost::function focus_callback_t; class xHandlerNotSupported : std::exception { static const char* focusMsg; @@ -94,6 +97,7 @@ public: void attachKey(cKey key); void detachKey(); void setTextToKey(); + bool hasKey(); virtual void attachClickHandler(click_callback_t f) throw(xHandlerNotSupported) = 0; virtual void attachFocusHandler(focus_callback_t f) throw(xHandlerNotSupported) = 0; virtual bool triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, Point where); @@ -105,6 +109,8 @@ public: eControlType getType(); virtual void setText(std::string l); virtual std::string getText(); + long getTextAsNum(); + void setTextToNum(long what); virtual void setFormat(eFormat prop, short val) throw(xUnsupportedProp) = 0; virtual short getFormat(eFormat prop) throw(xUnsupportedProp) = 0; virtual bool isClickable() = 0; diff --git a/osx/dialogxml/dialog.cpp b/osx/dialogxml/dialog.cpp index c6137a04..08bf2019 100644 --- a/osx/dialogxml/dialog.cpp +++ b/osx/dialogxml/dialog.cpp @@ -9,16 +9,30 @@ #define MOUSE_REGION 0L #define IN_FRONT (WindowPtr)-1L +#include +#include +#include #include "dialog.h" #include "graphtool.h" #include "soundtool.h" -#include using namespace std; using namespace ticpp; extern bool play_sounds; const short cDialog::BG_DARK = 5, cDialog::BG_LIGHT = 16; +static std::string generateRandomString(){ + // Not bothering to seed, because it doesn't actually matter if it's truly random. + // Though, this will be called after srand() is called in main() anyway. + int n_chars = rand() % 100; + std::string s; + while(n_chars > 0){ + s += char(rand() % 223 + 32); + n_chars--; + } + return s; +} + template<> pair cDialog::parse(Element& who /*pict*/){ pair p; Iterator attr; @@ -124,6 +138,11 @@ template<> pair cDialog::parse(Element& who /*pict*/){ break; } if(custom) p.second->picType += PIC_CUSTOM; + if(p.first == ""){ + do{ + p.first = generateRandomString(); + }while(controls.find(p.first) == controls.end()); + } return p; } @@ -198,6 +217,11 @@ template<> pair cDialog::parse(Element& who /*text*/){ } } p.second->lbl = content; + if(p.first == ""){ + do{ + p.first = generateRandomString(); + }while(controls.find(p.first) == controls.end()); + } return p; } @@ -363,6 +387,11 @@ template<> pair cDialog::parse(Element& who /*button*/){ } } p.second->lbl = content; + if(p.first == ""){ + do{ + p.first = generateRandomString(); + }while(controls.find(p.first) == controls.end()); + } return p; } @@ -428,6 +457,7 @@ template<> pair cDialog::parse(Element& who /*LED*/){ string name, val; int width = 0, height = 0; p.second = new cLed(this); + p.second->type = BTN_LED; for(attr = attr.begin(&who); attr != attr.end(); attr++){ attr->GetName(&name); attr->GetValue(&val); @@ -497,6 +527,11 @@ template<> pair cDialog::parse(Element& who /*LED*/){ } } p.second->lbl = content; + if(p.first == ""){ + do{ + p.first = generateRandomString(); + }while(controls.find(p.first) == controls.end()); + } return p; } @@ -528,6 +563,11 @@ template<> pair cDialog::parse(Element& who /*group*/){ } } p.second->lbl = content; + if(p.first == ""){ + do{ + p.first = generateRandomString(); + }while(controls.find(p.first) == controls.end()); + } return p; } @@ -565,10 +605,25 @@ template<> pair cDialog::parse(Element& who /*field*/){ } p.second->frame.right = p.second->frame.left + width; p.second->frame.bottom = p.second->frame.top + height; + if(p.first == ""){ + do{ + p.first = generateRandomString(); + }while(controls.find(p.first) == controls.end()); + } return p; } -cDialog::cDialog(string path){ +cDialog::cDialog(cDialog* p) : parent(p) {} + +cDialog::cDialog(std::string path) : parent(NULL){ + loadFromFile(path); +} + +cDialog::cDialog(std::string path, cDialog* p) : parent(p){ + loadFromFile(path); +} + +void cDialog::loadFromFile(std::string path){ try{ Document xml(path); xml.LoadFile(); @@ -626,13 +681,10 @@ cDialog::cDialog(string path){ bg = BG_DARK; // default is dark background // now calculate window rect SetRect(&winRect,0,0,0,0); + recalcRect(); ctrlIter iter = controls.begin(); currentFocus = NULL; while(iter != controls.end()){ - if(iter->second->frame.right > winRect.right) - winRect.right = iter->second->frame.right; - if(iter->second->frame.bottom > winRect.bottom) - winRect.bottom = iter->second->frame.bottom; if(typeid(iter->second) == typeid(cTextField*)){ cTextField* fld = (cTextField*) iter->second; if(currentFocus == NULL) currentFocus = fld; @@ -640,9 +692,21 @@ cDialog::cDialog(string path){ } iter++; } - winRect.right += 4; - winRect.bottom += 4; win = NewCWindow(NULL, &winRect, (unsigned char*) "", false, dBoxProc, IN_FRONT, false, 0); + // TODO: Set parent +} + +void cDialog::recalcRect(){ + ctrlIter iter = controls.begin(); + while(iter != controls.end()){ + if(iter->second->frame.right > winRect.right) + winRect.right = iter->second->frame.right; + if(iter->second->frame.bottom > winRect.bottom) + winRect.bottom = iter->second->frame.bottom; + iter++; + } + winRect.right += 6; + winRect.bottom += 6; } cDialog::_init::_init(){ @@ -665,10 +729,11 @@ cDialog::~cDialog(){ DisposeWindow(win); } -bool cDialog::add(cControl* what, std::string key){ +bool cDialog::add(cControl* what, Rect ctrl_frame, std::string key){ // First make sure the key is not already present. // If it is, we can't add the control, so return false. if(controls.find(key) != controls.end()) return false; + what->frame = ctrl_frame; controls.insert(std::make_pair(key,what)); return true; } @@ -806,8 +871,9 @@ void cDialog::setDefTextClr(RGBColor clr){ defTextClr = clr; } -void cDialog::toast(){ +bool cDialog::toast(){ dialogNotToast = false; + return true; } std::string cDialog::process_keystroke(cKey keyHit){ diff --git a/osx/dialogxml/dialog.css b/osx/dialogxml/dialog.css index 6d82b131..43c030ad 100644 --- a/osx/dialogxml/dialog.css +++ b/osx/dialogxml/dialog.css @@ -59,6 +59,16 @@ title { height: 72px; } +.pict.status { + width: 12px; + height: 12px; +} + +.pict.map { + width: 24px; + height: 24px; +} + .button , .led { padding: 0px; background-repeat: no-repeat; diff --git a/osx/dialogxml/dialog.dtd b/osx/dialogxml/dialog.dtd index dde7cabb..544c4b71 100644 --- a/osx/dialogxml/dialog.dtd +++ b/osx/dialogxml/dialog.dtd @@ -10,7 +10,7 @@ - + type getResult(); // This seems like an unimplementable function + template type& getResult(); + template void setResult(const type& val); void setBg(short n); void setDefTextClr(RGBColor clr); - void toast(); + bool toast(); cControl& operator[](std::string id); + void recalcRect(); private: void draw(); std::string process_keystroke(cKey keyHit); std::string process_click(Point where, eKeyMod mods); bool dialogNotToast; Rect winRect; + unsigned long long result; friend class cControl; friend class cButton; friend class cLed; @@ -91,4 +97,7 @@ public: ~xBadVal() throw(); const char* what() throw(); }; + +#include "dialog.results.h" // public template definitions + #endif diff --git a/osx/dialogxml/dialog.results.h b/osx/dialogxml/dialog.results.h new file mode 100644 index 00000000..fa0804f4 --- /dev/null +++ b/osx/dialogxml/dialog.results.h @@ -0,0 +1,119 @@ +/* + * dialog.results.h + * BoE + * + * Created by Celtic Minstrel on 06/06/09. + * + */ + +// Functions for allowing the dialog to have a result which can be of any type. +// Be sure to call setResult and getResult with the exact same template parameters! +// If you don't, bad things could happen. (Especially if you get the result as +// a pointer when it was set as an integral type.) +// Note however that for non-integral types it's safe to set it as type pointer to X and then +// get it as type X or vice versa, since setting it as type X stores the address anyway. + +template inline void cDialog::setResult(const type& val){ + const type* ptr = &val; + result = reinterpret_cast(ptr); +} + +template<> inline void cDialog::setResult(const char& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const signed char& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const unsigned char& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const signed short& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const unsigned short& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const signed int& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const unsigned int& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const signed long& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const unsigned long& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const signed long long& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const unsigned long long& val){ + result = reinterpret_cast(val); +} + +template<> inline void cDialog::setResult(const bool& val){ + result = reinterpret_cast(val); +} + +template inline type& cDialog::getResult(){ + return *reinterpret_cast(result); +} + +template<> inline char& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline signed char& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline unsigned char& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline signed short& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline unsigned short& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline signed int& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline unsigned int& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline signed long& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline unsigned long& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline signed long long& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline unsigned long long& cDialog::getResult(){ + return reinterpret_cast(result); +} + +template<> inline bool& cDialog::getResult(){ + return reinterpret_cast(result); +} \ No newline at end of file diff --git a/osx/dialogxml/dialog.xsl b/osx/dialogxml/dialog.xsl index 0c88a343..468fdd45 100644 --- a/osx/dialogxml/dialog.xsl +++ b/osx/dialogxml/dialog.xsl @@ -72,6 +72,9 @@ background-image: url('bg/.png'); left: px; top: px; width: ; + + + diff --git a/osx/dialogxml/dlogutil.buttons.h b/osx/dialogxml/dlogutil.buttons.h new file mode 100644 index 00000000..20f6fdbb --- /dev/null +++ b/osx/dialogxml/dlogutil.buttons.h @@ -0,0 +1,186 @@ +/* + * dlogutil.buttons.h + * BoE + * + * Created by Celtic Minstrel on 07/06/09. + * + */ + +size_t available_btns[] = { // This array is a list of indices into the following array. + 0, 63, 64, 65, 1, 4, 5, 8, 128,9, + 10, 11, 12, 13, 14, 15, 16, 17, 29, 51, + 60, 61, 62, 66, 69, 70, 71, 72, 73, 74, + 79, 80, 83, 86, 87, 88, 91, 92, 93, 99, + 100,101,102,104,129,130,131,132,133,134, + 135,136,137 +}; + +cBasicButtonType basic_buttons[] = { + {BTN_DONE, " ", {false,0,mod_none}}, // Formerly DLG_BTN_REG with "Done " as the string + {BTN_REG, "Ask", {false,0,mod_none}}, + {BTN_LEFT, " ", {true,key_left,mod_none}}, + {BTN_RIGHT, " ", {true,key_right,mod_none}}, + {BTN_REG, "Keep", {false,'k',mod_none}}, + {BTN_REG, "Cancel", {true,key_esc,mod_none}}, + {BTN_SM, "+", {false,0,mod_none}}, + {BTN_SM, "-", {false,0,mod_none}}, + {BTN_REG, "Buy", {false,0,mod_none}}, + {BTN_REG, "Leave", {false,0,mod_none}}, + //10 + {BTN_REG, "Get", {false,'g',mod_none}}, + {BTN_REG, "1", {false,'1',mod_none}}, + {BTN_REG, "2", {false,'2',mod_none}}, + {BTN_REG, "3", {false,'3',mod_none}}, + {BTN_REG, "4", {false,'4',mod_none}}, + {BTN_REG, "5", {false,'5',mod_none}}, + {BTN_REG, "6", {false,'6',mod_none}}, + {BTN_REG, "Cast", {false,0,mod_none}}, + {BTN_TINY, " ", {false,0,mod_none}}, + {BTN_TINY, " ", {false,0,mod_none}}, + //20 + {BTN_TINY, " ", {false,0,mod_none}}, + {BTN_TINY, " ", {false,0,mod_none}}, + {BTN_TINY, " ", {false,0,mod_none}}, + {BTN_REG, "Buy", {false,0,mod_none}}, + {BTN_REG, "Sell", {false,0,mod_none}}, + {BTN_LG, "Other Spells", {false,' ',mod_none}}, + {BTN_REG, "Buy x10", {false,0,mod_none}}, + {BTN_UP, " ", {true,key_up,mod_none}}, + {BTN_DOWN, " ", {true,key_down,mod_none}}, + {BTN_REG, "Save", {false,0,mod_none}}, + //30 + {BTN_REG, "Race", {false,0,mod_none}}, + {BTN_TALL, "Train", {false,0,mod_none}}, + {BTN_REG, "Items", {false,0,mod_none}}, + {BTN_REG, "Spells", {false,0,mod_none}}, + {BTN_LG, "Heal Party", {false,0,mod_none}}, + {BTN_SM, "1", {false,'1',mod_none}}, + {BTN_SM, "2", {false,'2',mod_none}}, + {BTN_SM, "3", {false,'3',mod_none}}, + {BTN_SM, "4", {false,'4',mod_none}}, + {BTN_SM, "5", {false,'5',mod_none}}, + //40 + {BTN_SM, "6", {false,'6',mod_none}}, + {BTN_SM, "7", {false,'7',mod_none}}, + {BTN_SM, "8", {false,'8',mod_none}}, + {BTN_SM, "9", {false,'9',mod_none}}, + {BTN_SM, "10", {false,'a',mod_none}}, + {BTN_SM, "11", {false,'b',mod_none}}, + {BTN_SM, "12", {false,'c',mod_none}}, + {BTN_SM, "13", {false,'d',mod_none}}, + {BTN_SM, "14", {false,'e',mod_none}}, + {BTN_SM, "15", {false,'f',mod_none}}, + //50 + {BTN_SM, "16", {false,'g',mod_none}}, + {BTN_REG, "Take", {false,0,mod_none}}, + {BTN_REG, "Create", {false,0,mod_none}}, + {BTN_REG, "Delete", {false,0,mod_none}}, + {BTN_LG, "Race/Special", {false,0,mod_none}}, + {BTN_REG, "Skill", {false,0,mod_none}}, + {BTN_REG, "Name", {false,0,mod_none}}, + {BTN_REG, "Graphic", {false,0,mod_none}}, + {BTN_LG, "Bash Door", {false,0,mod_none}}, + {BTN_LG, "Pick Lock", {false,0,mod_none}}, + //60 + {BTN_REG, "Leave", {false,0,mod_none}}, + {BTN_REG, "Steal", {false,0,mod_none}}, + {BTN_REG, "Attack", {false,0,mod_none}}, + {BTN_REG, "OK", {false,0,mod_none}}, + {BTN_REG, "Yes", {false,'y',mod_none}}, + {BTN_REG, "No", {false,'n',mod_none}}, + {BTN_LG, "Step In", {false,0,mod_none}}, + {BTN_HELP, " ", {false,'?',mod_none}}, + {BTN_REG, "Record", {false,'r',mod_none}}, + {BTN_REG, "Climb", {false,0,mod_none}}, + //70 + {BTN_REG, "Flee", {false,0,mod_none}}, + {BTN_REG, "Onward", {false,0,mod_none}}, + {BTN_REG, "Answer", {false,0,mod_none}}, + {BTN_REG, "Drink", {false,0,mod_none}}, + {BTN_LG, "Approach", {false,0,mod_none}}, + {BTN_LG, "Mage Spells", {false,0,mod_none}}, + {BTN_LG, "Priest Spells", {false,0,mod_none}}, + {BTN_LG, "Advantages", {false,0,mod_none}}, + {BTN_LG, "New Game", {false,0,mod_none}}, + {BTN_REG, "Land", {false,0,mod_none}}, + //80 + {BTN_REG, "Under", {false,0,mod_none}}, + {BTN_REG, "Restore", {false,0,mod_none}}, + {BTN_REG, "Restart", {false,0,mod_none}}, + {BTN_REG, "Quit", {false,0,mod_none}}, + {BTN_LG, "Save First", {false,0,mod_none}}, + {BTN_LG, "Just Quit", {false,0,mod_none}}, + {BTN_REG, "Rest", {false,0,mod_none}}, + {BTN_REG, "Read", {false,0,mod_none}}, + {BTN_REG, "Pull", {false,0,mod_none}}, + {BTN_LG, "Alchemy", {false,0,mod_none}}, + //90 + {BTN_SM, "17", {false,'g',mod_none}}, + {BTN_REG, "Push", {false,0,mod_none}}, + {BTN_REG, "Pray", {false,0,mod_none}}, + {BTN_REG, "Wait", {false,0,mod_none}}, + {BTN_PUSH, "", {false,0,mod_none}}, + {BTN_TRAIT, "", {false,0,mod_none}}, + {BTN_TALL, "Delete", {false,0,mod_none}}, + {BTN_TALL, "Graphic", {false,0,mod_none}}, + {BTN_TALL, "Create", {false,0,mod_none}}, + {BTN_REG, "Give", {false,0,mod_none}}, + //100 + {BTN_REG, "Destroy", {false,0,mod_none}}, + {BTN_REG, "Pay", {false,0,mod_none}}, + {BTN_REG, "Free", {false,0,mod_none}}, + {BTN_LG, "Next Tip", {false,0,mod_none}}, + {BTN_REG, "Touch", {false,0,mod_none}}, + {BTN_LG, "Select Icon", {false,0,mod_none}}, + {BTN_LG, "Create/Edit", {false,0,mod_none}}, + {BTN_LG, "Clear Special", {false,0,mod_none}}, + {BTN_LG, "Edit Abilities", {false,0,mod_none}}, + {BTN_REG, "Choose", {false,0,mod_none}}, + //110 + {BTN_LG, "Go Back", {false,0,mod_none}}, + {BTN_LG, "Create New", {false,0,mod_none}}, + {BTN_LG, "General", {false,0,mod_none}}, + {BTN_LG, "One Shots", {false,0,mod_none}}, + {BTN_LG, "Affect PCs", {false,0,mod_none}}, + {BTN_LG, "If-Thens", {false,0,mod_none}}, + {BTN_LG, "Town Specs", {false,0,mod_none}}, + {BTN_LG, "Out Specs", {false,0,mod_none}}, + {BTN_LG, "Advanced", {false,0,mod_none}}, + {BTN_LG, "Weapon Abil", {false,0,mod_none}}, + //120 + {BTN_LG, "General Abil.", {false,0,mod_none}}, + {BTN_LG, "NonSpell Use", {false,0,mod_none}}, + {BTN_LG, "Spell Usable", {false,0,mod_none}}, + {BTN_LG, "Reagents", {false,0,mod_none}}, + {BTN_LG, "Missiles", {false,0,mod_none}}, + {BTN_LG, "Abilities", {false,0,mod_none}}, + {BTN_LG, "Pick Picture", {false,0,mod_none}}, + {BTN_LG, "Animated", {false,0,mod_none}}, + {BTN_REG, "Enter", {false,0,mod_none}}, + {BTN_REG, "Burn", {false,0,mod_none}}, + //130 + {BTN_REG, "Insert", {false,0,mod_none}}, + {BTN_REG, "Remove", {false,0,mod_none}}, + {BTN_REG, "Accept", {false,0,mod_none}}, + {BTN_REG, "Refuse", {false,0,mod_none}}, + {BTN_REG, "Open", {false,0,mod_none}}, + {BTN_REG, "Close", {false,0,mod_none}}, + {BTN_REG, "Sit", {false,0,mod_none}}, + {BTN_REG, "Stand", {false,0,mod_none}}, + {BTN_SM, "", {false,0,mod_none}}, + {BTN_SM, "", {false,0,mod_none}}, + //140 + {BTN_SM, "18", {false,0,mod_none}}, + {BTN_SM, "19", {false,0,mod_none}}, + {BTN_SM, "20", {false,0,mod_none}}, + {BTN_SM, "", {false,0,mod_none}}, // invisible button; text was "Invisible!" + {BTN_SM, "", {false,0,mod_none}}, + {BTN_SM, "", {false,0,mod_none}}, + {BTN_SM, "", {false,0,mod_none}}, + {BTN_SM, "", {false,0,mod_none}}, + {BTN_SM, "", {false,0,mod_none}}, + {BTN_SM, "", {false,0,mod_none}}, + //150 + {BTN_LG, "Open File", {false,0,mod_none}}, + {BTN_SM, " ", {false,0,mod_none}}, +}; \ No newline at end of file diff --git a/osx/dialogxml/dlogutil.cpp b/osx/dialogxml/dlogutil.cpp index b2153d6a..06dd60bb 100644 --- a/osx/dialogxml/dlogutil.cpp +++ b/osx/dialogxml/dlogutil.cpp @@ -5,10 +5,449 @@ * Created by Celtic Minstrel on 11/05/09. * */ +#define BTNS_DEFINED -#include -using namespace std; +#include +#include +#include #include "dialog.h" #include "dlogutil.h" +#include "mathutil.h" +#include "dlogutil.buttons.h" // must be included here and only here + +const size_t cPictChoice::per_page = 36; + +cPictChoice::cPictChoice(std::vector& pics,ePicType t,cDialog* parent) : dlg("choose-pict.xml",parent), type(t) { + dlg["left"].attachClickHandler(boost::bind(&cPictChoice::onLeft,this,_1,_2)); + dlg["right"].attachClickHandler(boost::bind(&cPictChoice::onRight,this,_1,_2)); + dlg["done"].attachClickHandler(boost::bind(&cPictChoice::onOkay,this,_1,_2)); + dlg["cancel"].attachClickHandler(boost::bind(&cPictChoice::onCancel,this,_1,_2)); + picts = pics; + sort(picts.begin(),picts.end()); +} + +cPictChoice::cPictChoice( + std::vector::iterator begin, + std::vector::iterator end, + ePicType t, + cDialog* parent + ) : dlg("choose-pict.xml",parent), type(t) { + dlg["left"].attachClickHandler(boost::bind(&cPictChoice::onLeft,this,_1,_2)); + dlg["right"].attachClickHandler(boost::bind(&cPictChoice::onRight,this,_1,_2)); + dlg["done"].attachClickHandler(boost::bind(&cPictChoice::onOkay,this,_1,_2)); + dlg["cancel"].attachClickHandler(boost::bind(&cPictChoice::onCancel,this,_1,_2)); + copy(begin,end,picts.begin()); + sort(picts.begin(),picts.end()); +} + +pic_num_t cPictChoice::show(pic_num_t fallback, pic_num_t cur_sel){ + dlg.setResult(fallback); + cur = cur_sel; + page = cur / per_page; + fillPage(); + dlg.run(); + return dlg.getResult(); +}// returns the _number_ of the chosen picture, _not_ the index; there's no way to distinguish between duplicates +// returns fallback if the user cancels + +void cPictChoice::fillPage(){ + cLedGroup& group = dynamic_cast(dlg["group"]); + group.setSelected(""); // unselect all LEDs, since the currently selected one may be on another page + for(int i = 0; i < per_page; i++){ + std::ostringstream sout; + sout << "led" << i + 1; + if(page * per_page + i >= picts.size()) + dlg[sout.str()].hide(); + else + dlg[sout.str()].show(); + if(page * per_page + i == cur) + group.setSelected(sout.str()); + sout.str(""); + sout << "pic" << i + 1; + cPict& pic = dynamic_cast(dlg[sout.str()]); + if(page * per_page + i < picts.size()){ + pic.show(); + pic.setPict(picts[per_page * page + i], type); + }else pic.hide(); + } +} + +bool cPictChoice::onLeft(cDialog& m, std::string ide){ + if(page == 0) page = picts.size() / per_page; + else page--; + fillPage(); + return true; +} + +bool cPictChoice::onRight(cDialog& me, std::string id){ + if(page == picts.size() / per_page) page = 0; + else page++; + fillPage(); + return true; +} + +bool cPictChoice::onCancel(cDialog& me, std::string id){ + me.toast(); + return true; +} + +bool cPictChoice::onOkay(cDialog& me, std::string id){ + dlg.setResult(picts[cur]); + me.toast(); + return true; +} + +const size_t cStringChoice::per_page = 40; + +cStringChoice::cStringChoice( + std::vector& strs, + cDialog* parent + ) : dlg("choose-string.xml",parent) { + dlg["left"].attachClickHandler(boost::bind(&cStringChoice::onLeft,this,_1,_2)); + dlg["right"].attachClickHandler(boost::bind(&cStringChoice::onRight,this,_1,_2)); + dlg["done"].attachClickHandler(boost::bind(&cStringChoice::onOkay,this,_1,_2)); + dlg["cancel"].attachClickHandler(boost::bind(&cStringChoice::onCancel,this,_1,_2)); + strings = strs; +} + +cStringChoice::cStringChoice( + std::vector::iterator begin, + std::vector::iterator end, + cDialog* parent + ) : dlg("choose-string.xml",parent) { + dlg["left"].attachClickHandler(boost::bind(&cStringChoice::onLeft,this,_1,_2)); + dlg["right"].attachClickHandler(boost::bind(&cStringChoice::onRight,this,_1,_2)); + dlg["done"].attachClickHandler(boost::bind(&cStringChoice::onOkay,this,_1,_2)); + dlg["cancel"].attachClickHandler(boost::bind(&cStringChoice::onCancel,this,_1,_2)); + copy(begin,end,strings.begin()); +} + +size_t cStringChoice::show(std::string select){ + dlg.setResult(strings.size()); + std::vector::iterator iter = find(strings.begin(),strings.end(),select); + cur = iter - strings.begin(); + page = cur / per_page; + fillPage(); + dlg.run(); + return dlg.getResult(); +}// returns the _index_ of the chosen string, relative to begin if initialized from a range +// returns strs.size() if the user cancels + +void cStringChoice::fillPage(){ + cLedGroup& group = dynamic_cast(dlg["group"]); + group.setSelected(""); // unselect all LEDs, since the currently selected one may be on another page + for(unsigned int i = 0; i < per_page; i++){ + std::ostringstream sout; + sout << "led" << i + 1; + if(page * per_page + i >= strings.size()){ + dlg[sout.str()].hide(); + continue; + }else + dlg[sout.str()].show(); + if(page * per_page + i == cur) + group.setSelected(sout.str()); + if(page * per_page + i < strings.size()){ + dlg[sout.str()].setText(strings[per_page * page + i]); + } + } +} + +bool cStringChoice::onLeft(cDialog& me __attribute__((unused)), std::string id __attribute__((unused))){ + if(page == 0) page = strings.size() / per_page; + else page--; + fillPage(); + return true; +} + +bool cStringChoice::onRight(cDialog& me __attribute__((unused)), std::string id __attribute__((unused))){ + if(page == strings.size() / per_page) page = 0; + else page++; + fillPage(); + return true; +} + +bool cStringChoice::onCancel(cDialog& me, std::string id __attribute__((unused))){ + me.toast(); + return true; +} + +bool cStringChoice::onOkay(cDialog& me, std::string id __attribute__((unused))){ + dlg.setResult(cur); + me.toast(); + return true; +} + +cChoiceDlog::cChoiceDlog(std::string file, std::vector buttons, cDialog* p) : dlg(file, p) { + std::vector::iterator iter = buttons.begin(); + while(iter != buttons.end()){ + dlg[*iter].attachClickHandler(boost::bind(&cChoiceDlog::onClick,this,_1,_2)); + iter++; + } +} + +cChoiceDlog::cChoiceDlog(std::vector buttons, cDialog* p) : dlg(p) { + std::vector::iterator iter = buttons.begin(); + while(iter != buttons.end()){ + dlg[*iter].attachClickHandler(boost::bind(&cChoiceDlog::onClick,this,_1,_2)); + iter++; + } +} + +// so that the caller can set up aspects of the dialog if necessary +cDialog* cChoiceDlog::operator->(){ + return &dlg; +} + +std::string cChoiceDlog::show(){ + dlg.run(); + return dlg.getResult(); +} + +bool cChoiceDlog::onClick(cDialog& me, std::string id){ + me.setResult(id); + me.toast(); + return true; +} + +template bbtt::operator bool(){ + return b; +} + +template bbtt& bbtt::operator=(bbtt&){ + return *this; +} + +cThreeChoice::cThreeChoice + (std::vector strings,short btn1,short btn2,short btn3,pic_num_t pic,ePicType t,cDialog* parent) + : cChoiceDlog(/*cThreeChoice::getFileName(strings.size()),*/ std::vector(), parent), type(t){ + if(type == PIC_CUSTOM_DLOG_LG || type == PIC_DLOG_LG || type == PIC_SCEN_LG) + init_strings(strings,86); + else + init_strings(strings,50); + if(btn1 < 0){ + if(btn2 < 0){ + if(btn3 < 0) + init_buttons(basic_buttons[available_btns[63]],null_btn,null_btn); + else init_buttons(null_btn,null_btn,basic_buttons[available_btns[btn3]]); + }else{ + if(btn3 < 0) + init_buttons(null_btn,basic_buttons[available_btns[btn2]],null_btn); + else init_buttons(null_btn,basic_buttons[available_btns[btn2]],basic_buttons[available_btns[btn3]]); + } + }else{ + if(btn2 < 0){ + if(btn3 < 0) + init_buttons(basic_buttons[available_btns[btn1]],null_btn,null_btn); + else init_buttons(basic_buttons[available_btns[btn1]],null_btn,basic_buttons[available_btns[btn3]]); + }else{ + if(btn3 < 0) + init_buttons(basic_buttons[available_btns[btn1]],basic_buttons[available_btns[btn2]],null_btn); + else init_buttons(basic_buttons[available_btns[btn1]],basic_buttons[available_btns[btn2]], + basic_buttons[available_btns[btn3]]); + } + } + init_pict(pic); + operator->()->recalcRect(); +} + +void cThreeChoice::init_strings(std::vector& strings, unsigned short left){ + Rect cur_text_rect = {2, left, 0, 0}; + size_t total_len, str_width, str_height; + for (unsigned int i = 0; i < strings.size(); i++) + total_len += string_length(strings[i].c_str()); + total_len = total_len * 12; + str_width = s_sqrt(total_len) + 20; + //print_nums(0,total_len,str_width); + if (str_width < 340) + str_width = 340; + cur_text_rect.right = cur_text_rect.left + str_width; + cDialog* me = operator->(); + for(unsigned int j = 0; j < strings.size(); j++){ + std::ostringstream sout; + sout << "str" << j + 1; + str_height = ((string_length(strings[j].c_str()) + 60) / str_width) * 12 + 16; + cur_text_rect.bottom = cur_text_rect.top + str_height; + cTextMsg* str = new cTextMsg(me); + str->setText(strings[j]); + me->add(str, cur_text_rect, sout.str()); + cur_text_rect.top = cur_text_rect.bottom + 8; + } + buttons_right = cur_text_rect.right + 30; + buttons_top = cur_text_rect.top; +} + +template void cThreeChoice::init_buttons(bbtt btn1,bbtt btn2,bbtt btn3){ + Rect cur_btn_rect = {buttons_top,0,0,buttons_right}; + // The assignments in the if statements are intentional here. + if(btn_used[0] = a) btns[0] = btn1; + if(btn_used[1] = b) btns[1] = btn2; + if(btn_used[2] = c) btns[2] = btn3; + cDialog* me = operator->(); + for(int i = 0; i < 3; i++){ + if(!btn_used[i]) continue; + std::ostringstream sout; + sout << "btn" << i + 1; + cButton* btn = new cButton(me); + btn->attachKey(btns[i].defaultKey); + btn->setText(btns[i].label); + btn->setType(btns[i].type); + btn->attachClickHandler(boost::bind(&cChoiceDlog::onClick,this,_1,_2)); + switch(type){ + case BTN_HELP: + cur_btn_rect.bottom = cur_btn_rect.top + 13; + break; + case BTN_TINY: + case BTN_LED: // BTN_LED should never occur though + cur_btn_rect.bottom = cur_btn_rect.top + 10; + break; + case BTN_TALL: + case BTN_TRAIT: + cur_btn_rect.bottom = cur_btn_rect.top + 40; + break; + case BTN_PUSH: + cur_btn_rect.bottom = cur_btn_rect.top + 30; + break; + default: // in fact, this case should be the only one reachable, ideally + cur_btn_rect.bottom = cur_btn_rect.top + 23; + } + switch(type){ + case BTN_SM: + cur_btn_rect.left = cur_btn_rect.right - 23; + break; + case BTN_HELP: + cur_btn_rect.left = cur_btn_rect.right - 16; + break; + case BTN_TINY: + case BTN_LED: + cur_btn_rect.left = cur_btn_rect.right - 14; + break; + case BTN_PUSH: + cur_btn_rect.left = cur_btn_rect.right - 30; + break; + case BTN_LG: + cur_btn_rect.left = cur_btn_rect.right - 102; + break; + default: + cur_btn_rect.left = cur_btn_rect.right - 63; + } + me->add(btn, cur_btn_rect, sout.str()); + cur_btn_rect.right = cur_btn_rect.left - 4; + } +} + +void cThreeChoice::init_pict(pic_num_t pic){ + Rect pic_rect; + switch(type){ + case PIC_DLOG: + case PIC_CUSTOM_DLOG: + SetRect(&pic_rect,0,0,36,36); + break; + case PIC_TALK: + case PIC_CUSTOM_TALK: + case PIC_SCEN: + case PIC_CUSTOM_SCEN: + SetRect(&pic_rect,0,0,32,32); + break; + case PIC_MISSILE: + case PIC_CUSTOM_MISSILE: + SetRect(&pic_rect,0,0,18,18); + break; + case PIC_DLOG_LG: + case PIC_CUSTOM_DLOG_LG: + SetRect(&pic_rect,0,0,72,72); + break; + case PIC_SCEN_LG: + SetRect(&pic_rect,0,0,64,64); + break; + case PIC_TER_MAP: + case PIC_CUSTOM_TER_MAP: + SetRect(&pic_rect,0,0,24,24); + break; + case PIC_STATUS: + SetRect(&pic_rect,0,0,12,12); + default: + SetRect(&pic_rect,0,0,28,36); + } + OffsetRect(&pic_rect,8,8); + cDialog* me = operator->(); + cPict* pic_ctrl = new cPict(me); + pic_ctrl->setPict(pic,type); + me->add(pic_ctrl, pic_rect, "pict"); +} + +std::string cThreeChoice::show(){ + std::string result = cChoiceDlog::show(); + if(result == "btn1") return btns[0].label; + else if(result == "btn2") return btns[1].label; + else if(result == "btn3") return btns[2].label; + return "**ERROR**"; // shouldn't be reached +} + +std::string cStrDlog::getFileName(short n_strs, ePicType type, bool hasTitle){ + std::ostringstream sout; + sout << n_strs << "str"; + if(hasTitle) sout << "-title"; + if(type == PIC_DLOG_LG || type == PIC_CUSTOM_DLOG_LG || type == PIC_SCEN_LG) + sout << "-lg"; + sout << ".xml"; + return sout.str(); +} + +cStrDlog::cStrDlog(std::string str1,std::string str2,std::string title,pic_num_t pic,ePicType t,cDialog* parent) + : dlg(cStrDlog::getFileName((str1 != "") + (str2 != ""), t, title != ""), parent), type(t) { + cPict& pic_ctrl = dynamic_cast(dlg["pict"]); + pic_ctrl.setPict(pic, type); + if(str1 != "") { + dlg["str1"].setText(str1); + if(str2 != "") dlg["str2"].setText(str2); + }else if(str2 != "") dlg["str1"].setText(str2); + if(title != "") dlg["title"].setText(title); + dlg["record"].hide(); + dlg["record"].attachClickHandler(boost::bind(&cStrDlog::onRecord, this, _1, _2)); + dlg["okay"].attachClickHandler(boost::bind(&cStrDlog::onDismiss, this, _1, _2)); + this->str1 = str1; + this->str2 = str2; +} + +bool cStrDlog::onRecord(cDialog& me, std::string id){ + if(hasRecord) rec_f(str1, str2); + else me[id].hide(); + return hasRecord; +} + +bool cStrDlog::onDismiss(cDialog& me, std::string id){ + me.toast(); + return true; +} + +cStrDlog& cStrDlog::setSound(snd_num_t snd){ + sound = snd; + return *this; +} + +cStrDlog& cStrDlog::setRecordHandler(record_callback_t rec){ + if(rec == NULL){ + hasRecord = false; + dlg["record"].hide(); + }else{ + hasRecord = true; + rec_f = rec; + dlg["record"].show(); + } + return *this; +} + +void cStrDlog::show(){ + play_sound(sound); + dlg.run(); +} + +void giveError(std::string str1, std::string str2, short err, cDialog* parent){ + // TODO: ... +} + +void oopsError(short error, short code, short mode){ + // TODO: ... +} diff --git a/osx/dialogxml/dlogutil.h b/osx/dialogxml/dlogutil.h index 6e908fd5..64744085 100644 --- a/osx/dialogxml/dlogutil.h +++ b/osx/dialogxml/dlogutil.h @@ -11,70 +11,119 @@ #include #include +#include +#include "graphtool.h" // for pic_num_t +#include "soundtool.h" // for snd_num_t -typedef void (*record_callback_t)(std::string,std::string); +//typedef void (*record_callback_t)(std::string,std::string); +typedef boost::function record_callback_t; class cStrDlog { - cDialog dlg, *parent; - std::string str1, str2, title; + static std::string getFileName(short n_strs, ePicType type, bool hasTitle); + cDialog dlg; + std::string str1, str2; short sound; record_callback_t rec_f; + bool hasRecord; + const ePicType type; bool onRecord(cDialog& me, std::string id); bool onDismiss(cDialog& me, std::string id); public: - cStrDlog(std::string str) : dlg("1str.xml") {} - cStrDlog(std::string str1, std::string str2, bool hasTitle) : dlg(hasTitle ? "1str-title.xml" : "2str.xml") {} - cStrDlog(std::string str1, std::string str2, std::string title) : dlg("2str-title.xml") {} - cStrDlog& setPict(short num, ePicType type); - cStrDlog& setSound(short num); - cStrDlog& setParent(cDialog* parent); + cStrDlog(std::string str1,std::string str2,std::string title,pic_num_t pic,ePicType t,cDialog* parent); + cStrDlog& setSound(snd_num_t num); + cStrDlog& setRecordHandler(record_callback_t rec); void show(); }; class cChoiceDlog { - cDialog dlg, *parent; + cDialog dlg; +protected: bool onClick(cDialog& me, std::string id); public: - cChoiceDlog(std::string str) : dlg(str) {} - cChoiceDlog& setParent(cDialog* parent); + cChoiceDlog(std::string file, std::vector buttons, cDialog* p = NULL); + explicit cChoiceDlog(std::vector buttons, cDialog* p = NULL); + cDialog* operator->(); std::string show(); }; +template struct bbtt { // stands for "basic button type template" + eBtnType type; + std::string label; + cKey defaultKey; + operator bool(); + bbtt& operator=(bbtt&); +}; + +template<> struct bbtt { + operator bool(); + bbtt& operator=(bbtt&); +}; +typedef bbtt cBasicButtonType; + +namespace {const bbtt null_btn = {};} +#ifndef BTNS_DEFINED +extern cBasicButtonType basic_buttons[]; +extern size_t available_btns[]; +#endif + class cThreeChoice : public cChoiceDlog { + //static std::string getFileName(size_t n_strs); + bool btn_used[3]; + cBasicButtonType btns[3]; + unsigned short buttons_right, buttons_top; + void init_strings(std::vector& strings, unsigned short left); + template void init_buttons(bbtt btn1, bbtt btn2, bbtt btn3); + void init_pict(pic_num_t pic); + const ePicType type; public: - cThreeChoice(std::string str) : cChoiceDlog("1str-3-c.xml") {} - cThreeChoice(std::string str1, std::string str2) : cChoiceDlog("2str-3-c.xml") {} - cThreeChoice(std::string str1, std::string str2, std::string str3) : cChoiceDlog("3str-3-c.xml") {} - cThreeChoice(std::string str1, std::string str2, std::string str3, std::string str4) : cChoiceDlog("4str-3-c.xml") {} - cThreeChoice(std::string str1, std::string str2, std::string str3, std::string str4, std::string str5) : cChoiceDlog("5str-3-c.xml") {} - cThreeChoice(std::string str1, std::string str2, std::string str3, std::string str4, std::string str5, std::string str6) : cChoiceDlog("6str-3-c.xml") {} - cThreeChoice& setPict(short num, ePicType type); - cThreeChoice& setParent(cDialog* parent); - string show(); + template cThreeChoice + (std::vector strings, bbtt btn1, bbtt btn2, bbtt btn3, pic_num_t pic, ePicType t, cDialog* parent = NULL) + : cChoiceDlog(std::vector(), parent), type(t){ + if(type == PIC_CUSTOM_DLOG_LG || type == PIC_DLOG_LG || type == PIC_SCEN_LG) + init_strings(strings,86); + else + init_strings(strings,50); + init_buttons(btn1, btn2, btn3); + init_pict(pic); + operator->()->recalcRect(); + } + cThreeChoice(std::vector strings, short btn1, short btn2, short btn3, pic_num_t pic, ePicType t, cDialog* parent = NULL); + std::string show(); }; class cStringChoice { - cDialog dlg, *parent; + static const size_t per_page; + cDialog dlg; bool onLeft(cDialog& me, std::string id); bool onRight(cDialog& me, std::string id); bool onCancel(cDialog& me, std::string id); bool onOkay(cDialog& me, std::string id); + void fillPage(); + std::vector strings; + size_t page, cur; public: - cStringChoice(std::vector& strs); - cStringChoice(std::vector::iterator begin, std::vector::iterator end); - size_t show(); // returns the _index_ of the chosen string + explicit cStringChoice(std::vector& strs, cDialog* parent = NULL); + cStringChoice(std::vector::iterator begin, std::vector::iterator end, cDialog* parent = NULL); + size_t show(std::string select); // returns the _index_ of the chosen string, relative to begin + // returns strs.size() if the user cancels }; class cPictChoice { - cDialog dlg, *parent; + static const size_t per_page; + cDialog dlg; bool onLeft(cDialog& me, std::string id); bool onRight(cDialog& me, std::string id); bool onCancel(cDialog& me, std::string id); bool onOkay(cDialog& me, std::string id); + void fillPage(); + std::vector picts; + const ePicType type; + size_t page, cur; public: - cPictChoice(std::vector& pics, ePicType type); - cPictChoice(std::vector::iterator begin, std::vector::iterator end, ePicType type); - short show(); // returns the _number_ of the chosen picture, _not_ the index; there's no way to distinguish between duplicates + cPictChoice(std::vector& pics, ePicType t, cDialog* parent = NULL); + cPictChoice(std::vector::iterator begin, std::vector::iterator end, ePicType t, cDialog* parent = NULL); + pic_num_t show(pic_num_t fallback, pic_num_t cur_sel); // returns the _number_ of the chosen picture, _not_ the index; there's no way to distinguish between duplicates + // returns fallback if the user cancels }; #endif diff --git a/osx/dialogxml/edit-terrain.dlg b/osx/dialogxml/edit-terrain.dlg deleted file mode 100644 index 50e69ee5..00000000 --- a/osx/dialogxml/edit-terrain.dlg +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - Edit Terrain Type - Terrain number: - Terrain type name: - Terrain picture: - Terrain blockage: - - Clear - Walk through, opaque - Clear, special - Clear, blocked - Blocked, obstructed - Blocked, opaque - - Can fly over? - Can boat over? - Blocked to horses? - Step on sound: - - Footstep - Squish - Crunch - Silence - Big Splash - - Special properties: - - None - Change when step on - Damaging terrain - Is a bridge - Change while occupied - Dangerous terrain - Reserved - Crumbling terrain - Lockable terrain - Unlockable terrain - Reserved - Is a sign - Call special when step - Reserved - Is a container - Waterfall - Conveyor belt - Reserved - Reserved - Reserved - Blocked to monsters - Town entrance - Change when used - Call special when used - - Shortcut key: - Light radius: - Transform to what? - Extra values: - *flag1 - - *flag2 - - *flag3 - - Enter properties for this terrain type. For a detailed description of the fields, see the documentation. Note that, for terrain types 90 and below, only changes to the picture and shortcut key will be recorded. - - \ No newline at end of file diff --git a/osx/dialogxml/edit-terrain.xml b/osx/dialogxml/edit-terrain.xml new file mode 100644 index 00000000..4a83cbda --- /dev/null +++ b/osx/dialogxml/edit-terrain.xml @@ -0,0 +1,101 @@ + + + + + Edit Terrain Type + + Terrain number: + *num + Terrain type name: + + Terrain picture: + + + + Terrain blockage: + + Clear + Walk through, opaque + Clear, special + Clear, blocked + Blocked, obstructed + Blocked, opaque + + Can fly over? + Can boat over? + Blocked to horses? + Step sound: + + Footstep + Squish + Crunch + Silence + Big Splash + + Shortcut key: + + Light radius: + + Transform to what? + + + Ground type: + + Trim terrain: + + Trim type: + + + + Special properties: + + None + Change when step on + Damaging terrain + Is a bridge + Change while occupied + Dangerous terrain + Reserved + Crumbling terrain + Lockable terrain + Unlockable terrain + Reserved + Is a sign + Call special when step + Reserved + Is a container + Waterfall + Conveyor belt + Reserved + Reserved + Reserved + Blocked to monsters + Town entrance + Change when used + Call special when used + + Extra values: + *flag1 + + + *flag2 + + + *flag3 + + + + Combat Arena: + + + + Map icon: + + + + + \ No newline at end of file diff --git a/osx/dialogxml/field.cpp b/osx/dialogxml/field.cpp index 8fd97820..a4547682 100644 --- a/osx/dialogxml/field.cpp +++ b/osx/dialogxml/field.cpp @@ -46,19 +46,6 @@ std::string cTextField::getText(){ return std::string((char*)message); } -void cTextField::setTextToNum(short what){ - std::ostringstream sout; - sout << what; - setText(sout.str()); -} - -short cTextField::getTextAsNum(){ - std::istringstream sin(getText()); - short n; - sin >> n; - return n; -} - bool cTextField::isClickable(){ return false; } diff --git a/osx/dialogxml/field.h b/osx/dialogxml/field.h index 4385c4fd..df9b108d 100644 --- a/osx/dialogxml/field.h +++ b/osx/dialogxml/field.h @@ -20,8 +20,6 @@ public: short getFormat(eFormat prop) throw(xUnsupportedProp); std::string getText(); void setText(std::string what); - short getTextAsNum(); - void setTextToNum(short what); explicit cTextField(cDialog* parent); bool isClickable(); virtual ~cTextField(); diff --git a/osx/dialogxml/pict.cpp b/osx/dialogxml/pict.cpp index b5acf092..7f1b10e4 100644 --- a/osx/dialogxml/pict.cpp +++ b/osx/dialogxml/pict.cpp @@ -31,6 +31,7 @@ void cPict::init(){ drawPict[PIC_DLOG_LG] = drawPresetDlogLg; drawPict[PIC_SCEN_LG] = drawPresetScenLg; drawPict[PIC_TER_MAP] = drawPresetTerMap; + drawPict[PIC_TER_MAP] = drawStatusIcon; drawPict[PIC_MONST_WIDE] = drawPresetMonstWide; drawPict[PIC_MONST_TALL] = drawPresetMonstTall; drawPict[PIC_MONST_LG] = drawPresetMonstLg; @@ -173,6 +174,9 @@ void cPict::setSheet(eSheetType type, short n, GWorldPtr sheet){ case SHEET_HEADER: header = sheet; break; + case SHEET_STATUS: + status = sheet; + break; } } @@ -218,16 +222,26 @@ bool cPict::isSheetSet(eSheetType type, size_t num){ else return customSheets[num]; case SHEET_HEADER: return header; + case SHEET_STATUS: + return status; } return false; } -void cPict::setPict(short num, ePicType type){ +void cPict::setPict(pic_num_t num, ePicType type){ picNum = num; picType = type; if(isVisible()) draw(); } +pic_num_t cPict::getPicNum(){ + return picNum; +} + +ePicType cPict::getPicType(){ + return picType; +} + cPict::cPict(cDialog* parent) : cControl(parent,CTRL_PICT) {} bool cPict::isClickable(){ @@ -480,7 +494,7 @@ ePicType& operator-= (ePicType& lhs, ePicTypeMod rhs){ GWorldPtr cPict::teranim = NULL, cPict::dlog = NULL, cPict::talk = NULL, cPict::scen = NULL, cPict::largeScen = NULL; GWorldPtr cPict::item = NULL, cPict::tinyItem = NULL, cPict::pc = NULL, cPict::field = NULL, cPict::boom = NULL; -GWorldPtr cPict::missile = NULL, cPict::save = NULL, cPict::header = NULL, cPict::map = NULL; +GWorldPtr cPict::missile = NULL, cPict::save = NULL, cPict::header = NULL, cPict::map = NULL, cPict::status = NULL; std::vector cPict::ter, cPict::monst, cPict::customSheets; std::map cPict::largeSheets; std::map cPict::drawPict; @@ -752,6 +766,15 @@ void cPict::drawPresetTerMap(short num, GWorldPtr to_gw, Rect to_rect){ rect_draw_some_item(from_gw, from_rect, to_gw, to_rect, 0, 0); } +void cPict::drawStatusIcon(short num, GWorldPtr to_gw, Rect to_rect){ + Rect from_rect = {0,0,12,12}; + GWorldPtr from_gw = status; + to_rect.right = to_rect.left + 12; + to_rect.bottom = to_rect.top + 12; + OffsetRect(&from_rect,12 * (num % 3), 12 * (num / 3)); + rect_draw_some_item(from_gw, from_rect, to_gw, to_rect, 0, 0); +} + void cPict::drawCustomTer(short num, GWorldPtr to_gw, Rect to_rect){ printf("Drawing graphic %i as a custom terrain pic.\n",num); to_rect.right = to_rect.left + 28; diff --git a/osx/dialogxml/pict.h b/osx/dialogxml/pict.h index 1b05a40f..642a27bf 100644 --- a/osx/dialogxml/pict.h +++ b/osx/dialogxml/pict.h @@ -11,6 +11,7 @@ #include #include +#include "graphtool.h" // for pic_num_t enum ePicType { PIC_TER = 1, // 28x36 terrain graphic from the preset sheets @@ -28,6 +29,7 @@ enum ePicType { PIC_DLOG_LG = 13, // 72x72 dialog graphic from the dialog sheet PIC_SCEN_LG = 14, // 64x64 scenario graphic (currently each is on its own sheet) PIC_TER_MAP = 15, // 12x12 map graphic... or should it be 6x6? + PIC_STATUS = 16, // 12x12 status icon PIC_MONST_WIDE = 23, // 56x36 monster graphic from the preset sheets, resized to fit and centred in a 28x36 space PIC_MONST_TALL = 43, // 28x72 monster graphic from the preset sheets, resized to fit and centred in a 28x36 space PIC_MONST_LG = 63, // 56x72 monster graphic from the preset sheets, resized to fit in a 28x36 space @@ -81,6 +83,7 @@ enum eSheetType { SHEET_HEADER, SHEET_TER_MAP, SHEET_FULL, + SHEET_STATUS, SHEET_CUSTOM, }; @@ -94,7 +97,9 @@ public: short getFormat(eFormat prop) throw(xUnsupportedProp); static void setSheet(eSheetType type, short n, GWorldPtr sheet); static bool isSheetSet(eSheetType type, size_t n); - void setPict(short num, ePicType type); + void setPict(pic_num_t num, ePicType type); + pic_num_t getPicNum(); + ePicType getPicType(); explicit cPict(cDialog* parent); bool isClickable(); static void advanceAnim(); @@ -107,7 +112,7 @@ private: ePicType picType; bool clickable, drawFramed; friend class cDialog; - static GWorldPtr teranim, dlog, talk, scen, largeScen, item, tinyItem, pc, field, boom, missile, save, header, map; + static GWorldPtr teranim, dlog, talk, scen, largeScen, item, tinyItem, pc, field, boom, missile, save, header, map, status; static std::vector ter, monst, customSheets; static std::map largeSheets; // map instead of vector because it'll be a sparse array static void drawPresetTer(short num, GWorldPtr to_gw, Rect to_rect); @@ -127,6 +132,7 @@ private: static void drawPresetBoom(short num, GWorldPtr to_gw, Rect to_rect); static void drawPresetMissile(short num, GWorldPtr to_gw, Rect to_rect); static void drawPresetTerMap(short num, GWorldPtr to_gw, Rect to_rect); + static void drawStatusIcon(short num, GWorldPtr to_gw, Rect to_rect); static void drawFullSheet(short num, GWorldPtr to_gw, Rect to_rect); static void drawCustomTer(short num, GWorldPtr to_gw, Rect to_rect); static void drawCustomTerAnim(short num, GWorldPtr to_gw, Rect to_rect); diff --git a/osx/tools/cursors.h b/osx/tools/cursors.h new file mode 100644 index 00000000..da0f0138 --- /dev/null +++ b/osx/tools/cursors.h @@ -0,0 +1,27 @@ +// +// cursors.h +// BoE +// +// Created by Celtic Minstrel on 03/06/09. +// Wrappers for NSCursor, based on an Apple example +// + +#ifdef __cplusplus +#define C_DECL extern "C" +#else +#define C_DECL +#endif + +struct CocoaCursor { + void* ptr; +}; +typedef struct CocoaCursor CocoaCursor, *CursorRef; // including the struct keyword for Objective-C's sake + +C_DECL CursorRef CreateCursorFromFile(CFURLRef imgPath, float hotSpotX, float hotSpotY); +C_DECL void DisposeNSCursor(CursorRef cursor); +C_DECL void SetNSCursor(CursorRef cursor); +C_DECL void HideNSCursor(); +C_DECL void ShowNSCursor(); +C_DECL void CleanUp(); + +#undef C_DECL \ No newline at end of file diff --git a/osx/tools/cursors.m b/osx/tools/cursors.m new file mode 100644 index 00000000..830e8f7d --- /dev/null +++ b/osx/tools/cursors.m @@ -0,0 +1,79 @@ +// +// cursors.m +// BoE +// +// Created by Celtic Minstrel on 03/06/09. +// Wrappers for NSCursor, based on an Apple example +// + +#import +#import "cursors.h" +NSAutoreleasePool *pool; + +NSImage* ImageFromURL(CFURLRef url){ + CGImageSourceRef imageSource = CGImageSourceCreateWithURL(url, NULL); + CGImageRef theImage = nil; + + if(imageSource == nil) return nil; + + theImage = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL); + if(theImage == nil) return nil; + + CFRelease( imageSource ); + + NSRect imageRect = NSMakeRect(0.0, 0.0, 0.0, 0.0); + + // Get the image dimensions. + imageRect.size.height = CGImageGetHeight(theImage); + imageRect.size.width = CGImageGetWidth(theImage); + + // Create a new image to receive the Quartz image data. + NSImage *newImage = [[NSImage alloc] initWithSize:imageRect.size]; + [newImage lockFocus]; + + // Get the Quartz context and draw. + CGContextRef imageContext = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; + CGContextDrawImage(imageContext, *(CGRect*)&imageRect, theImage); + [newImage unlockFocus]; + + return newImage; +} + +CursorRef CreateCursorFromFile(CFURLRef imgPath, float hotSpotX, float hotSpotY){ + static BOOL inited = NO; + if(!inited){ + NSApplicationLoad(); + pool = [[NSAutoreleasePool alloc] init]; + [[[NSWindow alloc] init] release]; + inited = YES; + } + + NSImage *img = ImageFromURL(imgPath); + NSCursor *cursor = [[NSCursor alloc] initWithImage:img hotSpot:NSMakePoint(hotSpotX, hotSpotY)]; + [img release]; + + CursorRef theCursor = malloc(sizeof(CocoaCursor)); + theCursor->ptr = cursor; + return theCursor; +} + +void DisposeNSCursor(CursorRef cursor){ + [(NSCursor*)cursor->ptr release]; + free(cursor); +} + +void SetNSCursor(CursorRef cursor){ + [(NSCursor*)cursor->ptr set]; +} + +void HideNSCursor(){ + [NSCursor hide]; +} + +void ShowNSCursor(){ + [NSCursor unhide]; +} + +void CleanUp(){ + [pool release]; +} diff --git a/osx/tools/dlglowlevel.cpp b/osx/tools/dlglowlevel.cpp index bbc19d4a..bcbd205d 100644 --- a/osx/tools/dlglowlevel.cpp +++ b/osx/tools/dlglowlevel.cpp @@ -6,8 +6,8 @@ * */ -#include -#include +#include +#include #include "dlgconsts.h" #include "dlglowlevel.h" diff --git a/osx/tools/dlgtool.cpp b/osx/tools/dlgtool.cpp index a9bc111a..5850a83e 100644 --- a/osx/tools/dlgtool.cpp +++ b/osx/tools/dlgtool.cpp @@ -6,8 +6,8 @@ * */ -#include -#include +#include +#include #include using std::vector; //#include diff --git a/osx/tools/dlgutil.cpp b/osx/tools/dlgutil.cpp index 410d8fdc..81e04a2d 100644 --- a/osx/tools/dlgutil.cpp +++ b/osx/tools/dlgutil.cpp @@ -216,7 +216,6 @@ void give_error(char *text1, char *text2,short parent_num){ short store_str_label_1, store_str_label_2, store_str_label_1b, store_str_label_2b; // str_label_1 & str_label_2 uysed for saving button for journal // 1000 + x scen 2000 + x out 3000 + x town -__attribute__((deprecated)) void display_strings(char *text1, char *text2,short str_label_1,short str_label_2,short str_label_1b, short str_label_2b, char *title,short sound_num,short graphic_num,short graphic_type,short parent_num){ diff --git a/osx/tools/dlgutil.h b/osx/tools/dlgutil.h index 3133c2aa..b3c5ab56 100644 --- a/osx/tools/dlgutil.h +++ b/osx/tools/dlgutil.h @@ -11,7 +11,7 @@ short cd_create_custom_dialog(WindowPtr parent, Str255 strs[6],short pic_num,short btns[3]); void oops_error(short error,short code = 0, short mode = 0); void give_error(char *text1, char *text2,short parent_num); -void display_strings(char *text1, char *text2,short str_label_1,short str_label_2,short str_label_1b, short str_label_2b, char *title,short sound_num,short graphic_num,short graphic_type,short parent_num); +void display_strings(char *text1, char *text2,short str_label_1,short str_label_2,short str_label_1b, short str_label_2b, char *title,short sound_num,short graphic_num,short graphic_type,short parent_num) __attribute__((deprecated)); void display_strings(short a1,short a2, short b1, short b2, char *title,short sound_num,short graphic_num,short graphic_type,short parent_num); void display_strings_event_filter (short item_hit); void fancy_choice_dialog_event_filter (short item_hit); diff --git a/osx/tools/fileio.cpp b/osx/tools/fileio.cpp index 5dfbbb83..0c507442 100644 --- a/osx/tools/fileio.cpp +++ b/osx/tools/fileio.cpp @@ -27,7 +27,9 @@ extern bool cur_scen_is_mac, mac_is_intel; extern cScenario scenario; -extern GWorldPtr spec_scen_g; +extern GWorldPtr spec_scen_g,items_gworld,tiny_obj_gworld,fields_gworld,roads_gworld,boom_gworld,missiles_gworld; +extern GWorldPtr dlogpics_gworld,monst_gworld[],terrain_gworld[],anim_gworld,talkfaces_gworld,pc_gworld; +extern GWorldPtr status_gworld, vehicle_gworld, small_ter_gworld; extern cUniverse univ; //extern unsigned char borders[4][50]; //extern cOutdoors current_terrain; @@ -925,48 +927,88 @@ void load_spec_graphics() err = FSpMakeFSRef(&scenario.scen_file, &file); err = FSRefMakePath(&file, path, 255); printf("Loading scenario graphics... (%s)\n",(char*)path); - // for (i = 0; i < 63; i++) - // file_name[i] = whatever[i]; for (i = 0; i < 250; i++) { if (path[i] == '.') { - path[i + 1] = 'm'; - path[i + 2] = 'e'; - path[i + 3] = 'g'; + path[i + 1] = 'e'; + path[i + 2] = 'x'; + path[i + 3] = 'r'; //path[i + 4] = 0; break; } } - err = FSPathMakeRef(path, &file, NULL); - err = FSOpenResourceFile(&file, 0, NULL, fsRdPerm /*fsRdWrPerm*/, &custRef); - //file_num = HOpen(file_to_load.vRefNum,file_to_load.parID,file_name,1); - //if (file_num < 0){ - if(err != noErr){ - //whatever = (char *) file_to_load.name; - printf("First attempt failed... (%s)\n",(char*)path); + err = FSPathMakeRef(path,&file,NULL); + // TODO: Load new-style sheets + //if(err != noErr) + { + // for (i = 0; i < 63; i++) + // file_name[i] = whatever[i]; for (i = 0; i < 250; i++) { if (path[i] == '.') { - path[i + 1] = 'b'; - path[i + 2] = 'm'; - path[i + 3] = 'p'; + path[i + 1] = 'm'; + path[i + 2] = 'e'; + path[i + 3] = 'g'; //path[i + 4] = 0; break; } } err = FSPathMakeRef(path, &file, NULL); - FSSpec spec; - FSGetCatalogInfo(&file, kFSCatInfoNone, NULL, NULL, &spec, NULL); - err = FSpOpenDF(&spec, fsRdPerm, &custRef); - //spec_scen_g = load_bmp_from_file(file_name); - spec_scen_g = importPictureFileToGWorld(&spec); - if(spec_scen_g == NULL)printf("Scenario graphics not found (%s).\n",file_name); - return; - } + err = FSOpenResourceFile(&file, 0, NULL, fsRdPerm /*fsRdWrPerm*/, &custRef); + //file_num = HOpen(file_to_load.vRefNum,file_to_load.parID,file_name,1); + //if (file_num < 0){ + if(err != noErr){ + //whatever = (char *) file_to_load.name; + printf("First attempt failed... (%s)\n",(char*)path); + for (i = 0; i < 250; i++) { + if (path[i] == '.') { + path[i + 1] = 'b'; + path[i + 2] = 'm'; + path[i + 3] = 'p'; + //path[i + 4] = 0; + break; + } + } + err = FSPathMakeRef(path, &file, NULL); + FSSpec spec; + FSGetCatalogInfo(&file, kFSCatInfoNone, NULL, NULL, &spec, NULL); + err = FSpOpenDF(&spec, fsRdPerm, &custRef); + //spec_scen_g = load_bmp_from_file(file_name); + spec_scen_g = importPictureFileToGWorld(&spec); + if(spec_scen_g == NULL)printf("Scenario graphics not found (%s).\n",file_name); + }else{ + spec_scen_g = load_pict(1); + CloseResFile(custRef); + } + }//else{} - spec_scen_g = load_pict(1); - //CloseResFile(file_num); - CloseResFile(custRef); + // Now load regular graphics + items_gworld = load_pict("objects.png",univ.party.scen_name); + tiny_obj_gworld = load_pict("tinyobj.png",univ.party.scen_name); + fields_gworld = load_pict("fields.png",univ.party.scen_name); + roads_gworld = load_pict("trim.png",univ.party.scen_name); + boom_gworld = load_pict("booms.png",univ.party.scen_name); + missiles_gworld = load_pict("missiles.png",univ.party.scen_name); + dlogpics_gworld = load_pict("dlogpics.png",univ.party.scen_name); + status_gworld = load_pict("staticons.png",univ.party.scen_name); + + for (i = 0; i < 11; i++){ + std::ostringstream sout; + sout << "monst" << i + 1 << ".png"; + monst_gworld[i] = load_pict(sout.str(),univ.party.scen_name); + } + for (i = 0; i < 7; i++){ + std::ostringstream sout; + sout << "ter" << i + 1 << ".png"; + terrain_gworld[i] = load_pict(sout.str(),univ.party.scen_name); + } + anim_gworld = load_pict("teranim.png",univ.party.scen_name); + talkfaces_gworld = load_pict("talkportraits.png",univ.party.scen_name); + pc_gworld = load_pict("pcs.png",univ.party.scen_name); + vehicle_gworld = load_pict("vehicle.png",univ.party.scen_name); + small_ter_gworld = load_pict("mapOLD.png",univ.party.scen_name); // TODO: Should use the new map graphics instead + // TODO: Scenario icons ... } + bool load_party_v1(FSSpec file_to_load, bool town_restore, bool in_scen, bool maps_there, bool must_port); bool load_party_v2(FSSpec file_to_load, bool town_restore, bool in_scen, bool maps_there); bool load_party(FSSpec file_to_load){ @@ -1916,3 +1958,18 @@ bool save_party(FSSpec dest_file) // add_string_to_buf("Save: Game saved. "); return true; } + +std::vector load_strings(std::string which){ + char stringsPath[512]; + std::string path; + CFBundleRef mainBundle=CFBundleGetMainBundle(); + CFURLRef stringsURL = CFBundleCopyResourceURL(mainBundle,CFSTR("strings"),CFSTR(""),NULL); + CFStringGetCString(CFURLCopyFileSystemPath(stringsURL, kCFURLPOSIXPathStyle), stringsPath, 512, kCFStringEncodingUTF8); + path = stringsPath + '/' + which; + std::ifstream fin(path.c_str()); + std::string s; + std::vector v; + while(getline(fin,s)) + v.push_back(s); + return v; +} diff --git a/osx/tools/fileio.h b/osx/tools/fileio.h index 9c9af879..40346e48 100644 --- a/osx/tools/fileio.h +++ b/osx/tools/fileio.h @@ -6,6 +6,9 @@ * */ +#include +#include + void init_fileio(); struct no_file_chosen {}; // an exception class @@ -23,6 +26,7 @@ bool load_outdoors(location which_out,cOutdoors& the_out); bool load_outdoors(location which_out, short mode, ter_num_t borders[4][50]); bool load_outdoor_str(location which_out, short which_str, char* str); void load_spec_graphics(); +std::vector load_strings(std::string which); FSSpec nav_get_party() throw(no_file_chosen); FSSpec nav_put_party() throw(no_file_chosen); diff --git a/osx/tools/graphtool.cpp b/osx/tools/graphtool.cpp index 82bf6c58..9ac9c7d2 100644 --- a/osx/tools/graphtool.cpp +++ b/osx/tools/graphtool.cpp @@ -6,19 +6,18 @@ * */ -#define _GRAPHTOOL_CPP -#include "graphtool.h" +#define GRAPHTOOL_CPP #include +#include "graphtool.h" +#include "cursors.h" -//CursHandle arrow_curs[3][3], sword_curs, boot_curs, key_curs, target_curs,talk_curs,look_curs; -short arrow_curs[3][3] = { - {8, 9, 10}, - {11,12,13}, - {14,15,16}, +cursor_type arrow_curs[3][3] = { + {NW_curs, N_curs, NE_curs}, + {W_curs,wait_curs,E_curs}, + {SW_curs, S_curs, SE_curs}, }; -short sword_curs = 17, boot_curs = 18, drop_curs = 19, target_curs = 20; -short talk_curs = 21, key_curs = 22, look_curs = 23, current_cursor = 0; -CursHandle cursors[24] = { +cursor_type current_cursor = sword_curs; +CursorRef cursors[24] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, @@ -27,25 +26,47 @@ void (*redraw_screen)(); Point* offset; PixPatHandle bg[21]; short geneva_font_num, dungeon_font_num; +bool use_win_graphics = false; +CursorRef GetCursorFromPath(std::string filename, Point hotspot); + +void clean_up_graphtool(){ + for(int i = 0; i < 24; i++) + DisposeNSCursor(cursors[i]); + if(offset != NULL) delete offset; + CleanUp(); +} void init_graph_tool(void (*redraw_callback)(), Point* p){ redraw_screen = redraw_callback; int i,j; + static const Point cursor_hs[24] = { + { 4,1}, {1,14}, { 5,13}, {8,8}, {8,8}, {8,8}, {8,8}, {14,0}, + {12,3}, {13,7}, {12, 3}, + {9, 3}, {8, 8}, {8, 3}, + {12,3}, {13, 7},{12, 3}, + { 1,1}, {3, 7}, {14, 0}, {8,8}, {7,6}, {2,3}, {6,7} + }; + static const char*const edit_cursor_files[8] = { + "wand.gif","eyedropper.gif","brush.gif","spraycan.gif", + "eraser.gif","topleft.gif","bottomright.gif","hand.gif" + }; + static const char*const arrow_files[3][3] = { + {"NW.gif","W.gif","SW.gif"}, + {"N.gif","wait.gif","S.gif"}, + {"NE.gif","E.gif","SE.gif"} + }; + static const char*const game_cursor_files[7] = { + "sword.gif","boot.gif","drop.gif","target.gif", + "talk.gif","key.gif","look.gif" + }; if (cursors[0] == NULL) { for (i = 0; i < 8; i++) - cursors[i] = GetCursor(130 + i); + cursors[i] = GetCursorFromPath(edit_cursor_files[i],cursor_hs[i]); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) - cursors[arrow_curs[i][j]] = GetCursor(100 + (i - 1) + 10 * (j - 1)); - cursors[sword_curs] = GetCursor(120); - cursors[boot_curs] = GetCursor(121); - cursors[drop_curs] = GetCursor(122); - cursors[target_curs] = GetCursor(124); - cursors[talk_curs] = GetCursor(126); - cursors[key_curs] = GetCursor(127); - cursors[look_curs] = GetCursor(129); - set_cursor(sword_curs); - current_cursor = sword_curs; + cursors[arrow_curs[i][j]] = GetCursorFromPath(arrow_files[i][j],cursor_hs[arrow_curs[i][j]]); + for (i = 17; i < 24; i++) + cursors[i] = GetCursorFromPath(game_cursor_files[i - 17],cursor_hs[i]); } for (i = 0; i < 21; i++) bg[i] = GetPixPat(128 + i); @@ -78,6 +99,32 @@ unsigned int readUInt(unsigned char **ptr){ return ret; } +extern std::string progDir; +GWorldPtr load_pict(std::string picture_to_get, std::string scen_name){ + std::string filePath; + FSRef ref; + FSSpec spec; + if(scen_name != ""){ + filePath = progDir + "/Blades of Exile Scenarios/" + scen_name; + filePath.replace(filePath.find_last_of('.'),filePath.size(),".exr"); + filePath += '/' + picture_to_get; + printf(filePath.c_str()); + printf("\n\n"); + FSPathMakeRef((UInt8*)filePath.c_str(), &ref, NULL); + if(FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &spec, NULL) != fnfErr) + return importPictureFileToGWorld(&spec); + } + filePath = progDir + "/Scenario Editor/graphics.exd/"; + if(use_win_graphics) filePath += "win/"; + else filePath += "mac/"; + filePath += picture_to_get; + printf("Loading graphics sheet from: %s\n\n",filePath.c_str()); + FSPathMakeRef((UInt8*)filePath.c_str(), &ref, NULL); + if(FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, &spec, NULL) != fnfErr) + return importPictureFileToGWorld(&spec); + throw std::string("Graphic ") + picture_to_get + std::string(" not found."); // TODO: Create an exception class for this +} + GWorldPtr load_pict(int picture_to_get) { PicHandle current_pic_handle; @@ -202,11 +249,9 @@ GWorldPtr load_bmp(unsigned char *data, unsigned long length){ return newGWorld; } -void set_cursor(short which_c) { +void set_cursor(cursor_type which_c) { current_cursor = which_c; - HLock ((Handle) cursors[current_cursor]); - SetCursor (*cursors[current_cursor]); - HUnlock((Handle) cursors[current_cursor]); + SetNSCursor(cursors[current_cursor]); } void restore_cursor(){ @@ -229,10 +274,10 @@ void rect_draw_some_item (GWorldPtr src_gworld,Rect src_rect,GWorldPtr targ_gwor GrafPtr cur_port; RGBColor store_color; - if (main_win == 2) { + //if (main_win == 2) { GetBackColor(&store_color); BackColor(whiteColor); - } + //} GetPort(&cur_port); if (src_gworld == NULL) { @@ -264,7 +309,7 @@ void rect_draw_some_item (GWorldPtr src_gworld,Rect src_rect,GWorldPtr targ_gwor else CopyBits ( (BitMap*)* test1 , (BitMap*)*test2 , &src_rect, &targ_rect, - (masked == 10) ? addOver : 0, NULL); + (masked == 10) ? addOver : srcCopy, NULL); UnlockPixels(test2); } else { @@ -752,13 +797,27 @@ GWorldPtr importPictureFileToGWorld(const FSSpec *fileSpec){ Rect naturalBounds; GraphicsImportGetNaturalBounds (gi, &naturalBounds); GWorldPtr temp; - NewGWorld(&temp,32,&naturalBounds,NULL,GetGDevice(),noNewDevice + kNativeEndianPixMap); + NewGWorld(&temp,0,&naturalBounds,NULL,NULL,kNativeEndianPixMap); GraphicsImportSetGWorld (gi, temp, nil); GraphicsImportDraw (gi); CloseComponent(gi); return(temp); } +extern std::string progDir; +CursorRef GetCursorFromPath(std::string filename, Point hotspot){ + std::string fullpath = progDir + "/Scenario Editor/graphics.exd/"; + if(use_win_graphics) fullpath += "win"; + else fullpath += "mac"; + fullpath += "/cursors/"; + fullpath += filename; + printf("Loading cursor from: %s\n\n",fullpath.c_str()); + FSRef ref; + OSStatus err = FSPathMakeRef((UInt8*)fullpath.c_str(), &ref, NULL); + CFURLRef url = CFURLCreateFromFSRef(NULL, &ref); + return CreateCursorFromFile(url, hotspot.h, hotspot.v); +} + m_pic_index_t m_pic_index[] = { {1, 1, 1}, {2, 1, 1}, @@ -981,3 +1040,56 @@ m_pic_index_t m_pic_index[] = { {0, 1, 1}, //200 }; + +void tileImage(Rect area, GWorldPtr img, short mode){ + RgnHandle clip= NewRgn(); + RectRgn(clip,&area); + + GrafPtr cur_port; + GetPort(&cur_port); + const BitMap* drawDest = GetPortBitMapForCopyBits(cur_port); + PixMapHandle drawSource = GetPortPixMap(img); + + Rect imgRect; + GetPortBounds(img, &imgRect); + + int imgWidth=imgRect.right-imgRect.left; + int imgHeight=imgRect.bottom-imgRect.top; + int x,y; + unsigned int hrep = (int)((double(area.right-area.left)/imgWidth)+0.5); + unsigned int vrep = (int)((double(area.bottom-area.top)/imgHeight)+0.5); + for(unsigned int i=0; i #define LINES_IN_TEXT_WIN 11 +enum cursor_type { + wand_curs = 0, + eyedropper_curs = 1, + brush_curs = 2, + spray_curs = 3, + eraser_curs = 4, + topleft_curs = 5, + bottomright_curs = 6, + hand_curs = 7, + NW_curs = 8, + N_curs = 9, + NE_curs = 10, + W_curs = 11, + wait_curs = 12, + E_curs = 13, + SW_curs = 14, + S_curs = 15, + SE_curs = 16, + sword_curs = 17, + boot_curs = 18, + drop_curs = 19, + target_curs = 20, + talk_curs = 21, + key_curs = 22, + look_curs = 23, +}; + struct m_pic_index_t { unsigned char i, x, y; }; typedef unsigned short pic_num_t; void init_graph_tool(void (*redraw_callback)(),Point* p); -GWorldPtr load_pict(int picture_to_get); +void clean_up_graphtool(); +GWorldPtr load_pict(std::string picture_to_get, std::string scen_name = ""); +GWorldPtr load_pict(int picture_to_get) __attribute__((deprecated)); GWorldPtr load_bmp(unsigned char *data, unsigned long length); -void set_cursor(short which_curs); +void set_cursor(cursor_type which_curs); void restore_cursor(); void rect_draw_some_item (GWorldPtr src_gworld,Rect src_rect,GWorldPtr targ_gworld,Rect targ_rect, char masked,short main_win); @@ -31,11 +64,15 @@ short get_custom_rect (short which_rect, Rect& store_rect); void get_str(Str255 str,short i, short j); GWorldPtr importPictureFileToGWorld(const FSSpec *fileSpec); void writeGWorldToPNGFile(GWorldPtr gw, const FSSpec *fileSpec); -#ifndef _GRAPHTOOL_CPP -extern short arrow_curs[3][3]; -extern short sword_curs, boot_curs, drop_curs, target_curs; -extern short talk_curs, key_curs, look_curs, current_cursor; +void tileImage(Rect area, GWorldPtr img, short mode=0); +void tileImage(Rect area, GWorldPtr img, Rect srcRect, short mode=0); + +#ifndef GRAPHTOOL_CPP +extern cursor_type arrow_curs[3][3]; +extern cursor_type current_cursor; extern m_pic_index_t m_pic_index[200]; extern PixPatHandle bg[14]; extern short geneva_font_num,dungeon_font_num; #endif + +#endif diff --git a/osx/tools/mathutil.cpp b/osx/tools/mathutil.cpp index 8bfc4381..1ab2fcb1 100644 --- a/osx/tools/mathutil.cpp +++ b/osx/tools/mathutil.cpp @@ -7,7 +7,7 @@ */ #include "mathutil.h" -#include +#include short get_ran (short times,short min,short max){ long int store; diff --git a/osx/tools/viewdlog.cpp b/osx/tools/viewdlog.cpp index 7b4105ab..bc34538a 100644 --- a/osx/tools/viewdlog.cpp +++ b/osx/tools/viewdlog.cpp @@ -14,7 +14,7 @@ void Initialize(); void init_dialogs(); void display_strings(char *text1, char *text2, char *title,short graphic_num,short graphic_type,short parent_num); -GWorldPtr anim_gworld, talkfaces_gworld, items_gworld, tiny_obj_gworld, pc_gworld, dlog_gworld, monst_gworld[11], ter_gworld[7], small_ter_gworld, fields_gworld, pc_stats_gworld, item_stats_gworld, mixed_gworld; +GWorldPtr anim_gworld, talkfaces_gworld, items_gworld, tiny_obj_gworld, pc_gworld, dlog_gworld, monst_gworld[11], ter_gworld[7], small_ter_gworld, fields_gworld, pc_stats_gworld, item_stats_gworld; ResFileRefNum graphicsRef, soundsRef, boeRef, scenRef, pcRef; bool All_Done = false; WindowPtr mainPtr = (WindowPtr) -1; diff --git a/rsrc/graphics.exd/mac/boats.png b/rsrc/graphics.exd/mac/boats.png deleted file mode 100644 index 0fee2ec1..00000000 Binary files a/rsrc/graphics.exd/mac/boats.png and /dev/null differ diff --git a/rsrc/graphics.exd/mac/cursors/E.gif b/rsrc/graphics.exd/mac/cursors/E.gif new file mode 100644 index 00000000..fa105e7a Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/E.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/N.gif b/rsrc/graphics.exd/mac/cursors/N.gif new file mode 100644 index 00000000..ecb291c3 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/N.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/NE.gif b/rsrc/graphics.exd/mac/cursors/NE.gif new file mode 100644 index 00000000..777cb8af Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/NE.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/NW.gif b/rsrc/graphics.exd/mac/cursors/NW.gif new file mode 100644 index 00000000..68df212c Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/NW.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/S.gif b/rsrc/graphics.exd/mac/cursors/S.gif new file mode 100644 index 00000000..4b539496 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/S.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/SE.gif b/rsrc/graphics.exd/mac/cursors/SE.gif new file mode 100644 index 00000000..1555061c Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/SE.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/SW.gif b/rsrc/graphics.exd/mac/cursors/SW.gif new file mode 100644 index 00000000..4647059c Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/SW.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/W.gif b/rsrc/graphics.exd/mac/cursors/W.gif new file mode 100644 index 00000000..68b8b0c5 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/W.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/boot.gif b/rsrc/graphics.exd/mac/cursors/boot.gif new file mode 100644 index 00000000..71fd1322 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/boot.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/bottomright.gif b/rsrc/graphics.exd/mac/cursors/bottomright.gif new file mode 100644 index 00000000..6fc74f28 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/bottomright.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/brush.gif b/rsrc/graphics.exd/mac/cursors/brush.gif new file mode 100644 index 00000000..51461c31 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/brush.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/drop.gif b/rsrc/graphics.exd/mac/cursors/drop.gif new file mode 100644 index 00000000..da032da1 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/drop.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/eraser.gif b/rsrc/graphics.exd/mac/cursors/eraser.gif new file mode 100644 index 00000000..d6a515b7 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/eraser.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/eyedropper.gif b/rsrc/graphics.exd/mac/cursors/eyedropper.gif new file mode 100644 index 00000000..1427b7fd Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/eyedropper.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/hand.gif b/rsrc/graphics.exd/mac/cursors/hand.gif new file mode 100644 index 00000000..da032da1 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/hand.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/key.gif b/rsrc/graphics.exd/mac/cursors/key.gif new file mode 100644 index 00000000..bc565c0f Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/key.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/look.gif b/rsrc/graphics.exd/mac/cursors/look.gif new file mode 100644 index 00000000..8aacc4ea Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/look.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/spraycan.gif b/rsrc/graphics.exd/mac/cursors/spraycan.gif new file mode 100644 index 00000000..27ac2cde Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/spraycan.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/sword.gif b/rsrc/graphics.exd/mac/cursors/sword.gif new file mode 100644 index 00000000..046de790 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/sword.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/talk.gif b/rsrc/graphics.exd/mac/cursors/talk.gif new file mode 100644 index 00000000..f0d27572 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/talk.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/target.gif b/rsrc/graphics.exd/mac/cursors/target.gif new file mode 100644 index 00000000..cfbb23ab Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/target.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/topleft.gif b/rsrc/graphics.exd/mac/cursors/topleft.gif new file mode 100644 index 00000000..b1078f12 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/topleft.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/wait.gif b/rsrc/graphics.exd/mac/cursors/wait.gif new file mode 100644 index 00000000..92ca31e1 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/wait.gif differ diff --git a/rsrc/graphics.exd/mac/cursors/wand.gif b/rsrc/graphics.exd/mac/cursors/wand.gif new file mode 100644 index 00000000..725acd72 Binary files /dev/null and b/rsrc/graphics.exd/mac/cursors/wand.gif differ diff --git a/rsrc/graphics.exd/mac/dlogbtnhelp.png b/rsrc/graphics.exd/mac/dlogbtnhelp.png index 451cb925..c4b83a6a 100644 Binary files a/rsrc/graphics.exd/mac/dlogbtnhelp.png and b/rsrc/graphics.exd/mac/dlogbtnhelp.png differ diff --git a/rsrc/graphics.exd/mac/fields.png b/rsrc/graphics.exd/mac/fields.png index dfab9afa..222534ec 100644 Binary files a/rsrc/graphics.exd/mac/fields.png and b/rsrc/graphics.exd/mac/fields.png differ diff --git a/rsrc/graphics.exd/mac/horses.png b/rsrc/graphics.exd/mac/horses.png deleted file mode 100644 index f6d20bb8..00000000 Binary files a/rsrc/graphics.exd/mac/horses.png and /dev/null differ diff --git a/rsrc/graphics.exd/mac/invenbtns.png b/rsrc/graphics.exd/mac/invenbtns.png index e5a76244..97f273ad 100644 Binary files a/rsrc/graphics.exd/mac/invenbtns.png and b/rsrc/graphics.exd/mac/invenbtns.png differ diff --git a/rsrc/graphics.exd/mac/objects.png b/rsrc/graphics.exd/mac/objects.png index b8999a14..09e6280f 100644 Binary files a/rsrc/graphics.exd/mac/objects.png and b/rsrc/graphics.exd/mac/objects.png differ diff --git a/rsrc/graphics.exd/mac/startanim.png b/rsrc/graphics.exd/mac/startanim.png index 90915b2c..0e0d7c1e 100644 Binary files a/rsrc/graphics.exd/mac/startanim.png and b/rsrc/graphics.exd/mac/startanim.png differ diff --git a/rsrc/graphics.exd/mac/staticons.png b/rsrc/graphics.exd/mac/staticons.png index 645f48fe..05feecda 100644 Binary files a/rsrc/graphics.exd/mac/staticons.png and b/rsrc/graphics.exd/mac/staticons.png differ diff --git a/rsrc/graphics.exd/mac/terscreen.png b/rsrc/graphics.exd/mac/terscreen.png index 1c516f90..13cf6937 100644 Binary files a/rsrc/graphics.exd/mac/terscreen.png and b/rsrc/graphics.exd/mac/terscreen.png differ diff --git a/rsrc/graphics.exd/mac/trim.png b/rsrc/graphics.exd/mac/trim.png index 1dbb2609..bf30ff94 100644 Binary files a/rsrc/graphics.exd/mac/trim.png and b/rsrc/graphics.exd/mac/trim.png differ diff --git a/rsrc/graphics.exd/mac/vehicle.png b/rsrc/graphics.exd/mac/vehicle.png new file mode 100644 index 00000000..c44efe3f Binary files /dev/null and b/rsrc/graphics.exd/mac/vehicle.png differ diff --git a/rsrc/sounds.exa/SND0.WAV b/rsrc/sounds.exa/win/SND0.WAV similarity index 100% rename from rsrc/sounds.exa/SND0.WAV rename to rsrc/sounds.exa/win/SND0.WAV