diff --git a/osx/BoE.xcodeproj/project.pbxproj b/osx/BoE.xcodeproj/project.pbxproj index 12d53af4..28660b5e 100644 --- a/osx/BoE.xcodeproj/project.pbxproj +++ b/osx/BoE.xcodeproj/project.pbxproj @@ -62,6 +62,13 @@ 9107074C18F1D18400F7BD7F /* scrollbar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9191460018E63D8E005CF3A4 /* scrollbar.cpp */; }; 9107074D18F1D18400F7BD7F /* scrollbar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9191460018E63D8E005CF3A4 /* scrollbar.cpp */; }; 9107074E18F1D18500F7BD7F /* scrollbar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9191460018E63D8E005CF3A4 /* scrollbar.cpp */; }; + 9111513518FF144F001282A1 /* leave-town.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8E918FED338007026CE /* leave-town.xml */; }; + 9111513618FF144F001282A1 /* reunite-first.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8EA18FED4F2007026CE /* reunite-first.xml */; }; + 9111513718FF144F001282A1 /* reunited.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8EB18FEDAA5007026CE /* reunited.xml */; }; + 9111513818FF144F001282A1 /* not-split.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8EC18FEDB7F007026CE /* not-split.xml */; }; + 9111513918FF144F001282A1 /* leave-scenario.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8ED18FEDC25007026CE /* leave-scenario.xml */; }; + 9111513A18FF144F001282A1 /* save-quit.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8EE18FEDED1007026CE /* save-quit.xml */; }; + 9111513B18FF144F001282A1 /* save-open.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8EF18FEE014007026CE /* save-open.xml */; }; 912283C90FD0E16C00B21642 /* undo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 912283C80FD0E16C00B21642 /* undo.cpp */; }; 912286F80FD330E500B21642 /* dlogutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBADA0FB91D2A001E34EA /* dlogutil.cpp */; }; 912286F90FD330EA00B21642 /* button.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 910BBA890FB8EC57001E34EA /* button.cpp */; }; @@ -446,7 +453,6 @@ 91AC65520FA3441B00EEAE67 /* universe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC61C50FA2729900EEAE67 /* universe.cpp */; }; 91AC65AD0FA34AC600EEAE67 /* universe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC61C50FA2729900EEAE67 /* universe.cpp */; }; 91B3EF1F0F969C9C00BF5B67 /* BoECharEd.icns in Resources */ = {isa = PBXBuildFile; fileRef = 91B3EF110F969BD300BF5B67 /* BoECharEd.icns */; }; - 91B3EF390F969E8600BF5B67 /* Blades of Exile Character Editor-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 91B3EF130F969BD300BF5B67 /* Blades of Exile Character Editor-Info.plist */; }; 91B3EF450F969F1700BF5B67 /* BoE Scenario Editor-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 91B3EED90F969BA700BF5B67 /* BoE Scenario Editor-Info.plist */; }; 91B3EF470F969F1700BF5B67 /* BoE Scenario Editor.icns in Resources */ = {isa = PBXBuildFile; fileRef = 91B3EEDB0F969BA700BF5B67 /* BoE Scenario Editor.icns */; }; 91B3EF480F969F2300BF5B67 /* pc.main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EF050F969BD300BF5B67 /* pc.main.cpp */; }; @@ -517,6 +523,18 @@ 91F6F8F618F8DE6300E3EA15 /* qdpict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91F6F8F518F8DE6300E3EA15 /* qdpict.cpp */; }; 91F6F8F718F8DE6300E3EA15 /* qdpict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91F6F8F518F8DE6300E3EA15 /* qdpict.cpp */; }; 91F6F8F818F8DE6300E3EA15 /* qdpict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91F6F8F518F8DE6300E3EA15 /* qdpict.cpp */; }; + 91FCC8D818FE28CC007026CE /* pc.menu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 91FCC8D718FE28CC007026CE /* pc.menu.xib */; }; + 91FCC8DC18FE2CE8007026CE /* pc.menus.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91FCC8DB18FE2CE8007026CE /* pc.menus.mac.mm */; }; + 91FCC8DF18FE4708007026CE /* edit-day.xml in Resources */ = {isa = PBXBuildFile; fileRef = 91FCC8DE18FE4708007026CE /* edit-day.xml */; }; + 91FCC8E118FE4734007026CE /* edit-xp.xml in Resources */ = {isa = PBXBuildFile; fileRef = 91FCC8E018FE4734007026CE /* edit-xp.xml */; }; + 91FCC8E318FE4993007026CE /* about-pced.xml in Resources */ = {isa = PBXBuildFile; fileRef = 91FCC8E218FE4993007026CE /* about-pced.xml */; }; + 91FCC8E518FE5606007026CE /* pcedit.txt in Copy Strings */ = {isa = PBXBuildFile; fileRef = 91FCC8E418FE55F2007026CE /* pcedit.txt */; }; + 91FCC8E618FE5617007026CE /* about-pced.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8E218FE4993007026CE /* about-pced.xml */; }; + 91FCC8E718FE5617007026CE /* edit-day.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8DE18FE4708007026CE /* edit-day.xml */; }; + 91FCC8E818FE5617007026CE /* edit-xp.xml in Copy Dialog Definitions */ = {isa = PBXBuildFile; fileRef = 91FCC8E018FE4734007026CE /* edit-xp.xml */; }; + 91FCC8F118FEEDC6007026CE /* winutil.mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 919145FF18E63B70005CF3A4 /* winutil.mac.mm */; }; + 91FCC8F218FEEFE0007026CE /* pc.editors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91B3EF070F969BD300BF5B67 /* pc.editors.cpp */; }; + 91FCC8F418FF0866007026CE /* pc.appleevents.mm in Sources */ = {isa = PBXBuildFile; fileRef = 91FCC8F318FF069A007026CE /* pc.appleevents.mm */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -936,6 +954,16 @@ 91364F5C18F092EE0033B58E /* monster-info.xml in Copy Dialog Definitions */, 91364F5D18F092EE0033B58E /* pc-alchemy-info.xml in Copy Dialog Definitions */, 91364F5E18F092EE0033B58E /* pick-race-abil.xml in Copy Dialog Definitions */, + 91FCC8E618FE5617007026CE /* about-pced.xml in Copy Dialog Definitions */, + 91FCC8E718FE5617007026CE /* edit-day.xml in Copy Dialog Definitions */, + 91FCC8E818FE5617007026CE /* edit-xp.xml in Copy Dialog Definitions */, + 9111513518FF144F001282A1 /* leave-town.xml in Copy Dialog Definitions */, + 9111513618FF144F001282A1 /* reunite-first.xml in Copy Dialog Definitions */, + 9111513718FF144F001282A1 /* reunited.xml in Copy Dialog Definitions */, + 9111513818FF144F001282A1 /* not-split.xml in Copy Dialog Definitions */, + 9111513918FF144F001282A1 /* leave-scenario.xml in Copy Dialog Definitions */, + 9111513A18FF144F001282A1 /* save-quit.xml in Copy Dialog Definitions */, + 9111513B18FF144F001282A1 /* save-open.xml in Copy Dialog Definitions */, ); name = "Copy Dialog Definitions"; runOnlyForDeploymentPostprocessing = 0; @@ -957,6 +985,7 @@ 9192C14B18F32E8D0088A580 /* spell-times.txt in Copy Strings */, 9192C14C18F32E8D0088A580 /* magic-names.txt in Copy Strings */, 9192C15118F32E8D0088A580 /* traits.txt in Copy Strings */, + 91FCC8E518FE5606007026CE /* pcedit.txt in Copy Strings */, ); name = "Copy Strings"; runOnlyForDeploymentPostprocessing = 0; @@ -1490,6 +1519,21 @@ 91F6F8E118F87F3700E3EA15 /* sfml-window.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = "sfml-window.framework"; path = "../../../../../../Library/Frameworks/sfml-window.framework"; sourceTree = ""; }; 91F6F8E218F87F3700E3EA15 /* SFML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SFML.framework; path = ../../../../../../Library/Frameworks/SFML.framework; sourceTree = ""; }; 91F6F8F518F8DE6300E3EA15 /* qdpict.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = qdpict.cpp; sourceTree = ""; }; + 91FCC8D718FE28CC007026CE /* pc.menu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = pc.menu.xib; sourceTree = ""; }; + 91FCC8DA18FE2CCA007026CE /* pc.menus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = pc.menus.h; sourceTree = ""; }; + 91FCC8DB18FE2CE8007026CE /* pc.menus.mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = pc.menus.mac.mm; sourceTree = ""; }; + 91FCC8DE18FE4708007026CE /* edit-day.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "edit-day.xml"; sourceTree = ""; }; + 91FCC8E018FE4734007026CE /* edit-xp.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "edit-xp.xml"; sourceTree = ""; }; + 91FCC8E218FE4993007026CE /* about-pced.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "about-pced.xml"; sourceTree = ""; }; + 91FCC8E418FE55F2007026CE /* pcedit.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = pcedit.txt; path = strings/pcedit.txt; sourceTree = ""; }; + 91FCC8E918FED338007026CE /* leave-town.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "leave-town.xml"; sourceTree = ""; }; + 91FCC8EA18FED4F2007026CE /* reunite-first.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "reunite-first.xml"; sourceTree = ""; }; + 91FCC8EB18FEDAA5007026CE /* reunited.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = reunited.xml; sourceTree = ""; }; + 91FCC8EC18FEDB7F007026CE /* not-split.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "not-split.xml"; sourceTree = ""; }; + 91FCC8ED18FEDC25007026CE /* leave-scenario.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "leave-scenario.xml"; sourceTree = ""; }; + 91FCC8EE18FEDED1007026CE /* save-quit.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "save-quit.xml"; sourceTree = ""; }; + 91FCC8EF18FEE014007026CE /* save-open.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = "save-open.xml"; sourceTree = ""; }; + 91FCC8F318FF069A007026CE /* pc.appleevents.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = pc.appleevents.mm; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1777,6 +1821,7 @@ 9192C12518F327230088A580 /* mage-spells.txt */, 9192C13318F327230088A580 /* magic-names.txt */, 9192C12618F327230088A580 /* monster-abilities.txt */, + 91FCC8E418FE55F2007026CE /* pcedit.txt */, 9192C12A18F327230088A580 /* priest-spells.txt */, 9192C12D18F327230088A580 /* skills.txt */, 9192C13218F327230088A580 /* spell-times.txt */, @@ -1798,6 +1843,7 @@ 91364ECF18F0914F0033B58E /* 2str-title.xml */, 91364ED018F0914F0033B58E /* 2str.xml */, 91364ED118F0914F0033B58E /* about-boe.xml */, + 91FCC8E218FE4993007026CE /* about-pced.xml */, 9107074A18F0FC1300F7BD7F /* adventure-notes.xml */, 91364ED218F0914F0033B58E /* attack-friendly.xml */, 91364ED318F0914F0033B58E /* basic-button.xml */, @@ -1817,8 +1863,10 @@ 91364EE118F0914F0033B58E /* dark-slope-up.xml */, 91364EE218F0914F0033B58E /* delete-pc-confirm.xml */, 91364EE318F0914F0033B58E /* drop-item-confirm.xml */, + 91FCC8DE18FE4708007026CE /* edit-day.xml */, 91364EE418F0914F0033B58E /* edit-party.xml */, 91364EE518F0914F0033B58E /* edit-terrain.xml */, + 91FCC8E018FE4734007026CE /* edit-xp.xml */, 9107074818F0F5F000F7BD7F /* event-journal.xml */, 91364EE618F0914F0033B58E /* get-items.xml */, 91364EE718F0914F0033B58E /* get-num.xml */, @@ -1834,6 +1882,8 @@ 91364EF118F0914F0033B58E /* inventory-full.xml */, 91364EF218F0914F0033B58E /* item-info.xml */, 91364EF318F0914F0033B58E /* keep-stored-items.xml */, + 91FCC8ED18FEDC25007026CE /* leave-scenario.xml */, + 91FCC8E918FED338007026CE /* leave-town.xml */, 91364EF418F0914F0033B58E /* load-game-fail.xml */, 91364EF518F0914F0033B58E /* locked-door-action.xml */, 9156038F18F43C8D00A50C51 /* many-str.xml */, @@ -1842,6 +1892,7 @@ 91364EF818F0914F0033B58E /* new-party.xml */, 91364EF918F0914F0033B58E /* no-scenarios.xml */, 91364EFA18F0914F0033B58E /* not-save-game.xml */, + 91FCC8EC18FEDB7F007026CE /* not-split.xml */, 91364EFB18F0914F0033B58E /* party-death.xml */, 91364EFC18F0914F0033B58E /* pc-alchemy-info.xml */, 9107074B18F0FE3F00F7BD7F /* pc-info.xml */, @@ -1856,6 +1907,10 @@ 91364F0518F0914F0033B58E /* quit-confirm-save.xml */, 91364F0618F0914F0033B58E /* removed-special-items.xml */, 91364F0718F0914F0033B58E /* restart-game.xml */, + 91FCC8EA18FED4F2007026CE /* reunite-first.xml */, + 91FCC8EB18FEDAA5007026CE /* reunited.xml */, + 91FCC8EF18FEE014007026CE /* save-open.xml */, + 91FCC8EE18FEDED1007026CE /* save-quit.xml */, 91364F0818F0914F0033B58E /* scen-version-mismatch.xml */, 91364F0918F0914F0033B58E /* select-pc.xml */, 91364F0A18F0914F0033B58E /* skill-info.xml */, @@ -2206,6 +2261,7 @@ 91B3EEFE0F969BD300BF5B67 /* pc.fileio.h */, 91B3EEFF0F969BD300BF5B67 /* pc.global.h */, 91B3EF000F969BD300BF5B67 /* pc.graphics.h */, + 91FCC8DA18FE2CCA007026CE /* pc.menus.h */, ); name = headers; sourceTree = ""; @@ -2214,10 +2270,12 @@ isa = PBXGroup; children = ( 91B3EF060F969BD300BF5B67 /* pc.action.cpp */, + 91FCC8F318FF069A007026CE /* pc.appleevents.mm */, 91B3EF070F969BD300BF5B67 /* pc.editors.cpp */, 91B3EF080F969BD300BF5B67 /* pc.fileio.cpp */, 91B3EF0A0F969BD300BF5B67 /* pc.graphics.cpp */, 91B3EF050F969BD300BF5B67 /* pc.main.cpp */, + 91FCC8DB18FE2CE8007026CE /* pc.menus.mac.mm */, ); name = src; sourceTree = ""; @@ -2230,6 +2288,7 @@ 91B3EF110F969BD300BF5B67 /* BoECharEd.icns */, 91B3EF120F969BD300BF5B67 /* bladespced.rsrc */, 91B3EF130F969BD300BF5B67 /* Blades of Exile Character Editor-Info.plist */, + 91FCC8D718FE28CC007026CE /* pc.menu.xib */, ); name = rsrc; sourceTree = ""; @@ -2478,7 +2537,10 @@ buildActionMask = 2147483647; files = ( 91B3EF1F0F969C9C00BF5B67 /* BoECharEd.icns in Resources */, - 91B3EF390F969E8600BF5B67 /* Blades of Exile Character Editor-Info.plist in Resources */, + 91FCC8D818FE28CC007026CE /* pc.menu.xib in Resources */, + 91FCC8DF18FE4708007026CE /* edit-day.xml in Resources */, + 91FCC8E118FE4734007026CE /* edit-xp.xml in Resources */, + 91FCC8E318FE4993007026CE /* about-pced.xml in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2579,6 +2641,7 @@ 9107074C18F1D18400F7BD7F /* scrollbar.cpp in Sources */, 91F6F8F618F8DE6300E3EA15 /* qdpict.cpp in Sources */, 91EC483B18FBAD8000BB1E86 /* prefs.mac.mm in Sources */, + 91FCC8F218FEEFE0007026CE /* pc.editors.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2627,6 +2690,9 @@ 91A32D1F0FDE04A100C4E957 /* tinyxmlparser.cpp in Sources */, 9107074D18F1D18400F7BD7F /* scrollbar.cpp in Sources */, 91F6F8F718F8DE6300E3EA15 /* qdpict.cpp in Sources */, + 91FCC8DC18FE2CE8007026CE /* pc.menus.mac.mm in Sources */, + 91FCC8F118FEEDC6007026CE /* winutil.mac.mm in Sources */, + 91FCC8F418FF0866007026CE /* pc.appleevents.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/osx/boe.actions.cpp b/osx/boe.actions.cpp index a242cc8d..1bbd1468 100644 --- a/osx/boe.actions.cpp +++ b/osx/boe.actions.cpp @@ -1530,66 +1530,6 @@ void initiate_outdoor_combat(short i) draw_terrain(); } -// TODO: I'm sure there's a better way to do this (maybe one that's keyboard layout agnostic) -char keyToChar(sf::Keyboard::Key key, bool isShift) { - using kb = sf::Keyboard; - switch(key) { - case kb::A: return isShift ? 'A' : 'a'; - case kb::B: return isShift ? 'B' : 'b'; - case kb::C: return isShift ? 'C' : 'c'; - case kb::D: return isShift ? 'D' : 'd'; - case kb::E: return isShift ? 'E' : 'e'; - case kb::F: return isShift ? 'F' : 'f'; - case kb::G: return isShift ? 'G' : 'g'; - case kb::H: return isShift ? 'H' : 'h'; - case kb::I: return isShift ? 'I' : 'i'; - case kb::J: return isShift ? 'J' : 'j'; - case kb::K: return isShift ? 'K' : 'k'; - case kb::L: return isShift ? 'L' : 'l'; - case kb::M: return isShift ? 'M' : 'm'; - case kb::N: return isShift ? 'N' : 'n'; - case kb::O: return isShift ? 'O' : 'o'; - case kb::P: return isShift ? 'P' : 'p'; - case kb::Q: return isShift ? 'Q' : 'q'; - case kb::R: return isShift ? 'R' : 'r'; - case kb::S: return isShift ? 'S' : 's'; - case kb::T: return isShift ? 'T' : 't'; - case kb::U: return isShift ? 'U' : 'u'; - case kb::V: return isShift ? 'V' : 'v'; - case kb::W: return isShift ? 'W' : 'w'; - case kb::X: return isShift ? 'X' : 'x'; - case kb::Y: return isShift ? 'Y' : 'y'; - case kb::Z: return isShift ? 'Z' : 'z'; - case kb::Num1: return isShift ? '!' : '1'; - case kb::Num2: return isShift ? '@' : '2'; - case kb::Num3: return isShift ? '#' : '3'; - case kb::Num4: return isShift ? '$' : '4'; - case kb::Num5: return isShift ? '%' : '5'; - case kb::Num6: return isShift ? '^' : '6'; - case kb::Num7: return isShift ? '&' : '7'; - case kb::Num8: return isShift ? '*' : '8'; - case kb::Num9: return isShift ? '(' : '9'; - case kb::Num0: return isShift ? ')' : '0'; - case kb::Tilde: return isShift ? '~' : '`'; - case kb::Dash: return isShift ? '_' : '-'; - case kb::Equal: return isShift ? '+' : '='; - case kb::LBracket: return isShift ? '{' : '['; - case kb::RBracket: return isShift ? '}' : ']'; - case kb::SemiColon: return isShift ? ':' : ';'; - case kb::Quote: return isShift ? '"' : '\''; - case kb::Comma: return isShift ? '<' : ','; - case kb::Period: return isShift ? '>' : '.'; - case kb::Slash: return isShift ? '?' : '/'; - case kb::BackSlash: return isShift ? '|' : '\\'; - case kb::Tab: return '\t'; - case kb::Space: return ' '; - case kb::Return: return '\n'; - case kb::BackSpace: return '\b'; - case kb::Delete: return '\x7f'; - } - return 0; -} - bool handle_keystroke(sf::Event& event){ bool are_done = false; location pass_point; // TODO: This isn't needed diff --git a/osx/boe.dlgutil.cpp b/osx/boe.dlgutil.cpp index e56d7903..86a2be15 100644 --- a/osx/boe.dlgutil.cpp +++ b/osx/boe.dlgutil.cpp @@ -366,7 +366,7 @@ void handle_info_request(short what_chosen) break; case 5: // TODO: Create a dedicated dialog for alchemy info - display_alchemy(NULL); + display_alchemy(); break; case 8: base_item = store_mage_spells(what_chosen - 800 - 30); diff --git a/osx/boe.fileio.cpp b/osx/boe.fileio.cpp index c72b672a..ae4d66ce 100644 --- a/osx/boe.fileio.cpp +++ b/osx/boe.fileio.cpp @@ -99,6 +99,7 @@ fs::path progDir; cCustomGraphics spec_scen_g; std::ofstream flog("bladeslog.txt"); +// TODO: Move this to the common fileio.cpp void init_directories() { char cPath[768]; diff --git a/osx/boe.infodlg.cpp b/osx/boe.infodlg.cpp index 0863fbdb..3c7aa65e 100644 --- a/osx/boe.infodlg.cpp +++ b/osx/boe.infodlg.cpp @@ -28,7 +28,6 @@ #include "prefs.hpp" short mage_spell_pos = 0,priest_spell_pos = 0,skill_pos = 0; -cPlayer *store_pc; cCreature *store_m; short store_trait_mode,store_item_pc,store_pc_num; cItemRec store_i; @@ -39,7 +38,6 @@ extern short skill_cost[20]; extern short skill_max[20]; extern short skill_g_cost[20]; extern const char* skill_ids[19]; -extern short which_pc_displayed; //extern party_record_type party; extern short mage_range[66],priest_range[66]; extern short spell_cost[2][62],cur_town_talk_loaded; @@ -201,75 +199,6 @@ void display_skills(short force_skill,cDialog* parent) skillDlog.run(); } -static void put_pc_spells(cDialog& me) -{ - short i; - - for (i = 0; i < 62; i++) { - std::string id = "spell" + boost::lexical_cast(i + 1); - cLed& cur = dynamic_cast(me[id]); - if (((store_trait_mode == 0) && univ.party[which_pc_displayed].mage_spells[i]) || - ((store_trait_mode == 1) && univ.party[which_pc_displayed].priest_spells[i])) - cur.setState(led_red); - else cur.setState(led_off); - } - - me["who"].setText(univ.party[which_pc_displayed].name.c_str()); -} - -static bool display_pc_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) -{ - short pc_num; - - pc_num = which_pc_displayed; - if(item_hit == "done") { - me.toast(); - } else if(item_hit == "left") { - do { - pc_num = (pc_num == 0) ? 5 : pc_num - 1; - } while (univ.party[pc_num].main_status == 0); - which_pc_displayed = pc_num; - put_pc_spells(me); - } else if(item_hit == "right") { - do { - pc_num = (pc_num == 5) ? 0 : pc_num + 1; - } while (univ.party[pc_num].main_status == 0); - which_pc_displayed = pc_num; - put_pc_spells(me); - } - return true; -} - -void display_pc(short pc_num,short mode,cDialog* parent) -{ - short i; - std::string label_str; - - if (univ.party[pc_num].main_status == 0) { - for (pc_num = 0; pc_num < 6; pc_num++) - if (univ.party[pc_num].main_status == 1) - break; - } - which_pc_displayed = pc_num; - store_trait_mode = mode; - - make_cursor_sword(); - - cDialog pcInfo("pc-spell-info.xml", parent); - pcInfo.attachClickHandlers(display_pc_event_filter,{"done","left","right"}); - - for (i = 0; i < 62; i++) { - std::string id = "spell" + boost::lexical_cast(i + 1); - label_str = get_str((mode == 0) ? "mage-spells" : "priest-spells",i * 2 + 1); - pcInfo[id].setText(label_str); - } - put_pc_spells(pcInfo); - - dynamic_cast(pcInfo["pic"]).setPict(14 + mode,PIC_DLOG); - - pcInfo.run(); -} - static void put_item_info(cDialog& me,short pc,short item)//// { char store_text[256]; @@ -641,7 +570,7 @@ static bool display_alchemy_event_filter(cDialog& me, std::string item_hit, eKey return true; } -void display_alchemy(cDialog* parent) +void display_alchemy() { std::string get_text; @@ -649,7 +578,7 @@ void display_alchemy(cDialog* parent) make_cursor_sword(); - cDialog alchemy("many-str.xml",parent); + cDialog alchemy("many-str.xml"); alchemy.attachClickHandlers(display_alchemy_event_filter, {"done", "left", "right"}); get_text = get_str("alchemy", 1); @@ -662,113 +591,6 @@ void display_alchemy(cDialog* parent) alchemy.run(); } -static void display_alchemy() -{ - short i; - - make_cursor_sword(); - - cChoiceDlog showAlch("pc-alchemy-info.xml", {"done"}); - - for (i = 0; i < 20; i++) { - std::string id = "potion" + boost::lexical_cast(i + 1); - showAlch->addLabelFor(id, alch_names[i], LABEL_LEFT, 83, true); - showAlch->getControl(id).attachClickHandler(&cDialog::noAction); - cLed& led = dynamic_cast(showAlch->getControl(id)); - if (univ.party.alchemy[i] > 0) - led.setState(led_red); - else led.setState(led_off); - } - - showAlch.show(); -} - - -static void display_traits_graphics(cDialog& me) -{ - short i,store; - - std::string race = "race" + boost::lexical_cast(store_pc->race + 1); - dynamic_cast(me["race"]).setSelected(race); - for (i = 0; i < 10; i++) { - std::string id = "good" + boost::lexical_cast(i + 1); - dynamic_cast(me[id]).setState((store_pc->traits[i] > 0) ? led_red : led_off); - } - for (i = 0; i < 5; i++) { - std::string id = "bad" + boost::lexical_cast(i + 1); - dynamic_cast(me[id]).setState((store_pc->traits[10 + i] > 0) ? led_red : led_off); - } - - store = store_pc->get_tnl(); - me["xp"].setTextToNum(store); -} - -static bool pick_race_abil_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) { - me.toast(); - return true; -} - -static bool pick_race_select_led(cDialog& me, std::string item_hit, bool losing) -{ - std::string abil_str; - cPlayer *pc; - - pc = store_pc; - if(item_hit == "race") { - eRace race; - switch(item_hit[4] - '1') { - case 0: race = RACE_HUMAN; break; - case 1: race = RACE_NEPHIL; break; - case 2: race = RACE_SLITH; break; - case 3: race = RACE_VAHNATAI; break; - } - if(store_trait_mode == 0) - pc->race = race; - display_traits_graphics(me); - abil_str = get_str("traits",16 + race); - me["info"].setText(abil_str); - } else if(item_hit.substr(0,3) == "bad") { - int hit = item_hit[3] - '1'; - if(store_trait_mode != 1) - pc->traits[hit + 10] = (pc->traits[hit + 10] == true) ? false : true; - display_traits_graphics(me); - abil_str = get_str("traits",hit + 11); - me["info"].setText(abil_str); - } else if(item_hit.substr(0,4) == "good") { - int hit = item_hit[4] - '1'; - if(store_trait_mode != 1) - pc->traits[hit] = (pc->traits[hit] == true) ? false : true; - display_traits_graphics(me); - abil_str = get_str("traits",hit + 1); - me["info"].setText(abil_str); - } - return store_trait_mode == 0; -} - -void pick_race_abil(cPlayer *pc,short mode,cDialog* parent) -//mode; // 0 - edit 1 - just display 2 - can't change race -{ - static const char*const start_str1 = "Click on button by name for description."; - static const char*const start_str2 = "Click on advantage button to add/remove."; - - store_trait_mode = mode; - store_pc = pc; - make_cursor_sword(); - - cDialog pickAbil("pick-race-abil.xml"); - pickAbil["done"].attachClickHandler(pick_race_abil_event_filter); - pickAbil.attachFocusHandlers(pick_race_select_led, {"race", "bad1", "bad2", "bad3", "bad4", "bad5"}); - pickAbil.attachFocusHandlers(pick_race_select_led, {"good1", "good2", "good3", "good4", "good5"}); - pickAbil.attachFocusHandlers(pick_race_select_led, {"good6", "good7", "good8", "good9", "good10"}); - - display_traits_graphics(pickAbil); - if (mode == 1) - pickAbil["info"].setText(start_str1); - else pickAbil["info"].setText(start_str2); - - pickAbil.run(); -} - static void display_pc_info(cDialog& me) { short i,store; @@ -890,7 +712,7 @@ static bool give_pc_extra_info(cDialog& me, std::string item_hit, eKeyMod mods) if(item_hit == "seemage") display_pc(pc,0,&me); else if(item_hit == "seepriest") display_pc(pc,1,&me); else if(item_hit == "trait") pick_race_abil(&univ.party[pc],1,&me); - else if(item_hit == "alch") display_alchemy(); + else if(item_hit == "alch") display_alchemy(false); return true; } diff --git a/osx/boe.infodlg.h b/osx/boe.infodlg.h index 3b8060ff..a9d0409e 100644 --- a/osx/boe.infodlg.h +++ b/osx/boe.infodlg.h @@ -4,11 +4,9 @@ class cDialog; void display_spells(short mode,short force_spell,cDialog* parent); void display_skills(short force_skill,cDialog* parent); -void display_pc(short pc_num,short mode,cDialog* parent_num); void display_pc_item(short pc_num,short item,cItemRec si,cDialog* parent); void display_monst(short array_pos,cCreature *which_m,short mode); -void display_alchemy(cDialog* parent); -void pick_race_abil(cPlayer *pc,short mode,cDialog* parent); +void display_alchemy(); void display_traits_graphics(); void give_pc_info(short pc_num); void adventure_notes(); @@ -24,6 +22,11 @@ void put_spec_item_info (short which_i); //void give_error(const char *text1, const char *text2,short parent_num); //void display_strings_with_nums(short a1,short a2, short b1, short b2, char *title,short sound_num,short graphic_num,short graphic_type,short parent_num); +// These are defined in pc.editors.cpp since they are also used by the character editor +void pick_race_abil(cPlayer *pc,short mode,cDialog* parent); +void display_pc(short pc_num,short mode,cDialog* parent_num); +void display_alchemy(bool allowEdit); + // Callback for recording encounter strings class cStringRecorder { private: diff --git a/osx/boe.items.cpp b/osx/boe.items.cpp index 4a7bd5fe..ca77cf15 100644 --- a/osx/boe.items.cpp +++ b/osx/boe.items.cpp @@ -1151,56 +1151,6 @@ short custom_choice_dialog(std::array& strs,short pic_num,ePicTy // return i; //} -static bool select_pc_event_filter (cDialog& me, std::string item_hit, eKeyMod mods) -{ - me.toast(); - if(item_hit != "cancel") { - short which_pc = item_hit[item_hit.length() - 1] - '1'; - me.setResult(which_pc); - } else me.setResult(6); - return true; -} - -short char_select_pc(short active_only,short free_inv_only,const char *title) -//active_only; // 0 - no 1 - yes 2 - disarm trap -{ - short item_hit,i; - - make_cursor_sword(); - - cDialog selectPc("select-pc.xml"); - selectPc.attachClickHandlers(select_pc_event_filter, {"cancel", "pick1", "pick2", "pick3", "pick4", "pick5", "pick6"}); - - selectPc["title"].setText(title); - - for (i = 0; i < 6; i++) { - std::string n = boost::lexical_cast(i + 1); - if ((univ.party[i].main_status == 0) || - ((active_only == true) && (univ.party[i].main_status > 1)) || - ((free_inv_only == 1) && (pc_has_space(i) == 24)) || (univ.party[i].main_status == 5)) { - selectPc["pick" + n].hide(); - } - // TODO: Wouldn't this lead to blank name fields for non-active characters if those characters are allowed? - if (univ.party[i].main_status != 0) { - selectPc["pc" + n].setText(univ.party[i].name); - } - else selectPc["pc" + n].hide(); - } - - selectPc.run(); - item_hit = selectPc.getResult(); - - return item_hit; -} - -short select_pc(short active_only,short free_inv_only) -//active_only; // 0 - no 1 - yes 2 - disarm trap -{ - if (active_only == 2) - return char_select_pc(active_only,free_inv_only,"Trap! Who will disarm?"); - else return char_select_pc(active_only,free_inv_only,"Select a character:"); -} - static bool get_num_of_items_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) { me.setResult(me["number"].getTextAsNum()); diff --git a/osx/boe.items.h b/osx/boe.items.h index a0aa95ba..23cfb781 100644 --- a/osx/boe.items.h +++ b/osx/boe.items.h @@ -38,8 +38,6 @@ void make_town_hostile(); bool display_item(location from_loc,short pc_num,short mode, bool check_container); short custom_choice_dialog(std::array& strs,short pic_num,ePicType pic_type,std::array& buttons) ; //short fancy_choice_dialog(short which_dlog,short parent); -short char_select_pc(short active_only,short free_inv_only,const char *title); -short select_pc(short active_only,short free_inv_only); short get_num_of_items(short max_num); void init_mini_map(); void put_pc_effects_on_dialog(cDialog& dialog,short item); @@ -56,3 +54,7 @@ short luck_total(); cItemRec return_treasure(short loot,short level,short mode); void refresh_store_items(); std::string get_text_response(short dlg,short parent_num); + +// These are defined in pc.editors.cpp since they are also used by the character editor +short char_select_pc(short active_only,short free_inv_only,const char *title); +short select_pc(short active_only,short free_inv_only); diff --git a/osx/boe.main.cpp b/osx/boe.main.cpp index b585f18a..4e37e6bb 100644 --- a/osx/boe.main.cpp +++ b/osx/boe.main.cpp @@ -792,7 +792,7 @@ void handle_library_menu(int item_hit) break; case 4: // TODO: Create a dedicated dialog for alchemy info - display_alchemy(NULL); + display_alchemy(); break; case 5: tip_of_day(); break; diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index 94a9626d..bbbe5814 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -35,16 +35,7 @@ #include #include "button.h" -short skill_cost[20] = { - 3,3,3,2,2,2, 1,2,2,6, - 5, 1,2,4,2,1, 4,2,5,0}; -extern short skill_max[20] ; -short skill_g_cost[20] = { - 50,50,50,40,40,40,30,50,40,250, - 250,25,100,200,30,20,100,80,0,0}; -short skill_bonus[21] = { - -3,-3,-2,-1,0,0,1,1,1,2, - 2,2,3,3,3,3,4,4,4,5,5}; +extern short skill_bonus[21]; short spell_level[62] = { 1,1,1,1,1,1,1,1,1,1, 2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,3,3, @@ -84,15 +75,7 @@ const char *priest_s_name[62] = { "Guardian","Mass Charm","Protective Circle","Pestilence", "Revive All","Ravage Spirit","Resurrect","Divine Thud", "Avatar","Wall of Blades","Word of Recall","Major Cleansing"}; -const char *alch_names[20] = { - "Weak Curing Potion (1)","Weak Healing Potion (1)","Weak Poison (1)", - "Weak Speed Potion (3)","Medium Poison (3)", - "Medium Heal Potion (4)","Strong Curing (5)","Medium Speed Potion (5)", - "Graymold Salve (7)","Weak Energy Potion (9)", - "Potion of Clarity (9)","Strong Poison (10)","Strong Heal Potion (12)","Killer Poison (12)", - "Resurrection Balm (9)","Medium Energy Ptn. (14)","Knowledge Brew (19)" , - "Strong Strength (10)","Bliss (16)","Strong Power (20)" -}; +extern const char* alch_names[20]; const char *alch_names_short[20] = { "Weak Curing Potion","Weak Healing Potion","Weak Poison", "Weak Speed Potion","Medium Poison", @@ -102,13 +85,6 @@ const char *alch_names_short[20] = { "Resurrection Bal","Medium Energy Ptn.","Knowledge Brew" , "Strong Strength","Bliss","Strong Power" }; -// These are the IDs used to refer to the skills in the dialog -const char* skill_ids[19] = { - "str","dex","int", - "edge","bash","pole","thrown","bow","def", - "mage","priest","lore","alch","item", - "trap","lock","assassin","poison","luck" -}; short spell_w_cast[2][62] = { {0,1,1,1,1,1,3,4,1,2, 1,1,1,1,1,1,4,1,4,1, 2,1,1,0,1,1,4,1,1,0, 1,1,1,2,4,1,1,1, 2,1,1,2,4,4,1,1, 1,1,1,1,4,4,1,5, 1,4,1,4,4,4,4,1}, @@ -182,14 +158,6 @@ short spell_index[38] = {38,39,40,41,42,43,44,45,90,90,46,47,48,49,50,51,52,53,9 // Says which buttons hit which spells on second spell page, 90 means no button bool can_choose_caster; -// Variables for spending xp -bool talk_done = false; -long val_for_text; -bool keep_change = false; -short store_skills[20],store_h,store_sp,i,store_skp,which_skill; -long store_g; -short store_train_mode,store_train_pc; - // Dialog vars short store_mage_store ; short store_priest_store ; @@ -975,278 +943,6 @@ void drain_pc(short which_pc,short how_much) } } -// TODO: This dialog needs some kind of context system really badly to avoid the rampant globals -// MARK: Start spend XP dialog -static void do_xp_keep(short pc_num,short mode) -{ - for (i = 0; i < 20; i++) - univ.party[pc_num].skills[i] = store_skills[i]; - univ.party[pc_num].cur_health += store_h - univ.party[pc_num].max_health; - univ.party[pc_num].max_health = store_h; - univ.party[pc_num].cur_sp += store_sp - univ.party[pc_num].max_sp; - univ.party[pc_num].max_sp = store_sp; - if (mode == 1) - univ.party.gold = store_g; - univ.party[pc_num].skill_pts = store_skp; - -} - -static void draw_xp_skills(cDialog& me) -{ - short i; - // TODO: Wouldn't it make more sense for it to be red when you can't buy the skill rather than red when you can? - for (i = 0; i < 19; i++) { - cControl& cur = me[skill_ids[i]]; - if ((store_skp >= skill_cost[i]) && (store_g >= skill_g_cost[i])) - cur.setColour(sf::Color::Red); - else cur.setColour(me.getDefTextClr()); - cur.setTextToNum(store_skills[i]); - } - - cControl& sp = me["sp"]; - cControl& hp = me["hp"]; - if ((store_skp >= 1) && (store_g >= 10)) - hp.setColour(sf::Color::Red); - else hp.setColour(me.getDefTextClr()); - hp.setTextToNum(store_h); - if ((store_skp >= 1) && (store_g >= 15)) - sp.setColour(sf::Color::Red); - else sp.setColour(me.getDefTextClr()); - sp.setTextToNum(store_sp); -} - -static void update_gold_skills(cDialog& me) { - me["gold"].setTextToNum(((store_train_mode == 0) ? 0 : store_g)); - me["skp"].setTextToNum(store_skp); -} - - -static void do_xp_draw(cDialog& me) - -{ - - char get_text[256]; - short mode,pc_num; - - mode = store_train_mode; - pc_num = store_train_pc; - if (mode == 0) { - if (univ.party[pc_num].main_status == 1) - sprintf((char *) get_text, "%s",(char *) univ.party[pc_num].name.c_str()); - else sprintf((char *) get_text, "New PC"); - } - else sprintf((char *) get_text, "%s",(char *) univ.party[pc_num].name.c_str()); - - me["recipient"].setText(get_text); - - for (i = 0; i < 20; i++) - store_skills[i] = univ.party[pc_num].skills[i]; - store_h = univ.party[pc_num].max_health; - store_sp = univ.party[pc_num].max_sp; - store_g = (mode == 0) ? 20000 : univ.party.gold; - store_skp = univ.party[pc_num].skill_pts; - - draw_xp_skills(me); - - - update_gold_skills(me); -} - -static bool spend_xp_navigate_filter(cDialog& me, std::string item_hit, eKeyMod mods) -{ - short mode,pc_num; - bool talk_done = false; - - mode = store_train_mode; - pc_num = store_train_pc; - - if(item_hit == "cancel") { - if ((mode == 0) && (univ.party[pc_num].main_status < MAIN_STATUS_ABSENT)) - univ.party[pc_num].main_status = MAIN_STATUS_ABSENT; - me.setResult(false); - talk_done = true; - } else if(item_hit == "help") { - univ.party.help_received[10] = 0; - give_help(210,11,me); - } else if(item_hit == "keep") { - do_xp_keep(pc_num,mode); - me.setResult(true); - talk_done = true; - } else if(item_hit == "left") { - // TODO: Try not forcing a commit when using the arrows? - if (mode != 0) { - do_xp_keep(pc_num,mode); - do { - pc_num = (pc_num == 0) ? 5 : pc_num - 1; - } while (univ.party[pc_num].main_status != 1); - store_train_pc = pc_num; - do_xp_draw(me); - } // else TODO: Play an error sound here - } else if(item_hit == "right") { - // TODO: If they don't work in mode 0, why are they visible? - if (mode != 0) { - do_xp_keep(pc_num,mode); - do { - pc_num = (pc_num == 5) ? 0 : pc_num + 1; - } while (univ.party[pc_num].main_status != 1); - store_train_pc = pc_num; - do_xp_draw(me); - } // else TODO: Play an error sound here - } - store_train_pc = pc_num; - if (talk_done == true) { - me.toast(); - } - return true; -} - -static bool spend_xp_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) { - short mode = store_train_mode, pc_num = store_train_pc; - if(item_hit.substr(0,2) == "hp") { - if(mod_contains(mods, mod_alt)) { - cStrDlog aboutHP(get_str("help",63),"","About Health",24,PIC_DLOG,&me); - aboutHP.setSound(57); - aboutHP.show(); - } else if (((store_h >= 250) && (item_hit[3] == 'p')) || - ((store_h == univ.party[pc_num].max_health) && (item_hit[3] == 'm') && (mode == 1)) || - ((store_h == 6) && (item_hit[3] == 'm') && (mode == 0))) - ; // TODO: Play an error sound here - else if(item_hit == "hp-m") { - store_g += 10; - store_h -= 2; - store_skp += 1; - } - else { - if ((store_g < 10) || (store_skp < 1)) { - if (store_g < 10) - give_help(24,0,me); - else give_help(25,0,me); - } - else { - store_g -= 10; - store_h += 2; - store_skp -= 1; - } - } - - update_gold_skills(me); - me["hp"].setTextToNum(store_h); - draw_xp_skills(me); - - } else if(item_hit.substr(0,2) == "sp") { - if(mod_contains(mods, mod_alt)) { - cStrDlog aboutSP(get_str("help",64),"","About Spell Points",24,PIC_DLOG,&me); - aboutSP.setSound(57); - aboutSP.show(); - } else if (((store_sp >= 150) && (item_hit[3] == 'p')) || - ((store_sp == univ.party[pc_num].max_sp) && (item_hit[3] == 'm') && (mode == 1)) || - ((store_sp == 0) && (item_hit[3] == 'm') && (mode == 0))) - ; // TODO: Play an error sound here - else if(item_hit == "sp-m") { - store_g += 15; - store_sp -= 1; - store_skp += 1; - } - else { - if ((store_g < 15) || (store_skp < 1)) { - if (store_g < 15) - give_help(24,0,me); - else give_help(25,0,me); - } - else { - store_sp += 1; - store_g -= 15; - store_skp -= 1; - } - } - - update_gold_skills(me); - me["sp"].setTextToNum(store_sp); - draw_xp_skills(me); - } else { - for(int i = 0; i < 19; i++) { - int n = strlen(skill_ids[i]); - if(item_hit.length() < n + 2) continue; - if(item_hit.substr(0, item_hit.length() - 2) == skill_ids[i]) { - which_skill = i; - break; - } - } - if(mod_contains(mods, mod_alt)) display_skills(which_skill,&me); - else { - char dir = item_hit[item_hit.length() - 1]; - - if (((store_skills[which_skill] >= skill_max[which_skill]) && (dir == 'p')) || - ((store_skills[which_skill] == univ.party[pc_num].skills[which_skill]) && (dir == 'm') && (mode == 1)) || - ((store_skills[which_skill] == 0) && (dir == 'm') && (mode == 0) && (which_skill > 2)) || - ((store_skills[which_skill] == 1) && (dir == 'm') && (mode == 0) && (which_skill <= 2))) - ; // TODO: Play an error sound here - else { - if(dir == 'm') { - store_g += skill_g_cost[which_skill]; - store_skills[which_skill] -= 1; - store_skp += skill_cost[which_skill]; - } - else { - if ((store_g < skill_g_cost[which_skill]) || (store_skp < skill_cost[which_skill])) { - if (store_g < skill_g_cost[which_skill]) - give_help(24,0,me); - else give_help(25,0,me); - } - else { - store_skills[which_skill] += 1; - store_g -= skill_g_cost[which_skill]; - store_skp -= skill_cost[which_skill]; - } - } - - update_gold_skills(me); - me[skill_ids[which_skill]].setTextToNum(store_skills[which_skill]); - draw_xp_skills(me); - } - } - } - return true; -} - -bool spend_xp(short pc_num, short mode, cDialog* parent) -//short mode; // 0 - create 1 - train -// returns 1 if cancelled -{ - store_train_pc = pc_num; - store_train_mode = mode; - - make_cursor_sword(); - - cDialog xpDlog("spend-xp.xml",parent); - xpDlog.addLabelFor("hp","Health (1/10)",LABEL_LEFT,75,true); - xpDlog.addLabelFor("sp","Spell Pts. (1/15)",LABEL_LEFT,75,true); - std::string minus = "-m", plus = "-p"; - for (i = 54; i < 73; i++) { - std::ostringstream sout; - sout << get_str("skills",1 + 2 * (i - 54)) << ' ' << '('; - sout << skill_cost[i - 54] << '/' << skill_g_cost[i - 54] << ')'; - xpDlog.addLabelFor(skill_ids[i - 54],sout.str(),LABEL_LEFT,(i < 63) ? 75 : 69,true); - xpDlog[skill_ids[i - 54] + minus].attachClickHandler(spend_xp_event_filter); - xpDlog[skill_ids[i - 54] + plus].attachClickHandler(spend_xp_event_filter); - } - do_xp_draw(xpDlog); - - xpDlog.attachClickHandlers(spend_xp_navigate_filter,{"keep","cancel","left","right","help"}); - xpDlog.attachClickHandlers(spend_xp_event_filter,{"sp-m","sp-p","hp-m","hp-p"}); - - if (univ.party.help_received[10] == 0) { - // TODO: Is an initial draw even needed? -// cd_initial_draw(1010); - give_help(10,11,xpDlog); - } - - xpDlog.run(); - - return xpDlog.getResult(); -} - - short mage_lore_total() { short total = 0,i; @@ -2316,7 +2012,7 @@ static void draw_spell_info(cDialog& me) if (((store_situation == 0) && (store_mage == 70)) || ((store_situation == 1) && (store_priest == 70))) { // No spell selected - for (i = 0; i < 6; i++) { + for(int i = 0; i < 6; i++) { std::string id = "target" + boost::lexical_cast(i + 1); me[id].hide(); } @@ -2324,7 +2020,7 @@ static void draw_spell_info(cDialog& me) } else { // Spell selected - for (i = 0; i < 6; i++) { + for(int i = 0; i < 6; i++) { std::string id = "target" + boost::lexical_cast(i + 1); // TODO: Make this thing an enum switch (((store_situation == 0) ? @@ -2562,7 +2258,7 @@ static bool pick_spell_select_led(cDialog& me, std::string id, eKeyMod mods) { static const char*const bad_spell = " Spell not available."; short item_hit = id[id.length() - 1] - '1'; if(mod_contains(mods, mod_alt)) { - i = (on_which_spell_page == 0) ? item_hit : spell_index[item_hit]; + int i = (on_which_spell_page == 0) ? item_hit : spell_index[item_hit]; display_spells(store_situation,i,&me); } else if(dynamic_cast(me[id]).getState() == led_off) { @@ -2673,7 +2369,8 @@ short pick_spell(short pc_num,short type,short situation) // 70 - no spell OW s if (pc_num == 6) { // See if can keep same caster can_choose_caster = true; if (pc_can_cast_spell(pc_casting,type,type) == false) { - for (i = 0; i < 6; i++) + int i; + for(i = 0; i < 6; i++) if (pc_can_cast_spell(i,type,type)) { pc_casting = i; i = 500; @@ -2747,7 +2444,7 @@ short pick_spell(short pc_num,short type,short situation) // 70 - no spell OW s castSpell.attachClickHandlers(pick_spell_event_filter, {"cancel", "cast", "other", "help"}); dynamic_cast(castSpell["pic"]).setPict(14 + type,PIC_DLOG); - for(i = 0; i < 38; i++) { + for(int i = 0; i < 38; i++) { std::string id = "spell" + boost::lexical_cast(i + 1); if (i > 25) castSpell[id].attachKey({false, static_cast('a' + i - 26), mod_shift}); @@ -2994,7 +2691,7 @@ bool pick_pc_graphic(short pc_num,short mode,cDialog* parent) return choice != 36; } -static bool pc_name_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) +static bool pc_name_event_filter(cDialog& me, std::string item_hit, eKeyMod mods, short store_train_pc) { std::string pcName = me["name"].getText(); @@ -3013,13 +2710,12 @@ bool pick_pc_name(short pc_num,cDialog* parent) //town_num; // Will be 0 - 200 for town, 200 - 290 for outdoors //short sign_type; // terrain type { - store_train_pc = pc_num; - + using namespace std::placeholders; make_cursor_sword(); cDialog pcPickName("pick-pc-name.xml", parent); - pcPickName["name"].setText(univ.party[store_train_pc].name); - pcPickName["okay"].attachClickHandler(pc_name_event_filter); + pcPickName["name"].setText(univ.party[pc_num].name); + pcPickName["okay"].attachClickHandler(std::bind(pc_name_event_filter, _1, _2, _3, pc_num)); pcPickName.run(); diff --git a/osx/boe.party.h b/osx/boe.party.h index 1347cf6b..07802538 100644 --- a/osx/boe.party.h +++ b/osx/boe.party.h @@ -20,7 +20,6 @@ void restore_sp_party(short amt); void award_party_xp(short amt); void award_xp(short pc_num,short amt); void drain_pc(short which_pc,short how_much); -bool spend_xp(short pc_num, short mode, cDialog* parent); short mage_lore_total(); bool poison_weapon( short pc_num, short how_much,short safe); bool is_weapon(short pc_num,short item); @@ -61,3 +60,5 @@ short woodsman_present(); void print_spell_cast(short spell_num,short which); void put_party_in_scen(std::string scen_name); +// This is defined in pc.editors.cpp since it is also used by the character editor +bool spend_xp(short pc_num, short mode, cDialog* parent); diff --git a/osx/boe.specials.cpp b/osx/boe.specials.cpp index 11346716..17b8e015 100644 --- a/osx/boe.specials.cpp +++ b/osx/boe.specials.cpp @@ -62,9 +62,7 @@ short store_item_spell_level = 10; // global vbalues for when processing special encounters short current_pc_picked_in_spec_enc = -1; // pc that's been selected, -1 if none -short skill_max[20] = { - 20,20,20,20,20,20,20,20,20,7, - 7,20,20,10,20,20,20,20,20}; +extern short skill_max[20];; location store_special_loc; bool special_in_progress = false; short spec_str_offset[3] = {160,10,0}; diff --git a/osx/classes/scenario.h b/osx/classes/scenario.h index fe17bd84..56f65209 100644 --- a/osx/classes/scenario.h +++ b/osx/classes/scenario.h @@ -12,6 +12,12 @@ #include #include #include "terrain.h" +#include "monster.h" +#include "vehicle.h" +#include "item.h" +#include "special.h" +#include "outdoors.h" +#include "town.h" namespace fs = boost::filesystem; // TODO: Centralize this namespace alias? diff --git a/osx/dialogxml/button.cpp b/osx/dialogxml/button.cpp index 03d0f106..b96d1386 100644 --- a/osx/dialogxml/button.cpp +++ b/osx/dialogxml/button.cpp @@ -80,9 +80,8 @@ void cButton::draw(){ // Push button string should be centred below the button // Others may need adjustments too, not sure TEXT.colour = sf::Color::Black; - // TODO: When should we pass 1 as the second parameter? // TODO: How is it supposed to know it's a default button when this fact is stored in the dialog, not the button? - if(key.spec && key.k == key_enter) drawFrame(2,0); // frame default button, to provide a visual cue that it's the default + if(key.spec && key.k == key_enter) drawFrame(2,frameStyle); // frame default button, to provide a visual cue that it's the default }else{ tileImage(*inWindow,frame,bg_gworld,bg[parent->bg]); } @@ -90,6 +89,7 @@ void cButton::draw(){ void cButton::setFormat(eFormat prop, short val) throw(xUnsupportedProp){ if(prop == TXT_WRAP) wrapLabel = val; + else if(prop == TXT_FRAMESTYLE) frameStyle = val; else throw xUnsupportedProp(prop); } diff --git a/osx/dialogxml/control.cpp b/osx/dialogxml/control.cpp index 253756e2..0b70cc3f 100644 --- a/osx/dialogxml/control.cpp +++ b/osx/dialogxml/control.cpp @@ -57,12 +57,15 @@ xUnsupportedProp::~xUnsupportedProp() throw(){ } const char* xUnsupportedProp::what() throw(){ if(msg == NULL){ - msg = new char[60]; + msg = new char[62]; std::string s; switch(whichProp){ case TXT_FRAME: s = "TXT_FRAME"; break; + case TXT_FRAMESTYLE: + s = "TXT_FRAMESTYLE"; + break; case TXT_FONT: s = "TXT_FONT"; break; @@ -258,9 +261,9 @@ void cControl::detachKey(){ this->key.c = 0; } -cControl::cControl(eControlType t, cDialog& p) : parent(&p), inWindow(&p.win), type(t), visible(true), key({false, 0, mod_none}) {} +cControl::cControl(eControlType t, cDialog& p) : parent(&p), inWindow(&p.win), type(t), visible(true), key({false, 0, mod_none}), frameStyle(0) {} -cControl::cControl(eControlType t, sf::RenderWindow& p) : parent(NULL), inWindow(&p), type(t), visible(true), key({false, 0, mod_none}) {} +cControl::cControl(eControlType t, sf::RenderWindow& p) : parent(NULL), inWindow(&p), type(t), visible(true), key({false, 0, mod_none}), frameStyle(0) {} bool cControl::triggerClickHandler(cDialog& __attribute__((unused)), std::string __attribute__((unused)), eKeyMod __attribute__((unused)), location __attribute__((unused))){ return true; diff --git a/osx/dialogxml/control.h b/osx/dialogxml/control.h index 25a797e7..d9319b51 100644 --- a/osx/dialogxml/control.h +++ b/osx/dialogxml/control.h @@ -28,6 +28,7 @@ enum eFormat { TXT_FONT, TXT_SIZE, TXT_WRAP, + TXT_FRAMESTYLE, }; enum eControlType { @@ -108,6 +109,7 @@ protected: std::string lbl; bool visible, depressed = false; // depressed is only applicable for clickable controls RECT frame; + int frameStyle; cKey key; static bool foundSilom(); static std::string font_nums[4]; diff --git a/osx/dialogxml/dialog.cpp b/osx/dialogxml/dialog.cpp index a909cb8b..03c09511 100644 --- a/osx/dialogxml/dialog.cpp +++ b/osx/dialogxml/dialog.cpp @@ -27,6 +27,7 @@ extern sf::RenderWindow mainPtr; extern sf::Texture bg_gworld; extern bool play_sounds; const short cDialog::BG_DARK = 5, cDialog::BG_LIGHT = 16; +short cDialog::defaultBackground = cDialog::BG_DARK; static std::string generateRandomString(){ // Not bothering to seed, because it doesn't actually matter if it's truly random. @@ -209,7 +210,7 @@ template<> pair cDialog::parse(Element& who /*text*/){ int width = 0, height = 0; bool foundTop = false, foundLeft = false; // top and left are required attributes RECT frame; - p.second = new cTextMsg(this); + p.second = new cTextMsg(*this); if(bg == BG_DARK) p.second->setColour(sf::Color::White); for(attr = attr.begin(&who); attr != attr.end(); attr++){ attr->GetName(&name); @@ -745,7 +746,7 @@ cDialog::cDialog(std::string path, cDialog* p) : parent(p) { extern fs::path progDir; void cDialog::loadFromFile(std::string path){ - bg = BG_DARK; // default is dark background + bg = defaultBackground; fname = path; fs::path cPath = progDir/"data"/"dialogs"/path; try{ @@ -884,7 +885,6 @@ bool cDialog::remove(std::string key){ return true; } -extern char keyToChar(sf::Keyboard::Key key, bool isShift); void cDialog::run(){ // We always need the cursor when we're in a dialog mainPtr.setMouseCursorVisible(true); @@ -1135,7 +1135,7 @@ bool cDialog::addLabelFor(std::string key, std::string label, eLabelPos where, s try { labelCtrl = &this->getControl(key); } catch(std::invalid_argument x) { - labelCtrl = new cTextMsg(this); + labelCtrl = new cTextMsg(*this); } labelCtrl->setText(label); labelCtrl->setFormat(TXT_FONT, bold ? SILOM : GENEVA); diff --git a/osx/dialogxml/dialog.h b/osx/dialogxml/dialog.h index 175f34b2..fb39f6cf 100644 --- a/osx/dialogxml/dialog.h +++ b/osx/dialogxml/dialog.h @@ -43,6 +43,7 @@ public: static void init(); static bool noAction(cDialog&,std::string,eKeyMod) {return true;} static const short BG_LIGHT, BG_DARK; + static short defaultBackground; explicit cDialog(cDialog* p = NULL); // dialog with no items explicit cDialog(std::string path); // cd_create_dialog cDialog(std::string path,cDialog* p); // cd_create_dialog_parent_num diff --git a/osx/dialogxml/dlogutil.cpp b/osx/dialogxml/dlogutil.cpp index 2482aef8..9b7d21df 100644 --- a/osx/dialogxml/dlogutil.cpp +++ b/osx/dialogxml/dlogutil.cpp @@ -281,7 +281,7 @@ void cThreeChoice::init_strings(std::vector& strings, unsigned shor sout << "str" << j + 1; str_height = ((string_length(strings[j]) + 60) / str_width) * 12 + 16; cur_text_rect.bottom = cur_text_rect.top + str_height; - cTextMsg* str = new cTextMsg(me); + 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; diff --git a/osx/dialogxml/message.cpp b/osx/dialogxml/message.cpp index f0d1cecb..436c05b0 100644 --- a/osx/dialogxml/message.cpp +++ b/osx/dialogxml/message.cpp @@ -36,6 +36,9 @@ void cTextMsg::setFormat(eFormat prop, short val) throw(xUnsupportedProp){ case TXT_FRAME: drawFramed = val; break; + case TXT_FRAMESTYLE: + frameStyle = val; + break; case TXT_SIZE: textSize = val; break; @@ -68,12 +71,21 @@ short cTextMsg::getFormat(eFormat prop) throw(xUnsupportedProp){ return 0; } -cTextMsg::cTextMsg(cDialog* parent) : - cControl(CTRL_TEXT,*parent), +cTextMsg::cTextMsg(cDialog& parent) : + cControl(CTRL_TEXT,parent), drawFramed(false), textFont(SILOM), textSize(10), - color(parent->defTextClr), + color(parent.defTextClr), + clickable(false), + fromList("none") {} + +cTextMsg::cTextMsg(sf::RenderWindow& parent) : + cControl(CTRL_TEXT,parent), + drawFramed(false), + textFont(SILOM), + textSize(10), + color(cDialog::defaultBackground == cDialog::BG_DARK ? sf::Color::White : sf::Color::Black), clickable(false), fromList("none") {} @@ -91,8 +103,7 @@ void cTextMsg::draw(){ if(textFont == SILOM && !foundSilom()) TEXT.style = sf::Text::Bold; else TEXT.style = sf::Text::Regular; TEXT.pointSize = textSize; - // TODO: When should we pass 1 as the second parameter? - if(drawFramed) drawFrame(2,0); + if(drawFramed) drawFrame(2,frameStyle); sf::Color draw_color = color; if(clickable && depressed){ draw_color.r = 256 - draw_color.r; diff --git a/osx/dialogxml/message.h b/osx/dialogxml/message.h index d0603f58..8b28fdf4 100644 --- a/osx/dialogxml/message.h +++ b/osx/dialogxml/message.h @@ -23,7 +23,8 @@ public: short getFormat(eFormat prop) throw(xUnsupportedProp); void setColour(sf::Color clr) throw(xUnsupportedProp); sf::Color getColour() throw(xUnsupportedProp); - explicit cTextMsg(cDialog* parent); + explicit cTextMsg(cDialog& parent); + explicit cTextMsg(sf::RenderWindow& parent); bool isClickable(); virtual ~cTextMsg(); void draw(); diff --git a/osx/dialogxml/pict.cpp b/osx/dialogxml/pict.cpp index 750a845b..bf4d3697 100644 --- a/osx/dialogxml/pict.cpp +++ b/osx/dialogxml/pict.cpp @@ -87,6 +87,7 @@ bool cPict::triggerClickHandler(cDialog& me, std::string id, eKeyMod mods, locat void cPict::setFormat(eFormat prop, short val) throw(xUnsupportedProp){ if(prop == TXT_FRAME) drawFramed = val; + else if(prop == TXT_FRAMESTYLE) frameStyle = val; else throw xUnsupportedProp(prop); } @@ -484,8 +485,7 @@ void cPict::draw(){ } (this->*drawPict()[picType])(picNum,rect); - // TODO: When should we pass 1 as the second parameter? - if(drawFramed) drawFrame(2,0); + if(drawFramed) drawFrame(2,frameStyle); } void cPict::drawPresetTer(short num, RECT to_rect){ diff --git a/osx/pcedit/bladespced.rsrc b/osx/pcedit/bladespced.rsrc index d491d1af..de625dfa 100644 Binary files a/osx/pcedit/bladespced.rsrc and b/osx/pcedit/bladespced.rsrc differ diff --git a/osx/pcedit/pc.action.cpp b/osx/pcedit/pc.action.cpp index eb4737ec..afbb491d 100644 --- a/osx/pcedit/pc.action.cpp +++ b/osx/pcedit/pc.action.cpp @@ -1,5 +1,4 @@ -#include #include #include "pc.graphics.h" @@ -10,10 +9,9 @@ #include "pc.action.h" #include "graphtool.h" #include "soundtool.h" -#include "dlgtool.h" #include "mathutil.h" -#include "dlgconsts.h" -#include "dlgutil.h" +#include "dlogutil.h" +#include /* Adventure globals */ //extern party_record_type party; @@ -31,67 +29,48 @@ extern cUniverse univ; //extern bool ed_reg; //extern long ed_flag,ed_key; -extern WindowPtr mainPtr; +extern sf::RenderWindow mainPtr; extern bool file_in_mem; -extern short dialog_answer; //extern long register_flag; -extern GWorldPtr pc_gworld; -extern bool diff_depth_ok,save_blocked; +extern sf::Texture pc_gworld; +extern bool diff_depth_ok; short which_pc_displayed,store_pc_trait_mode,store_which_to_edit; extern short current_active_pc; -Str255 empty_string = "\p "; -extern Rect pc_area_buttons[6][4] ; // 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 - -extern Rect pc_info_rect; -extern Rect name_rect; +char empty_string[256] = " "; +extern RECT pc_area_buttons[6][4] ; // 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 - +extern RECT pc_info_rect; +extern RECT name_rect; -extern Rect pc_race_rect; -extern Rect edit_rect[5][2]; +extern RECT pc_race_rect; +extern RECT edit_rect[5][2]; -short store_trait_mode,store_train_pc; -cPlayer *store_xp_pc; +short store_trait_mode; -// Variables for spending xp - bool talk_done = false; - long val_for_text; - bool keep_change = false; - short store_skills[20],store_h,store_sp,i,which_skill,store_skp = 10000,store_g = 10000; - - -short skill_cost[20] = {3,3,3,2,2,2, 1,2,2,6, - 5, 1,2,4,2,1, 4,2,5,0}; -short skill_max[20] = {20,20,20,20,20,20,20,20,20,7, - 7,20,20,10,20,20,20,20,20}; -short skill_g_cost[20] = {50,50,50,40,40,40,30,50,40,250, - 250,25,100,200,30,20,100,80,0,0}; -short skill_bonus[21] = {-3,-3,-2,-1,0,0,1,1,1,2, - 2,2,3,3,3,3,4,4,4,5,5}; - -//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 - -bool handle_action(EventRecord event,short mode) +//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 - +bool handle_action(sf::Event event,short mode) //short mode; // ignore, { short i; - Point the_point; + location the_point; short choice = 4; bool to_return = false; - the_point = event.where; - GlobalToLocal(&the_point); + the_point = {event.mouseButton.x, event.mouseButton.y}; if (file_in_mem == false) return false; for (i = 0; i < 6; i++) - if ((PtInRect(the_point,&pc_area_buttons[i][0]) == true) && + if((the_point.in(pc_area_buttons[i][0])) && (univ.party[i].main_status > 0)) { do_button_action(0,i); current_active_pc = i; @@ -99,25 +78,21 @@ bool handle_action(EventRecord event,short mode) draw_items(1); } for (i = 0; i < 5; i++) - if ((PtInRect(the_point,&edit_rect[i][0]) == true) && + if((the_point.in(edit_rect[i][0])) && (univ.party[current_active_pc].main_status > 0)) { do_button_action(0,i + 10); - if (save_blocked == false) - if ((choice = FCD(904,0)) == 1) - return to_return; - else save_blocked = true; switch(i) { case 0: - display_pc(current_active_pc,0,0); + display_pc(current_active_pc,0,NULL); break; case 1: - display_pc(current_active_pc,1,0); + display_pc(current_active_pc,1,NULL); break; case 2: - pick_race_abil(&univ.party[current_active_pc],0,0); + pick_race_abil(&univ.party[current_active_pc],0,NULL); break; case 3: - spend_xp(current_active_pc,1,0); + spend_xp(current_active_pc,1,NULL); break; case 4: edit_xp(&univ.party[current_active_pc]); @@ -126,14 +101,14 @@ bool handle_action(EventRecord event,short mode) } } for (i = 0; i < 24; i++) - if ((PtInRect(the_point,&item_string_rects[i][1]) == true) && // drop item + if((the_point.in(item_string_rects[i][1])) && // drop item (univ.party[current_active_pc].items[i].variety > 0)) { // variety = 0 no item in slot/ non 0 item exists flash_rect(item_string_rects[i][1]); take_item(current_active_pc,i); draw_items(1); } for (i = 0; i < 24; i++) - if ((PtInRect(the_point,&item_string_rects[i][2]) == true) && // identify item + if((the_point.in(item_string_rects[i][2])) && // identify item (univ.party[current_active_pc].items[i].variety > 0)) { flash_rect(item_string_rects[i][2]); univ.party[current_active_pc].items[i].ident = true; @@ -143,24 +118,21 @@ bool handle_action(EventRecord event,short mode) return to_return; } -void flash_rect(Rect to_flash) +void flash_rect(RECT to_flash) { unsigned long dummy; - InvertRect (&to_flash); + // TODO: Think of a good way to do this + //InvertRect (&to_flash); play_sound(37); - Delay(5,&dummy); - InvertRect (&to_flash); + sf::sleep(time_in_ticks(5)); } -void edit_gold_or_food_event_filter (short item_hit) +static bool get_num_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) { - Str255 get_text; - - cd_retrieve_text_edit_str((store_which_to_edit == 0) ? 1012 : 947,2,(char *) get_text); - dialog_answer = 0; - sscanf((char *) get_text,"%d",&dialog_answer); - toast_dialog(); + me.toast(); + me.setResult(me["number"].getTextAsNum()); + return true; } void edit_gold_or_food(short which_to_edit) @@ -168,481 +140,168 @@ void edit_gold_or_food(short which_to_edit) { short item_hit; - Str255 sign_text; + char sign_text[256]; location view_loc; store_which_to_edit = which_to_edit; make_cursor_sword(); - cd_create_dialog((which_to_edit == 0) ? 1012 : 947, mainPtr); - sprintf((char *) sign_text,"%d",(short) ((which_to_edit == 0) ? univ.party.gold : univ.party.food)); - cd_set_text_edit_str((which_to_edit == 0) ? 1012 : 947,2,(char *) sign_text); + cDialog dlog("get-num.xml"); + dlog["okay"].attachClickHandler(get_num_event_filter); + if(which_to_edit == 0) + dlog["prompt"].setText("How much gold do you want?"); + else dlog["prompt"].setText("How much food do you want?"); + dlog["number"].setTextToNum((which_to_edit == 0) ? univ.party.gold : univ.party.food); - item_hit = cd_run_dialog(); - cd_kill_dialog((which_to_edit == 0) ? 1012 : 947); - dialog_answer = minmax(0,25000,dialog_answer); + dlog.run(); + int dialog_answer = minmax(0,25000,dlog.getResult()); if (which_to_edit == 0) univ.party.gold = dialog_answer; else univ.party.food = dialog_answer; } -void edit_day_event_filter (short item_hit) -{ - Str255 get_text; - - cd_retrieve_text_edit_str(917,2,(char *) get_text); - dialog_answer = 0; - sscanf((char *) get_text,"%d",&dialog_answer); - toast_dialog(); -} - void edit_day() { short item_hit; - Str255 sign_text; + char sign_text[256]; location view_loc; make_cursor_sword(); - cd_create_dialog(917,mainPtr); + cDialog dlog("edit-day.xml"); + dlog["okay"].attachClickHandler(get_num_event_filter); - sprintf((char *) sign_text,"%d",(short) ( ((univ.party.age) / 3700) + 1)); - cd_set_text_edit_str(917,2,(char *) sign_text); + dlog["number"].setTextToNum(((univ.party.age) / 3700) + 1); - item_hit = cd_run_dialog(); + dlog.run(); - cd_kill_dialog(917); - - dialog_answer = minmax(0,500,dialog_answer); + long long dialog_answer = minmax(0,500,dlog.getResult()); univ.party.age = (long long) (3700) * (long long) (dialog_answer); } - -void put_pc_graphics() +void combine_things(short pc_num) { - short i; - - for (i = 3; i < 65; i++) { - if (((store_trait_mode == 0) && (univ.party[which_pc_displayed].mage_spells[i - 3] == true)) || - ((store_trait_mode == 1) && (univ.party[which_pc_displayed].priest_spells[i - 3] == true))) - cd_set_led(991,i,1); - else cd_set_led(991,i,0); - } - - cd_set_item_text(991,69,univ.party[which_pc_displayed].name.c_str()); -} -void display_pc_event_filter (short item_hit) -{ - short pc_num; - - pc_num = which_pc_displayed; - switch (item_hit) { - case 1: case 65: - toast_dialog(); - break; - - case 66: - do { - pc_num = (pc_num == 0) ? 5 : pc_num - 1; - } while (univ.party[pc_num].main_status == 0); - which_pc_displayed = pc_num; - put_pc_graphics(); - break; - case 67: - do { - pc_num = (pc_num == 5) ? 0 : pc_num + 1; - } while (univ.party[pc_num].main_status == 0); - which_pc_displayed = pc_num; - put_pc_graphics(); - break; - - default: - if (store_trait_mode == 0) - univ.party[which_pc_displayed].mage_spells[item_hit - 3] = - 1 - univ.party[which_pc_displayed].mage_spells[item_hit - 3]; - else - univ.party[which_pc_displayed].priest_spells[item_hit - 3] = - 1 - univ.party[which_pc_displayed].priest_spells[item_hit - 3]; - put_pc_graphics(); - break; - } -} - -void display_pc(short pc_num,short mode,short parent) -{ - short i,item_hit; - Str255 label_str; + short i,j,test; - if (univ.party[pc_num].main_status == 0) { - for (pc_num = 0; pc_num < 6; pc_num++) - if (univ.party[pc_num].main_status == 1) - break; - } - which_pc_displayed = pc_num; - store_trait_mode = mode; - - make_cursor_sword(); - - cd_create_dialog_parent_num(991,0); - - for (i = 3; i < 65; i++) { - get_str(label_str,(mode == 0) ? 7 : 8,(i - 3) * 2 + 1); - cd_add_label(991,i,(char *)label_str,46); - } - put_pc_graphics(); - - cd_set_pict(991,2,14 + mode,PICT_DLG); - - item_hit = cd_run_dialog(); - cd_kill_dialog(991); -} - - -void display_alchemy_event_filter (short item_hit) -{ - short i; - - switch (item_hit) { - case 1: case 3: - toast_dialog(); - break; - default: - univ.party.alchemy[item_hit - 4] = 1 - univ.party.alchemy[item_hit - 4]; - break; - - } - for (i = 0; i < 20; i++) { - if (univ.party.alchemy[i] > 0) - cd_set_led(996,i + 4,1); - else cd_set_led(996,i + 4,0); - } -} - -void display_alchemy() -{ - short i,item_hit; - char *alch_names[] = {"Weak Curing Potion (1)","Weak Healing Potion (1)","Weak Poison (1)", - "Weak Speed Potion (3)","Medium Poison (3)", - "Medium Heal Potion (4)","Strong Curing (5)","Medium Speed Potion (5)", - "Graymold Salve (7)","Weak Power Potion (9)", - "Potion of Clarity (9)","Strong Poison (10)","Strong Heal Potion (12)","Killer Poison (12)", - "Resurrection Balm (9)","Medium Power Potion (14)","Knowledge Brew (19)", - "Strong Strength (10)","Bliss (18)","Strong Power (20)" - }; - - make_cursor_sword(); - - cd_create_dialog_parent_num(996,0); - - - for (i = 0; i < 20; i++) { - cd_add_label(996,i + 4,alch_names[i],1083); - if (univ.party.alchemy[i] > 0) - cd_set_led(996,i + 4,1); - else cd_set_led(996,i + 4,0); - } - - item_hit = cd_run_dialog(); - cd_kill_dialog(996); - untoast_dialog(); - -} - -void do_xp_keep(short pc_num,short mode) -{ - for (i = 0; i < 20; i++) - univ.party[pc_num].skills[i] = store_skills[i]; - univ.party[pc_num].cur_health += store_h - univ.party[pc_num].max_health; - univ.party[pc_num].max_health = store_h; - univ.party[pc_num].cur_sp += store_sp - univ.party[pc_num].max_sp; - univ.party[pc_num].max_sp = store_sp; - -} - -void draw_xp_skills() -{ - short i; - for (i = 0; i < 19; i++) { - if ((store_skp >= skill_cost[i]) && (store_g >= skill_g_cost[i])) - cd_text_frame(1010,54 + i,11); - else cd_text_frame(1010,54 + i,1); - cd_set_item_num(1010,54 + i,store_skills[i]); - } - - if ((store_skp >= 1) && (store_g >= 10)) - cd_text_frame(1010,52,11); - else cd_text_frame(1010,52,1); - cd_set_item_num(1010,52,store_h); - if ((store_skp >= 1) && (store_g >= 15)) - cd_text_frame(1010,53,11); - else cd_text_frame(1010,53,1); - cd_set_item_num(1010,53,store_sp); -} - - -void do_xp_draw(){ - char get_text[256]; - short pc_num; - - pc_num = store_train_pc; - - sprintf((char *) get_text, "%s",(char *) univ.party[pc_num].name.c_str()); - - - cd_set_item_text (1010, 51,get_text); - - for (i = 0; i < 20; i++) - store_skills[i] = univ.party[pc_num].skills[i]; - store_h = univ.party[pc_num].max_health; - store_sp = univ.party[pc_num].max_sp; - store_g = 12000; - store_skp = 10000; - - draw_xp_skills(); - - update_gold_skills(); -} - -void spend_xp_event_filter (short item_hit) -{ - short pc_num; - bool talk_done = false; - - pc_num = store_train_pc; - - switch (item_hit) { - case 73: - dialog_answer = 0; - talk_done = true; - break; - - - - case 3: case 4: - if ((store_h >= 250) && (item_hit == 4)) - SysBeep(2); - else { - if (item_hit == 3) { - store_g += 10; - store_h -= 2; - store_skp += 1; - } - else { - if ((store_g < 10) || (store_skp < 1)) { - - SysBeep(2); - } - else { - store_g -= 10; - store_h += 2; - store_skp -= 1; - } - } - - update_gold_skills(); - cd_set_item_num(1010,52,store_h); - draw_xp_skills(); - - } - break; - - case 5: case 6: - if ((store_sp >= 150) && (item_hit == 6)) - SysBeep(2); - else { - if (item_hit == 5) { - store_g += 15; - store_sp -= 1; - store_skp += 1; - } - else { - if ((store_g < 15) || (store_skp < 1)) { - - SysBeep(2); - } - else { - store_sp += 1; - store_g -= 15; - store_skp -= 1; - } - } - - update_gold_skills(); - cd_set_item_num(1010,53,store_sp); - draw_xp_skills(); - } - break; - - case 48: - do_xp_keep(pc_num,0); - dialog_answer = 1; - talk_done = true; - break; - - case 49: - - do_xp_keep(pc_num,0); - do { - pc_num = (pc_num == 0) ? 5 : pc_num - 1; - } while (univ.party[pc_num].main_status != 1); - store_train_pc = pc_num; - do_xp_draw(); - break; - - case 50: - - do_xp_keep(pc_num,0); - do { - pc_num = (pc_num == 5) ? 0 : pc_num + 1; - } while (univ.party[pc_num].main_status != 1); - store_train_pc = pc_num; - do_xp_draw(); - break; - - case 100: - break; - - default: - if (item_hit >= 100) { + for (i = 0; i < 24; i++) { + if ((univ.party[pc_num].items[i].variety > 0) && + (univ.party[pc_num].items[i].type_flag > 0) && (univ.party[pc_num].items[i].ident)) { + for (j = i + 1; j < 24; j++) + if ((univ.party[pc_num].items[j].variety > 0) && + (univ.party[pc_num].items[j].type_flag == univ.party[pc_num].items[i].type_flag) + && (univ.party[pc_num].items[j].ident)) { + // add_string_to_buf("(items combined)"); + test = (short) (univ.party[pc_num].items[i].charges) + (short) (univ.party[pc_num].items[j].charges); + if (test > 125) { + univ.party[pc_num].items[i].charges = 125; + // ASB("Can have at most 125 of any item."); } - else { - which_skill = (item_hit - 7) / 2; - - if (((store_skills[which_skill] >= skill_max[which_skill]) && ((item_hit - 7) % 2 == 1)) || - ((store_skills[which_skill] == 0) && ((item_hit - 7) % 2 == 0) && (which_skill > 2)) || - ((store_skills[which_skill] == 1) && ((item_hit - 7) % 2 == 0) && (which_skill <= 2))) - SysBeep(2); - else { - if ((item_hit - 7) % 2 == 0) { - store_g += skill_g_cost[which_skill]; - store_skills[which_skill] -= 1; - store_skp += skill_cost[which_skill]; - } - else { - if ((store_g < skill_g_cost[which_skill]) || (store_skp < skill_cost[which_skill])) { - - SysBeep(2); - } - else { - store_skills[which_skill] += 1; - store_g -= skill_g_cost[which_skill]; - store_skp -= skill_cost[which_skill]; - } - } - - update_gold_skills(); - cd_set_item_num(1010,54 + which_skill,store_skills[which_skill]); - draw_xp_skills(); - } - } - break; - } - - store_train_pc = pc_num; - if (talk_done == true) { - toast_dialog(); - } -} -void update_gold_skills() -{ - csit(1010,47,"Lots!"); - csit(1010,46,"Lots!"); -} -bool spend_xp(short pc_num, short mode, short parent) -//short mode; // 0 - create 1 - train -// returns 1 if cancelled -{ - Str255 get_text,text2; - short item_hit; - - store_train_pc = pc_num; - - make_cursor_sword(); - - cd_create_dialog_parent_num(1010,parent); - sprintf((char *) get_text,"Health (%d/%d)",1,10); - cd_add_label(1010,52,(char *) get_text,1075); - sprintf((char *) get_text,"Spell Pts. (%d/%d)",1,15); - //cd_add_label(1010,5,get_text,1040); - cd_add_label(1010,53,(char *) get_text,1075); - for (i = 54; i < 73; i++) { - get_str(text2,9,1 + 2 * (i - 54)); - sprintf((char *) get_text,"%s (%d/%d)",text2,skill_cost[i - 54],skill_g_cost[i - 54]); - cd_add_label(1010,i,(char *) get_text,(i < 63) ? 1075 : 1069); - } - do_xp_draw(); - - dialog_answer = 0; - - item_hit = cd_run_dialog(); - - cd_kill_dialog(1010); - - return dialog_answer; -} - -void give_reg_info_event_filter (short item_hit) -{ - - switch (item_hit) { - case 1: - toast_dialog(); - break; + else univ.party[pc_num].items[i].charges += univ.party[pc_num].items[j].charges; + if (univ.party[pc_num].equip[j] == true) { + univ.party[pc_num].equip[i] = true; + univ.party[pc_num].equip[j] = false; + } + take_item(pc_num,j); } + } + if ((univ.party[pc_num].items[i].variety > 0) && (univ.party[pc_num].items[i].charges < 0)) + univ.party[pc_num].items[i].charges = 1; + } } -void give_reg_info() +bool give_to_pc(short pc_num,cItemRec item, short print_result) { - short item_hit; - - make_cursor_sword(); - - cd_create_dialog_parent_num(1073,0); + short free_space; - item_hit = cd_run_dialog(); - cd_kill_dialog(1073); - + if (item.variety == 0) + return true; + if (((free_space = pc_has_space(pc_num)) == 24 ) || (univ.party[pc_num].main_status != 1)) + return false; + else { + univ.party[pc_num].items[free_space] = item; + combine_things(pc_num); + return true; + } + return false; } -void edit_xp_event_filter (short item_hit) +bool give_to_party(cItemRec item,short print_result) { - Str255 get_text; + short i = 0; + + while (i < 6) { + if (give_to_pc(i,item,print_result) == true) + return true; + i++; + } + return false; +} + +void give_gold(short amount,bool print_result) +{ + univ.party.gold = univ.party.gold + amount; +} + +bool take_gold(short amount,bool print_result) +{ + if (univ.party.gold < amount) + return false; + univ.party.gold = univ.party.gold - amount; + return true; +} + +short pc_has_space(short pc_num) +{ + short i = 0; + + while (i < 24) { + if (univ.party[pc_num].items[i].variety == 0) + return i; + i++; + } + return 24; +} + +void take_item(short pc_num,short which_item) +//short pc_num,which_item; // if which_item > 20, don't update stat win, item is which_item - 20 +{ + short i; + + if ((univ.party[pc_num].weap_poisoned == which_item) && (univ.party[pc_num].status[0] > 0)) { + // add_string_to_buf(" Poison lost. "); + univ.party[pc_num].status[0] = 0; + } + if ((univ.party[pc_num].weap_poisoned > which_item) && (univ.party[pc_num].status[0] > 0)) + univ.party[pc_num].weap_poisoned--; + + for (i = which_item; i < 23; i++) { + univ.party[pc_num].items[i] = univ.party[pc_num].items[i + 1]; + univ.party[pc_num].equip[i] = univ.party[pc_num].equip[i + 1]; + } + univ.party[pc_num].items[23].variety = ITEM_TYPE_NO_ITEM; + univ.party[pc_num].equip[23] = false; - cd_retrieve_text_edit_str(1024,2,(char *) get_text); - dialog_answer = 0; - sscanf((char *) get_text,"%d",&dialog_answer); - toast_dialog(); } void edit_xp(cPlayer *pc) { - - short item_hit; - Str255 sign_text; location view_loc; - store_xp_pc = pc; - make_cursor_sword(); - cd_create_dialog(1024,mainPtr); + cDialog dlog("edit-xp.xml"); + dlog["okay"].attachClickHandler(get_num_event_filter); - sprintf((char *) sign_text,"%d",(short)pc->experience); - cd_set_text_edit_str(1024,2,(char *) sign_text); - item_hit = store_xp_pc->get_tnl(); - cdsin(1024,8,item_hit); + dlog["number"].setTextToNum(pc->experience); + dlog["perlevel"].setTextToNum(pc->get_tnl()); - item_hit = cd_run_dialog(); + dlog.run(); - cd_kill_dialog(1024); - - if (dialog_answer < 0) - dialog_answer = dialog_answer * -1; - dialog_answer = minmax(0,10000,dialog_answer); + int dialog_answer = minmax(0,10000,abs(dlog.getResult())); pc->experience = dialog_answer; } diff --git a/osx/pcedit/pc.action.h b/osx/pcedit/pc.action.h index da91042a..054161b7 100644 --- a/osx/pcedit/pc.action.h +++ b/osx/pcedit/pc.action.h @@ -1,23 +1,12 @@ -bool handle_action(EventRecord event,short mode); -void flash_rect(Rect to_flash); -void edit_gold_or_food_event_filter (short item_hit); + +#include +#include "dialog.h" + +bool handle_action(sf::Event event,short mode); +void flash_rect(RECT to_flash); void edit_gold_or_food(short which_to_edit); -void put_pc_graphics(); -void display_pc_event_filter (short item_hit); -void display_pc(short pc_num,short mode,short parent); -void display_alchemy_event_filter (short item_hit); -void display_alchemy(); -void do_xp_keep(short pc_num,short mode); -void draw_xp_skills(); -void do_xp_draw(); -void spend_xp_event_filter (short item_hit); -void update_gold_skills(); -bool spend_xp(short pc_num, short mode, short parent); -void give_reg_info_event_filter (short item_hit); -void give_reg_info(); -void do_registration_event_filter (short item_hit); -void do_registration(); +void display_pc(short pc_num,short mode,cDialog* parent); +void display_alchemy(bool allowEdit); +bool spend_xp(short pc_num, short mode, cDialog* parent); void edit_day(); -void edit_day_event_filter (short item_hit); -void edit_xp_event_filter (short item_hit); void edit_xp(cPlayer *pc); diff --git a/osx/pcedit/pc.appleevents.mm b/osx/pcedit/pc.appleevents.mm new file mode 100644 index 00000000..15a57ca5 --- /dev/null +++ b/osx/pcedit/pc.appleevents.mm @@ -0,0 +1,38 @@ +// +// pc.appleevents.mm +// BoE +// +// Created by Celtic Minstrel on 14-04-16. +// +// + +#include + +extern bool verify_restore_quit(bool mode); +extern bool All_Done; + +typedef NSAppleEventDescriptor AEDescr; + +@interface AppleEventHandler : NSObject +-(void)handleOpenDoc:(AEDescr*)theAppleEvent withReply: (AEDescr*)reply; +-(void)handleQuit:(AEDescr*)theAppleEvent withReply: (AEDescr*)reply; +@end + +void set_up_apple_events() { + AppleEventHandler* aeHandler = [[AppleEventHandler alloc] init]; + NSAppleEventManager* AEmgr = [NSAppleEventManager sharedAppleEventManager]; + [AEmgr setEventHandler: aeHandler andSelector: @selector(handleOpenDoc:withReply:) + forEventClass: kCoreEventClass andEventID: kAEOpenDocuments]; + [AEmgr setEventHandler: aeHandler andSelector: @selector(handleQuit:withReply:) + forEventClass: kCoreEventClass andEventID: kAEQuitApplication]; +} + +@implementation AppleEventHandler +-(void)handleOpenDoc:(AEDescr*)theAppleEvent withReply: (AEDescr*)reply { + // TODO: Handle this +} +-(void)handleQuit:(AEDescr*)theAppleEvent withReply: (AEDescr*)reply { + All_Done = verify_restore_quit(0); +} +@end + diff --git a/osx/pcedit/pc.editors.cpp b/osx/pcedit/pc.editors.cpp index 6aea9908..f235ac25 100644 --- a/osx/pcedit/pc.editors.cpp +++ b/osx/pcedit/pc.editors.cpp @@ -1,11 +1,16 @@ -#include #include "pc.graphics.h" #include "pc.global.h" #include "classes.h" #include "pc.editors.h" #include "graphtool.h" -#include "dlgtool.h" +#include "dialog.h" +#include "control.h" +#include "button.h" +#include "dlogutil.h" +#include + +extern std::string get_str(std::string, short); /* Adventure globals */ //extern party_record_type party; @@ -24,256 +29,98 @@ extern short store_flags[3]; extern short current_active_pc; -extern WindowPtr mainPtr; -extern Rect d_rects[80]; +extern sf::RenderWindow mainPtr; +extern RECT d_rects[80]; extern short d_rect_index[80]; -extern bool modeless_exists[12],diff_depth_ok,current_file_has_maps; -extern short modeless_key[12]; -extern DialogPtr modeless_dialogs[12]; - -bool equippable[18] = {false,true,true,false,true,true,true,false,false,true,true,true, - true,true,true,false,false,true}; -short num_hands_to_use[18] = {0,1,2,0,1,1,1,0,0,1,1,0,0,0,0,0,0,0}; -short num_that_can_equip[18] = {0,2,1,0,1,1,1,0,0,2,1,1,1,2,1,0,0,1}; -short selected,item_max = 0; +extern bool diff_depth_ok,current_file_has_maps; bool choice_active[6]; - - extern short store_trait_mode; +extern short which_pc_displayed; cPlayer *store_pc; -GWorldPtr button_num_gworld; +sf::Texture button_num_gworld; +short skill_cost[20] = { + 3,3,3,2,2,2, 1,2,2,6, + 5, 1,2,4,2,1, 4,2,5,0}; +short skill_max[20] = { + 20,20,20,20,20,20,20,20,20,7, + 7,20,20,10,20,20,20,20,20}; +short skill_g_cost[20] = { + 50,50,50,40,40,40,30,50,40,250, + 250,25,100,200,30,20,100,80,0,0}; +short skill_bonus[21] = { + -3,-3,-2,-1,0,0,1,1,1,2, + 2,2,3,3,3,3,4,4,4,5,5}; +// These are the IDs used to refer to the skills in the dialog +const char* skill_ids[19] = { + "str","dex","int", + "edge","bash","pole","thrown","bow","def", + "mage","priest","lore","alch","item", + "trap","lock","assassin","poison","luck" +}; +// Variables for spending xp +bool talk_done = false; +long val_for_text; +bool keep_change = false; +short store_skills[20],store_h,store_sp,i,store_skp,which_skill; +long store_g; +short store_train_mode,store_train_pc; -void combine_things(short pc_num) +static bool select_pc_event_filter (cDialog& me, std::string item_hit, eKeyMod mods) { - short i,j,test; - - for (i = 0; i < 24; i++) { - if ((univ.party[pc_num].items[i].variety > 0) && - (univ.party[pc_num].items[i].type_flag > 0) && (univ.party[pc_num].items[i].ident)) { - for (j = i + 1; j < 24; j++) - if ((univ.party[pc_num].items[j].variety > 0) && - (univ.party[pc_num].items[j].type_flag == univ.party[pc_num].items[i].type_flag) - && (univ.party[pc_num].items[j].ident)) { - add_string_to_buf("(items combined)"); - test = (short) (univ.party[pc_num].items[i].charges) + (short) (univ.party[pc_num].items[j].charges); - if (test > 125) { - univ.party[pc_num].items[i].charges = 125; - ASB("Can have at most 125 of any item."); - } - else univ.party[pc_num].items[i].charges += univ.party[pc_num].items[j].charges; - if (univ.party[pc_num].equip[j] == true) { - univ.party[pc_num].equip[i] = true; - univ.party[pc_num].equip[j] = false; - } - take_item(pc_num,j); - } - } - if ((univ.party[pc_num].items[i].variety > 0) && (univ.party[pc_num].items[i].charges < 0)) - univ.party[pc_num].items[i].charges = 1; - } -} - -bool give_to_pc(short pc_num,cItemRec item, short print_result) -{ - short free_space; - - if (item.variety == 0) - return true; - if (((free_space = pc_has_space(pc_num)) == 24 ) || (univ.party[pc_num].main_status != 1)) - return false; - else { - univ.party[pc_num].items[free_space] = item; - combine_things(pc_num); - return true; - } - return false; -} - -bool give_to_party(cItemRec item,short print_result) -{ - short i = 0; - - while (i < 6) { - if (give_to_pc(i,item,print_result) == true) - return true; - i++; - } - return false; -} - -void give_gold(short amount,bool print_result) -{ - univ.party.gold = univ.party.gold + amount; -} - -bool take_gold(short amount,bool print_result) -{ - if (univ.party.gold < amount) - return false; - univ.party.gold = univ.party.gold - amount; + me.toast(); + if(item_hit != "cancel") { + short which_pc = item_hit[item_hit.length() - 1] - '1'; + me.setResult(which_pc); + } else me.setResult(6); return true; } - -short pc_has_space(short pc_num) -{ - short i = 0; - - while (i < 24) { - if (univ.party[pc_num].items[i].variety == 0) - return i; - i++; - } - return 24; -} - - -void take_item(short pc_num,short which_item) -//short pc_num,which_item; // if which_item > 20, don't update stat win, item is which_item - 20 -{ - short i; - - if ((univ.party[pc_num].weap_poisoned == which_item) && (univ.party[pc_num].status[0] > 0)) { -// add_string_to_buf(" Poison lost. "); - univ.party[pc_num].status[0] = 0; - } - if ((univ.party[pc_num].weap_poisoned > which_item) && (univ.party[pc_num].status[0] > 0)) - univ.party[pc_num].weap_poisoned--; - - for (i = which_item; i < 23; i++) { - univ.party[pc_num].items[i] = univ.party[pc_num].items[i + 1]; - univ.party[pc_num].equip[i] = univ.party[pc_num].equip[i + 1]; - } - univ.party[pc_num].items[23].variety = ITEM_TYPE_NO_ITEM; - univ.party[pc_num].equip[23] = false; - -} - - -//void fancy_choice_dialog_event_filter (short item_hit) -//{ -// toast_dialog(); -// dialog_answer = item_hit; -//} -// -//short fancy_choice_dialog(short which_dlog,short parent) -//// ignore parent in Mac version -//{ -// short item_hit,i,store_dialog_answer; -// Str255 temp_str; -// -// store_dialog_answer = dialog_answer; -// make_cursor_sword(); -// -// cd_create_dialog_parent_num(which_dlog,parent); -// -// item_hit = cd_run_dialog(); -// cd_kill_dialog(which_dlog,0); -// -// i = dialog_answer; -// dialog_answer = store_dialog_answer; -// -// return i; -//} - -void select_pc_event_filter (short item_hit) -{ - toast_dialog(); - if (item_hit == 16) - dialog_answer = 6; - else dialog_answer = item_hit - 3; -} - -short char_select_pc(short active_only,short free_inv_only,char *title) -//active_only; // 0 - no 1 - yes 2 - disarm trap +short char_select_pc(short active_only,short free_inv_only,const char *title) +//active_only; // 0 - no 1 - yes 2 - disarm trap { short item_hit,i; - + make_cursor_sword(); - cd_create_dialog(1018,mainPtr); + cDialog selectPc("select-pc.xml"); + selectPc.attachClickHandlers(select_pc_event_filter, {"cancel", "pick1", "pick2", "pick3", "pick4", "pick5", "pick6"}); - if (active_only == 2) - csit(1018,15,"Select PC to disarm trap:"); - else csit( 1018,15,title); + selectPc["title"].setText(title); for (i = 0; i < 6; i++) { + std::string n = boost::lexical_cast(i + 1); if ((univ.party[i].main_status == 0) || ((active_only == true) && (univ.party[i].main_status > 1)) || ((free_inv_only == 1) && (pc_has_space(i) == 24)) || (univ.party[i].main_status == 5)) { - cd_activate_item(1018, 3 + i, 0); - } + selectPc["pick" + n].hide(); + } + // TODO: Wouldn't this lead to blank name fields for non-active characters if those characters are allowed? if (univ.party[i].main_status != 0) { - csit(1018,9 + i,univ.party[i].name.c_str()); - } - else cd_activate_item(1018, 9 + i, 0); + selectPc["pc" + n].setText(univ.party[i].name); + } + else selectPc["pc" + n].hide(); } - item_hit = cd_run_dialog(); - cd_kill_dialog(1018); - - return dialog_answer; + selectPc.run(); + item_hit = selectPc.getResult(); + + return item_hit; } short select_pc(short active_only,short free_inv_only) -//active_only; // 0 - no 1 - yes 2 - disarm trap +//active_only; // 0 - no 1 - yes 2 - disarm trap { if (active_only == 2) return char_select_pc(active_only,free_inv_only,"Trap! Who will disarm?"); - else return char_select_pc(active_only,free_inv_only,"Select a character:"); + else return char_select_pc(active_only,free_inv_only,"Select a character:"); } - -// only used at beginning of program -short choice_dialog(short pic,short num) -{ - DialogPtr select_dialog = NULL; - short item_hit; - - select_dialog = GetNewDialog (num, 0, IN_FRONT); - if (select_dialog == NULL) { - SysBeep(50); - ExitToShell(); - } - - SetPort(GetDialogPort(select_dialog)); - - - - ShowWindow(GetDialogWindow(select_dialog)); - - //if (pic > 0) - // put_dialog_graphic(pic,0,the_rect); - ModalDialog(NULL, &item_hit); - - DisposeDialog(select_dialog); - -// SetPort(GetWindowPort(mainPtr)); - -// BeginUpdate(mainPtr); -// if (in_startup_mode == false) -// refresh_screen(0); -// else draw_startup(0); -// EndUpdate(mainPtr); - - - return item_hit; - -} - - - - - - - - -short party_total_level() +static short party_total_level() { short i,j = 0; @@ -283,115 +130,467 @@ short party_total_level() return j; } - - -short luck_total() +static void put_pc_spells(cDialog& me) { - short i = 0; + short i; - for (i = 0; i < 6; i++) - if (univ.party[i].main_status == 1) - i += univ.party[i].skills[18]; - return i; + for (i = 0; i < 62; i++) { + std::string id = "spell" + boost::lexical_cast(i + 1); + cLed& cur = dynamic_cast(me[id]); + if (((store_trait_mode == 0) && univ.party[which_pc_displayed].mage_spells[i]) || + ((store_trait_mode == 1) && univ.party[which_pc_displayed].priest_spells[i])) + cur.setState(led_red); + else cur.setState(led_off); + } + + me["who"].setText(univ.party[which_pc_displayed].name.c_str()); } -void display_traits_graphics() +static bool display_pc_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) +{ + short pc_num; + + pc_num = which_pc_displayed; + if(item_hit == "done") { + me.toast(); + } else if(item_hit == "left") { + do { + pc_num = (pc_num == 0) ? 5 : pc_num - 1; + } while (univ.party[pc_num].main_status == 0); + which_pc_displayed = pc_num; + put_pc_spells(me); + } else if(item_hit == "right") { + do { + pc_num = (pc_num == 5) ? 0 : pc_num + 1; + } while (univ.party[pc_num].main_status == 0); + which_pc_displayed = pc_num; + put_pc_spells(me); + } + return true; +} + +void display_pc(short pc_num,short mode,cDialog* parent) +{ + short i; + std::string label_str; + + if (univ.party[pc_num].main_status == 0) { + for (pc_num = 0; pc_num < 6; pc_num++) + if (univ.party[pc_num].main_status == 1) + break; + } + which_pc_displayed = pc_num; + store_trait_mode = mode; + + make_cursor_sword(); + + cDialog pcInfo("pc-spell-info.xml", parent); + pcInfo.attachClickHandlers(display_pc_event_filter,{"done","left","right"}); + + for (i = 0; i < 62; i++) { + std::string id = "spell" + boost::lexical_cast(i + 1); + label_str = get_str((mode == 0) ? "mage-spells" : "priest-spells",i * 2 + 1); + pcInfo[id].setText(label_str); + } + put_pc_spells(pcInfo); + + dynamic_cast(pcInfo["pic"]).setPict(14 + mode,PIC_DLOG); + + pcInfo.run(); +} + +static void display_traits_graphics(cDialog& me) { short i,store; - - for (i = 0; i < 3; i++) { - cd_set_led(1013,4 + i,(store_pc->race == i) ? 1 : 0); - } + + std::string race = "race" + boost::lexical_cast(store_pc->race + 1); + dynamic_cast(me["race"]).setSelected(race); for (i = 0; i < 10; i++) { - cd_set_led(1013,7 + i,(store_pc->traits[i] > 0) ? 1 : 0); - } + std::string id = "good" + boost::lexical_cast(i + 1); + dynamic_cast(me[id]).setState((store_pc->traits[i] > 0) ? led_red : led_off); + } for (i = 0; i < 5; i++) { - cd_set_led(1013,36 + i,(store_pc->traits[10 + i] > 0) ? 1 : 0); - } - + std::string id = "bad" + boost::lexical_cast(i + 1); + dynamic_cast(me[id]).setState((store_pc->traits[10 + i] > 0) ? led_red : led_off); + } + store = store_pc->get_tnl(); - cdsin(1013,18,store); + me["xp"].setTextToNum(store); } -void pick_race_abil_event_filter(short item_hit) +static bool pick_race_abil_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) { + me.toast(); + return true; +} + +static bool pick_race_select_led(cDialog& me, std::string item_hit, bool losing) { - Str255 abil_str; + std::string abil_str; cPlayer *pc; - + pc = store_pc; - switch (item_hit) { - case 3: - toast_dialog(); - break; - case 4: case 5: case 6: - if (store_trait_mode == 0) - pc->race = (eRace) (item_hit - 4); - display_traits_graphics(); - get_str(abil_str,5,12 + item_hit); - csit(1013,19,(char *) abil_str); - break; - case 36: case 37: case 38: case 39: case 40: - if (store_trait_mode != 1) - pc->traits[item_hit - 36 + 10] = (pc->traits[item_hit - 36 + 10] == true) ? false : true; - display_traits_graphics(); - get_str(abil_str,5,item_hit - 36 + 11); - csit(1013,19,(char *) abil_str); - break; - default: - if (item_hit >= 100) - return; - if (store_trait_mode != 1) - pc->traits[item_hit - 7] = (pc->traits[item_hit - 7] == true) ? false : true; - display_traits_graphics(); - get_str(abil_str,5,item_hit - 6); - csit(1013,19,(char *) abil_str); - break; - } - + if(item_hit == "race") { + eRace race; + switch(item_hit[4] - '1') { + case 0: race = RACE_HUMAN; break; + case 1: race = RACE_NEPHIL; break; + case 2: race = RACE_SLITH; break; + case 3: race = RACE_VAHNATAI; break; + } + if(store_trait_mode == 0) + pc->race = race; + display_traits_graphics(me); + abil_str = get_str("traits",16 + race); + me["info"].setText(abil_str); + } else if(item_hit.substr(0,3) == "bad") { + int hit = item_hit[3] - '1'; + if(store_trait_mode != 1) + pc->traits[hit + 10] = (pc->traits[hit + 10] == true) ? false : true; + display_traits_graphics(me); + abil_str = get_str("traits",hit + 11); + me["info"].setText(abil_str); + } else if(item_hit.substr(0,4) == "good") { + int hit = item_hit[4] - '1'; + if(store_trait_mode != 1) + pc->traits[hit] = (pc->traits[hit] == true) ? false : true; + display_traits_graphics(me); + abil_str = get_str("traits",hit + 1); + me["info"].setText(abil_str); + } + return store_trait_mode == 0; } -void pick_race_abil(cPlayer *pc,short mode,short parent_num) +void pick_race_abil(cPlayer *pc,short mode,cDialog* parent) //mode; // 0 - edit 1 - just display 2 - can't change race { - char *start_str1 = "Click on advantage button for description."; - char *start_str2 = "Click on advantage button to add/lose."; - short item_hit; + static const char*const start_str1 = "Click on button by name for description."; + static const char*const start_str2 = "Click on advantage button to add/remove."; - mode = 0; store_trait_mode = mode; store_pc = pc; make_cursor_sword(); - - cd_create_dialog_parent_num(1013,parent_num); - - display_traits_graphics(); - if (mode == 1) - csit(1013,19,start_str1); - else csit(1013,19,start_str2); - item_hit = cd_run_dialog(); - cd_kill_dialog(1013); - untoast_dialog(); + cDialog pickAbil("pick-race-abil.xml"); + pickAbil["done"].attachClickHandler(pick_race_abil_event_filter); + pickAbil.attachFocusHandlers(pick_race_select_led, {"race", "bad1", "bad2", "bad3", "bad4", "bad5"}); + pickAbil.attachFocusHandlers(pick_race_select_led, {"good1", "good2", "good3", "good4", "good5"}); + pickAbil.attachFocusHandlers(pick_race_select_led, {"good6", "good7", "good8", "good9", "good10"}); + + display_traits_graphics(pickAbil); + if (mode == 1) + pickAbil["info"].setText(start_str1); + else pickAbil["info"].setText(start_str2); + + pickAbil.run(); +} + +const char* alch_names[20] = { + "Weak Curing Potion (1)","Weak Healing Potion (1)","Weak Poison (1)", + "Weak Speed Potion (3)","Medium Poison (3)", + "Medium Heal Potion (4)","Strong Curing (5)","Medium Speed Potion (5)", + "Graymold Salve (7)","Weak Energy Potion (9)", + "Potion of Clarity (9)","Strong Poison (10)","Strong Heal Potion (12)","Killer Poison (12)", + "Resurrection Balm (9)","Medium Energy Ptn. (14)","Knowledge Brew (19)" , + "Strong Strength (10)","Bliss (16)","Strong Power (20)" +}; + +void display_alchemy(bool allowEdit) +{ + short i; + + make_cursor_sword(); + + cChoiceDlog showAlch("pc-alchemy-info.xml", {"done"}); + + for(i = 0; i < 20; i++) { + std::string id = "potion" + boost::lexical_cast(i + 1); + showAlch->addLabelFor(id, alch_names[i], LABEL_LEFT, 83, true); + if(!allowEdit) + showAlch->getControl(id).attachClickHandler(&cDialog::noAction); + cLed& led = dynamic_cast(showAlch->getControl(id)); + if (univ.party.alchemy[i] > 0) + led.setState(led_red); + else led.setState(led_off); + } + + showAlch.show(); + if(!allowEdit) return; + + for(i = 0; i < 20; i++) { + std::string id = "potion" + boost::lexical_cast(i + 1); + cLed& led = dynamic_cast(showAlch->getControl(id)); + if(led.getState() == led_red) univ.party.alchemy[i] = true; + else univ.party.alchemy[i] = false; + } +} + +// TODO: This dialog needs some kind of context system really badly to avoid the rampant globals +// MARK: Start spend XP dialog +static void do_xp_keep(short pc_num,short mode) +{ + for (i = 0; i < 20; i++) + univ.party[pc_num].skills[i] = store_skills[i]; + univ.party[pc_num].cur_health += store_h - univ.party[pc_num].max_health; + univ.party[pc_num].max_health = store_h; + univ.party[pc_num].cur_sp += store_sp - univ.party[pc_num].max_sp; + univ.party[pc_num].max_sp = store_sp; + if (mode == 1) + univ.party.gold = store_g; + univ.party[pc_num].skill_pts = store_skp; + +} + +static void draw_xp_skills(cDialog& me) +{ + short i; + // TODO: Wouldn't it make more sense for it to be red when you can't buy the skill rather than red when you can? + for (i = 0; i < 19; i++) { + cControl& cur = me[skill_ids[i]]; + if ((store_skp >= skill_cost[i]) && (store_g >= skill_g_cost[i])) + cur.setColour(sf::Color::Red); + else cur.setColour(me.getDefTextClr()); + cur.setTextToNum(store_skills[i]); + } + + cControl& sp = me["sp"]; + cControl& hp = me["hp"]; + if ((store_skp >= 1) && (store_g >= 10)) + hp.setColour(sf::Color::Red); + else hp.setColour(me.getDefTextClr()); + hp.setTextToNum(store_h); + if ((store_skp >= 1) && (store_g >= 15)) + sp.setColour(sf::Color::Red); + else sp.setColour(me.getDefTextClr()); + sp.setTextToNum(store_sp); +} + +static void update_gold_skills(cDialog& me) { + me["gold"].setTextToNum(((store_train_mode == 0) ? 0 : store_g)); + me["skp"].setTextToNum(store_skp); } -//short get_tnl(pc_record_type *pc) -//{ -// short tnl = 100,i,store_per = 100; -// short rp[3] = {0,12,20}; -// short ap[15] = {10,20,8,10,4, 6,10,7,12,15, -10,-8,-8,-20,-8}; -// -// tnl = (tnl * (100 + rp[pc->race])) / 100; -// for (i = 0; i < 15; i++) -// if (pc->traits[i] == true) -// store_per = store_per + ap[i]; -// -// tnl = (tnl * store_per) / 100; -// -// return tnl; -//} -// +static void do_xp_draw(cDialog& me) +{ + + char get_text[256]; + short mode,pc_num; + + mode = store_train_mode; + pc_num = store_train_pc; + if (mode == 0) { + if (univ.party[pc_num].main_status == 1) + sprintf((char *) get_text, "%s",(char *) univ.party[pc_num].name.c_str()); + else sprintf((char *) get_text, "New PC"); + } + else sprintf((char *) get_text, "%s",(char *) univ.party[pc_num].name.c_str()); + + me["recipient"].setText(get_text); + + for (i = 0; i < 20; i++) + store_skills[i] = univ.party[pc_num].skills[i]; + store_h = univ.party[pc_num].max_health; + store_sp = univ.party[pc_num].max_sp; + store_g = (mode == 0) ? 20000 : univ.party.gold; + store_skp = univ.party[pc_num].skill_pts; + + draw_xp_skills(me); + + + update_gold_skills(me); +} -//display_strings(20,7,0,0,"Editing party",57,707,916); +static bool spend_xp_navigate_filter(cDialog& me, std::string item_hit, eKeyMod mods) +{ + short mode,pc_num; + bool talk_done = false; + + mode = store_train_mode; + pc_num = store_train_pc; + + if(item_hit == "cancel") { + if ((mode == 0) && (univ.party[pc_num].main_status < MAIN_STATUS_ABSENT)) + univ.party[pc_num].main_status = MAIN_STATUS_ABSENT; + me.setResult(false); + talk_done = true; + } else if(item_hit == "help") { + univ.party.help_received[10] = 0; +// give_help(210,11,me); + } else if(item_hit == "keep") { + do_xp_keep(pc_num,mode); + me.setResult(true); + talk_done = true; + } else if(item_hit == "left") { + // TODO: Try not forcing a commit when using the arrows? + if (mode != 0) { + do_xp_keep(pc_num,mode); + do { + pc_num = (pc_num == 0) ? 5 : pc_num - 1; + } while (univ.party[pc_num].main_status != 1); + store_train_pc = pc_num; + do_xp_draw(me); + } // else TODO: Play an error sound here + } else if(item_hit == "right") { + // TODO: If they don't work in mode 0, why are they visible? + if (mode != 0) { + do_xp_keep(pc_num,mode); + do { + pc_num = (pc_num == 5) ? 0 : pc_num + 1; + } while (univ.party[pc_num].main_status != 1); + store_train_pc = pc_num; + do_xp_draw(me); + } // else TODO: Play an error sound here + } + store_train_pc = pc_num; + if (talk_done == true) { + me.toast(); + } + return true; +} +static bool spend_xp_event_filter(cDialog& me, std::string item_hit, eKeyMod mods) { + short mode = store_train_mode, pc_num = store_train_pc; + if(item_hit.substr(0,2) == "hp") { + if(mod_contains(mods, mod_alt)) { + cStrDlog aboutHP(get_str("help",63),"","About Health",24,PIC_DLOG,&me); + aboutHP.setSound(57); + aboutHP.show(); + } else if (((store_h >= 250) && (item_hit[3] == 'p')) || + ((store_h == univ.party[pc_num].max_health) && (item_hit[3] == 'm') && (mode == 1)) || + ((store_h == 6) && (item_hit[3] == 'm') && (mode == 0))) + ; // TODO: Play an error sound here + else if(item_hit == "hp-m") { + store_g += 10; + store_h -= 2; + store_skp += 1; + } + else { + if ((store_g < 10) || (store_skp < 1)) { +// if (store_g < 10) +// give_help(24,0,me); +// else give_help(25,0,me); + } + else { + store_g -= 10; + store_h += 2; + store_skp -= 1; + } + } + + update_gold_skills(me); + me["hp"].setTextToNum(store_h); + draw_xp_skills(me); + + } else if(item_hit.substr(0,2) == "sp") { + if(mod_contains(mods, mod_alt)) { + cStrDlog aboutSP(get_str("help",64),"","About Spell Points",24,PIC_DLOG,&me); + aboutSP.setSound(57); + aboutSP.show(); + } else if (((store_sp >= 150) && (item_hit[3] == 'p')) || + ((store_sp == univ.party[pc_num].max_sp) && (item_hit[3] == 'm') && (mode == 1)) || + ((store_sp == 0) && (item_hit[3] == 'm') && (mode == 0))) + ; // TODO: Play an error sound here + else if(item_hit == "sp-m") { + store_g += 15; + store_sp -= 1; + store_skp += 1; + } + else { + if ((store_g < 15) || (store_skp < 1)) { +// if (store_g < 15) +// give_help(24,0,me); +// else give_help(25,0,me); + } + else { + store_sp += 1; + store_g -= 15; + store_skp -= 1; + } + } + + update_gold_skills(me); + me["sp"].setTextToNum(store_sp); + draw_xp_skills(me); + } else { + for(int i = 0; i < 19; i++) { + int n = strlen(skill_ids[i]); + if(item_hit.length() < n + 2) continue; + if(item_hit.substr(0, item_hit.length() - 2) == skill_ids[i]) { + which_skill = i; + break; + } + } +/* if(mod_contains(mods, mod_alt)) display_skills(which_skill,&me); + else */{ + char dir = item_hit[item_hit.length() - 1]; + + if (((store_skills[which_skill] >= skill_max[which_skill]) && (dir == 'p')) || + ((store_skills[which_skill] == univ.party[pc_num].skills[which_skill]) && (dir == 'm') && (mode == 1)) || + ((store_skills[which_skill] == 0) && (dir == 'm') && (mode == 0) && (which_skill > 2)) || + ((store_skills[which_skill] == 1) && (dir == 'm') && (mode == 0) && (which_skill <= 2))) + ; // TODO: Play an error sound here + else { + if(dir == 'm') { + store_g += skill_g_cost[which_skill]; + store_skills[which_skill] -= 1; + store_skp += skill_cost[which_skill]; + } + else { + if ((store_g < skill_g_cost[which_skill]) || (store_skp < skill_cost[which_skill])) { +// if (store_g < skill_g_cost[which_skill]) +// give_help(24,0,me); +// else give_help(25,0,me); + } + else { + store_skills[which_skill] += 1; + store_g -= skill_g_cost[which_skill]; + store_skp -= skill_cost[which_skill]; + } + } + + update_gold_skills(me); + me[skill_ids[which_skill]].setTextToNum(store_skills[which_skill]); + draw_xp_skills(me); + } + } + } + return true; +} + +bool spend_xp(short pc_num, short mode, cDialog* parent) +//short mode; // 0 - create 1 - train +// returns 1 if cancelled +{ + store_train_pc = pc_num; + store_train_mode = mode; + + make_cursor_sword(); + + cDialog xpDlog("spend-xp.xml",parent); + xpDlog.addLabelFor("hp","Health (1/10)",LABEL_LEFT,75,true); + xpDlog.addLabelFor("sp","Spell Pts. (1/15)",LABEL_LEFT,75,true); + std::string minus = "-m", plus = "-p"; + for (i = 54; i < 73; i++) { + std::ostringstream sout; + sout << get_str("skills",1 + 2 * (i - 54)) << ' ' << '('; + sout << skill_cost[i - 54] << '/' << skill_g_cost[i - 54] << ')'; + xpDlog.addLabelFor(skill_ids[i - 54],sout.str(),LABEL_LEFT,(i < 63) ? 75 : 69,true); + xpDlog[skill_ids[i - 54] + minus].attachClickHandler(spend_xp_event_filter); + xpDlog[skill_ids[i - 54] + plus].attachClickHandler(spend_xp_event_filter); + } + do_xp_draw(xpDlog); + + xpDlog.attachClickHandlers(spend_xp_navigate_filter,{"keep","cancel","left","right","help"}); + xpDlog.attachClickHandlers(spend_xp_event_filter,{"sp-m","sp-p","hp-m","hp-p"}); + + if (univ.party.help_received[10] == 0) { + // TODO: Is an initial draw even needed? +// cd_initial_draw(1010); +// give_help(10,11,xpDlog); + } + + xpDlog.run(); + + return xpDlog.getResult(); +} diff --git a/osx/pcedit/pc.editors.h b/osx/pcedit/pc.editors.h index ff94c4ff..9e3cb5b5 100644 --- a/osx/pcedit/pc.editors.h +++ b/osx/pcedit/pc.editors.h @@ -1,22 +1,14 @@ + + bool give_to_pc(short pc_num,cItemRec item, short print_result); bool give_to_party(cItemRec item,short print_result); void give_gold(short amount,bool print_result); bool take_gold(short amount,bool print_result); short pc_has_space(short pc_num); void take_item(short pc_num,short which_item); -//void fancy_choice_dialog_event_filter (short item_hit); -//short fancy_choice_dialog(short which_dlog,short parent); -void select_pc_event_filter (short item_hit); short char_select_pc(short active_only,short free_inv_only,char *title); short select_pc(short active_only,short free_inv_only); -short choice_dialog(short pic,short num); -bool give_spec_items_event_filter (short item_hit); void give_spec_items(); -short party_total_level(); -short luck_total(); -void display_traits_graphics(); -void pick_race_abil_event_filter(short item_hit); -void pick_race_abil(cPlayer *pc,short mode,short parent_num); -//short get_tnl(pc_record_type *pc); +void pick_race_abil(cPlayer *pc,short mode,class cDialog* parent_num); void reset_boats(); void combine_things(short pc_num); diff --git a/osx/pcedit/pc.fileio.cpp b/osx/pcedit/pc.fileio.cpp index eb7c4b21..ede9cb68 100644 --- a/osx/pcedit/pc.fileio.cpp +++ b/osx/pcedit/pc.fileio.cpp @@ -10,12 +10,12 @@ #include "soundtool.h" #include "pc.editors.h" #include "mathutil.h" -#include "dlgutil.h" +#include "dlogutil.h" +#include "restypes.hpp" +#include +#include "fileio.h" #define DONE_BUTTON_ITEM 1 -#define IN_FRONT (WindowPtr)-1L - -DialogPtr the_dialog; /* Adventure globals */ //extern party_record_type party; @@ -31,10 +31,10 @@ DialogPtr the_dialog; //extern stored_town_maps_type town_maps; //extern stored_outdoor_maps_type o_maps; -extern bool play_sounds,save_blocked; +extern bool play_sounds; extern short current_active_pc; extern long stored_key; -extern WindowPtr mainPtr; +extern sf::RenderWindow mainPtr; extern cItemRec item_list[400]; extern cUniverse univ; @@ -49,25 +49,55 @@ typedef struct { char *party_encryptor; -Str63 last_load_file = "\pBlades of Exile Save"; +std::string last_load_file = "Blades of Exile Save"; extern void update_item_menu(); extern short store_flags[3]; -FSSpec store_file_reply; +fs::path store_file_reply; short give_intro_hint,display_mode; short jl; -FSSpec file_to_load; +fs::path file_to_load; void load_base_item_defs(); bool load_scen_item_defs(char scen_name[256]); +fs::path progDir; + +void init_directories() +{ + char cPath[768]; + CFBundleRef mainBundle=CFBundleGetMainBundle(); + + CFStringRef progURL = CFURLCopyFileSystemPath(CFBundleCopyBundleURL(mainBundle), kCFURLPOSIXPathStyle); + const char* tmp = CFStringGetCStringPtr(progURL, kCFStringEncodingASCII);//kCFStringEncodingUTF8); + if(tmp == NULL){ + bool success = CFStringGetCString(progURL, cPath, sizeof(cPath), kCFStringEncodingUTF8); + if(success) { + progDir = cPath; + std::cout << cPath << "\n\n" << progDir << "\n\n"; + } else { + std::cout << "Couldn't retrieve application path.\n"; + exit(1); + } + }else progDir = tmp; + progDir = progDir.parent_path(); + std::cout<(progDir/"Scenario Editor"/"graphics.exd"/"mac"); + ResMgr::pushPath(progDir/"Scenario Editor"/"graphics.exd"/"mac"/"cursors"); + ResMgr::pushPath(progDir/"data"/"fonts"); + ResMgr::pushPath(progDir/"data"/"strings"); + ResMgr::pushPath(progDir/"Scenario Editor"/"sounds.exa"); + +} + //bool select_save_location(FSSpec* to_save_ptr){ // if(to_save_ptr==NULL) // return(false); // OSErr error; -// Str255 message = "\pSelect saved game: "; +// char message[256] = "Select saved game: "; // NavTypeListHandle type_list; // NavDialogCreationOptions dialogOptions; // NavDialogRef theDialog; @@ -187,65 +217,11 @@ short init_data(short flag) } void load_base_item_defs(){ - OSErr err; - char cPath[512]; - CFBundleRef mainBundle=CFBundleGetMainBundle(); - CFURLRef baseScenURL = CFBundleCopyResourceURL(mainBundle,CFSTR("bladbase"),CFSTR("exs"),NULL); - CFStringRef baseScenPath = CFURLCopyFileSystemPath(baseScenURL, kCFURLPOSIXPathStyle); - CFStringGetCString(baseScenPath, cPath, 512, kCFStringEncodingUTF8); - FSRef bSRef; - FSPathMakeRef((UInt8*)cPath, &bSRef, false); - short forkRef; - HFSUniStr255 forkName; - FSGetDataForkName(&forkName); - err=FSOpenFork(&bSRef, forkName.length, forkName.unicode, fsRdPerm, &forkRef); - if(err!=noErr){ - printf("Unable to open base scenario data\n"); - ExitToShell(); - } - err=FSReadFork(forkRef, fsFromStart, 41942, 26400, &(item_list[0]), NULL); - if(err!=noErr){ - printf("Unable to read base scenario data\n"); - ExitToShell(); - } - err=FSCloseFork(forkRef); - if(err!=noErr){ - printf("Unable to close base scenario data\n"); - ExitToShell(); - } + fs::path basePath = progDir/"Scenario Editor"/"BoE Bases"/"bladbase.exs"; + load_scenario(basePath, true); } -bool load_scen_item_defs(char scen_name[256]){ - OSErr err; - char cPath[768]; - CFBundleRef mainBundle=CFBundleGetMainBundle(); - CFURLRef progURL = CFBundleCopyBundleURL(mainBundle); - CFStringRef progDir = CFURLCopyFileSystemPath(progURL, kCFURLPOSIXPathStyle); - CFRange findRes; - if(!CFStringFindWithOptions(progDir, CFSTR("/"), CFRangeMake(0, CFStringGetLength(progDir)), kCFCompareBackwards, &findRes)){ - printf("Error: Unable to find scenario directory\n"); - return(false); - } - CFStringRef scenPath = CFStringCreateWithFormat(NULL,NULL,CFSTR("%@/Blades of Exile Scenarios/%s"),CFStringCreateWithSubstring(NULL, progDir, CFRangeMake(0,findRes.location)),scen_name); - CFStringGetCString(scenPath, cPath, 768, kCFStringEncodingUTF8); - FSRef scenRef; - FSPathMakeRef((UInt8*)cPath, &scenRef, false); - short forkRef; - HFSUniStr255 forkName; - FSGetDataForkName(&forkName); - err=FSOpenFork(&scenRef, forkName.length, forkName.unicode, fsRdPerm, &forkRef); - if(err!=noErr){ - printf("Unable to open scenario data\n"); - return(false); - } - err=FSReadFork(forkRef, fsFromStart, 41942, 26400, &(item_list[0]), NULL); - if(err!=noErr){ - printf("Unable to read scenario data\n"); - return(false); - } - err=FSCloseFork(forkRef); - if(err!=noErr){ - printf("Unable to close scenario data\n"); - } - return(true); -} \ No newline at end of file +bool load_scen_item_defs(std::string scen_name){ + fs::path scenPath = progDir/"Blades of Exile Scenarios"/(scen_name + ".exs"); + return load_scenario(scenPath, true); +} diff --git a/osx/pcedit/pc.fileio.h b/osx/pcedit/pc.fileio.h index 146d26fd..90fb69e9 100644 --- a/osx/pcedit/pc.fileio.h +++ b/osx/pcedit/pc.fileio.h @@ -8,3 +8,4 @@ short init_data(short flag); //void make_pref_file(FSSpec pref); //void save_prefs(); void remove_party_from_scen(); +void init_directories(); diff --git a/osx/pcedit/pc.global.h b/osx/pcedit/pc.global.h index d5389bbf..7cc0bc06 100644 --- a/osx/pcedit/pc.global.h +++ b/osx/pcedit/pc.global.h @@ -1,14 +1,12 @@ //#define EXILE_BIG_GUNS 1 #define DRAG_EDGE 15 -#define IN_FRONT (WindowPtr)-1L #define T_M 60 #define NUM_TOWN_ITEMS 115 #define DRAG_EDGE 15 -#define IN_FRONT (WindowPtr)-1L #define DISPLAY_LEFT 23 #define DISPLAY_TOP 23 @@ -91,7 +89,7 @@ // location sign_locs[8]; // out_wandering_type wandering[4],special_enc[4]; // location wandering_locs[4]; -// Rect info_rect[8]; +// RECT info_rect[8]; // unsigned char strlens[180]; // special_node_type specials[60]; // } outdoor_record_type; @@ -158,7 +156,7 @@ // location start_locs[4]; // location exit_locs[4]; // short exit_specs[4]; -// Rect in_town_rect; +// RECT in_town_rect; // preset_item_type preset_items[64]; // short max_num_monst; // preset_field_type preset_fields[50]; @@ -175,21 +173,21 @@ //typedef struct { // unsigned char terrain[64][64]; -// Rect room_rect[16]; +// RECT room_rect[16]; // creature_start_type creatures[60]; // unsigned char lighting[8][64]; // } big_tr_type; //typedef struct { // unsigned char terrain[48][48]; -// Rect room_rect[16]; +// RECT room_rect[16]; // creature_start_type creatures[40]; // unsigned char lighting[6][48]; // } ave_tr_type; //typedef struct { // unsigned char terrain[32][32]; -// Rect room_rect[16]; +// RECT room_rect[16]; // creature_start_type creatures[30]; // unsigned char lighting[4][32]; // } tiny_tr_type; @@ -203,7 +201,7 @@ // } city_block_type; //typedef struct { -// Rect what_rect; +// RECT what_rect; // unsigned char ter_type; // unsigned char hollow; // } city_ter_rect_type; @@ -283,7 +281,7 @@ // short flag_to_add_to_town[10][2]; // short flag_c; // short out_data_size[100][2]; -// Rect store_item_rects[3]; +// RECT store_item_rects[3]; // short store_item_towns[3]; // short flag_e; // short special_items[50]; diff --git a/osx/pcedit/pc.graphics.cpp b/osx/pcedit/pc.graphics.cpp index 5c349c18..a64adfbc 100644 --- a/osx/pcedit/pc.graphics.cpp +++ b/osx/pcedit/pc.graphics.cpp @@ -8,43 +8,47 @@ #include "pc.action.h" #include "soundtool.h" #include "graphtool.h" -#include "dlgtool.h" -#include "dlglowlevel.h" -#include "dlgutil.h" +#include "dlogutil.h" +#include "restypes.hpp" +#include "message.h" +#include "mathutil.h" + +extern std::string get_str(std::string, short); extern cUniverse univ; -extern WindowPtr mainPtr; -extern bool play_sounds,file_in_mem,party_in_scen,scen_items_loaded; +extern sf::RenderWindow mainPtr; +extern bool play_sounds,party_in_scen,scen_items_loaded; +extern fs::path file_in_mem; extern short store_flags[3]; -extern GWorldPtr button_num_gworld,bg_gworld; +extern sf::Texture button_num_gworld,bg_gworld; extern short current_active_pc; //extern bool ed_reg; //extern long register_flag,stored_key; //extern long ed_flag,ed_key; -GWorldPtr title_gworld,pc_gworld,dlogpics_gworld; -GWorldPtr buttons_gworld,invenbtn_gworld,status_gworld; +sf::Texture title_gworld,pc_gworld,dlogpics_gworld; +sf::Texture 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}; -Rect title_from = {0,0,70,380}; -extern Rect pc_area_buttons[6][4] ; // 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 - -extern Rect pc_info_rect; // Frame that holds a pc's basic info and items -extern Rect name_rect; -extern Rect pc_race_rect; -extern Rect info_area_rect; -extern Rect hp_sp_rect; -extern Rect skill_rect; -extern Rect pc_skills_rect[19]; -extern Rect status_rect; -extern Rect pc_status_rect[10]; -extern Rect traits_rect; -extern Rect pc_traits_rect[16]; -extern Rect edit_rect[5][2]; +RECT whole_win_rect = {0,0,440,590}; +RECT title_from = {0,0,70,380}; +extern RECT pc_area_buttons[6][4] ; // 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 - +extern RECT pc_info_rect; // Frame that holds a pc's basic info and items +extern RECT name_rect; +extern RECT pc_race_rect; +extern RECT info_area_rect; +extern RECT hp_sp_rect; +extern RECT skill_rect; +extern RECT pc_skills_rect[19]; +extern RECT status_rect; +extern RECT pc_status_rect[10]; +extern RECT traits_rect; +extern RECT pc_traits_rect[16]; +extern RECT edit_rect[5][2]; short store_str1a; short store_str1b; @@ -52,62 +56,34 @@ short store_str2a; short store_str2b; short store_which_string_dlog; short store_page_on,store_num_i; -Rect ed_buttons_from[2] = {{0,0,57,57},{0,57,57,114}}; +// TODO: The duplication of RECT here shouldn't be necessary... +RECT ed_buttons_from[2] = {RECT{0,0,57,57},RECT{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 +sf::Texture 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[NUM_MONST_SHEETS],terrain_gworld[NUM_TER_SHEETS],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); - cd_register_event_filter(917,edit_day_event_filter); - cd_register_event_filter(970,display_strings_event_filter); - cd_register_event_filter(971,display_strings_event_filter); - cd_register_event_filter(972,display_strings_event_filter); - cd_register_event_filter(973,display_strings_event_filter); - cd_register_event_filter(991,display_pc_event_filter); - cd_register_event_filter(996,display_alchemy_event_filter); - cd_register_event_filter(1010,spend_xp_event_filter); - cd_register_event_filter(947,edit_gold_or_food_event_filter); - cd_register_event_filter(1012,edit_gold_or_food_event_filter); - cd_register_event_filter(1013,pick_race_abil_event_filter); - cd_register_event_filter(1018,select_pc_event_filter); - cd_register_event_filter(1024,edit_xp_event_filter); - cd_register_event_filter(1073,give_reg_info_event_filter); - cd_register_default_event_filter(fancy_choice_dialog_event_filter); -} +sf::Texture items_gworld,tiny_obj_gworld,fields_gworld,roads_gworld,boom_gworld,missiles_gworld; +sf::Texture monst_gworld[NUM_MONST_SHEETS],terrain_gworld[NUM_TER_SHEETS],anim_gworld,talkfaces_gworld; +sf::Texture vehicle_gworld, small_ter_gworld; void init_main_buttons() { short i; int indent = 0, indent2 = 0; - GrafPtr old_port; - Str255 fn1 = "\pGeneva"; - Str255 fn3 = "\pPalatino"; - Rect base_rect; + RECT base_rect; if (init_once == false) { init_once = true; - GetFNum(fn1,&geneva_font_num); - if (geneva_font_num == 0) - GetFNum(fn3,&geneva_font_num); - - GetPort(&old_port); - SetPort(GetWindowPort(mainPtr)); - TextFont(geneva_font_num); - TextFace(bold); - TextSize(10); - SetPort(old_port); + TEXT.font = "Silom"; + TEXT.style = sf::Text::Regular; + TEXT.pointSize = 10; } //whole_win_rect = mainPtr->portRect; //Initialize pc_info_rect in center pc_info_rect= whole_win_rect; - InsetRect(&pc_info_rect,100,100); + pc_info_rect.inset(100,100); pc_info_rect.bottom+=52; pc_info_rect.top-=25; pc_info_rect.right+=5; @@ -138,8 +114,8 @@ void init_main_buttons() pc_area_buttons[i][1].bottom = pc_area_buttons[i][2].top = pc_area_buttons[i][0].bottom - 18; pc_area_buttons[i][2].bottom = pc_area_buttons[i][3].top = pc_area_buttons[i][0].bottom - 9; pc_area_buttons[i][3].bottom = pc_area_buttons[i][0].bottom; - OffsetRect(&pc_area_buttons[i][2],0,-1); - OffsetRect(&pc_area_buttons[i][3],0,-2); + pc_area_buttons[i][2].offset(0,-1); + pc_area_buttons[i][3].offset(0,-2); } //Initialize the edit_rect buttons edit_rect[0][0].top = pc_info_rect.top; @@ -207,7 +183,7 @@ void init_main_buttons() for (i = 0; i < 19; i++) { pc_skills_rect[i] = base_rect; - OffsetRect(&pc_skills_rect[i], (i / 10) * ((name_rect.right)-(name_rect.left)), (i % 10) * (pc_info_rect.bottom - name_rect.bottom)/30); + pc_skills_rect[i].offset((i / 10) * ((name_rect.right)-(name_rect.left)), (i % 10) * (pc_info_rect.bottom - name_rect.bottom)/30); } //Initialize status_rect @@ -222,7 +198,7 @@ void init_main_buttons() base_rect.bottom = base_rect.top + (pc_info_rect.bottom - status_rect.bottom)/15; for (i = 0; i < 10; i++) { pc_status_rect[i] = base_rect; - OffsetRect(&pc_status_rect[i], (i / 5) * ((name_rect.right)-(name_rect.left)), (i % 5) * (pc_info_rect.bottom - status_rect.bottom)/15); + pc_status_rect[i].offset((i / 5) * ((name_rect.right)-(name_rect.left)), (i % 5) * (pc_info_rect.bottom - status_rect.bottom)/15); } //Initialize traits_rect traits_rect.top = pc_status_rect[4].bottom + 5; @@ -236,7 +212,7 @@ void init_main_buttons() base_rect.bottom = base_rect.top + 10; for (i = 0; i < 16; i++) { pc_traits_rect[i] = base_rect; - OffsetRect(&pc_traits_rect[i], (i / 8) * ((name_rect.right)-(name_rect.left)), (i % 8) * 9); + pc_traits_rect[i].offset((i / 8) * ((name_rect.right)-(name_rect.left)), (i % 8) * 9); } @@ -246,7 +222,7 @@ void init_main_buttons() item_string_rects[0][0].bottom = item_string_rects[0][0].top + 12; for (i = 1; i < 24; i++) { item_string_rects[i][0] = item_string_rects[0][0]; - OffsetRect(&item_string_rects[i][0],0,13 * i); + item_string_rects[i][0].offset(0,13 * i); } for (i = 0; i < 24; i++) { item_string_rects[i][1] = item_string_rects[i][0]; @@ -261,20 +237,11 @@ 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("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); -// } + title_gworld.loadFromImage(*ResMgr::get("pcedtitle")); + invenbtn_gworld.loadFromImage(*ResMgr::get("invenbtns")); + status_gworld.loadFromImage(*ResMgr::get("staticons")); + dlogpics_gworld.loadFromImage(*ResMgr::get("dlogpics")); + buttons_gworld.loadFromImage(*ResMgr::get("pcedbuttons")); } @@ -283,77 +250,77 @@ void redraw_screen() draw_main_screen(); display_party(6,1); draw_items(1); + mainPtr.display(); +} + +static void frame_dlog_rect(sf::RenderWindow& target, RECT rect) { + cTextMsg text(target); + text.setFormat(TXT_FRAME, true); + text.setFormat(TXT_FRAMESTYLE, 1); + text.setBounds(rect); + text.draw(); } void draw_main_screen() { - Rect source_rect, dest_rec,dest_rect; - Rect reg_rect; + RECT source_rect, dest_rec,dest_rect; + RECT reg_rect; - SetPort(GetWindowPort(mainPtr)); - tileImage(whole_win_rect,bg_gworld,bg[12]); // fill whole window with background texture + tileImage(mainPtr,whole_win_rect,bg_gworld,bg[12]); // fill whole window with background texture dest_rec = source_rect = title_from; // initializes, to draw title - // title_from is a Rect constant - OffsetRect(&dest_rec,20,0); + // title_from is a RECT constant + dest_rec.offset(20,0); - rect_draw_some_item (title_gworld,source_rect,dest_rec,(Point){0,0},transparent); - // The first title_gworld is the from, the gworld to draw from - // and source_rect is the rectangle in that gworld to draw - // The 1,1 at the end means ... - // the 1st 1 means transparent, if the first 1 was a 0, not transparent - // The second 1 means on the main window, not into another gworld - // dest_rec is where it's drawn to - // Finally, the second title_gworld. This would be the gworld you were drawing into if - // you were drawing into a gworld. You aren't so this doesn't matter, so just put the earlier - // gworld in as a place holder. + rect_draw_some_item(title_gworld,source_rect,mainPtr,dest_rec,sf::BlendAlpha); dest_rect = dest_rec; dest_rect.top = dest_rect.bottom; dest_rect.bottom = dest_rect.top + 50; // initialize rectangle to draw text into - TextSize(12); - TextFace(bold + underline); + // TODO: Is this needed? +#if 0 + TEXT.pointSize = 12; + TEXT.style = sf::Text::Underlined; // set the pen - //char_win_draw_string(GetWindowPort(mainPtr),dest_rect,"Characters",0,10); + win_draw_string(mainPtr,dest_rect,"Characters",0,10); // This draws a chunk of text on the screen - TextSize(10); /// reset text size - TextFace(0); // reset text pen - TextFace(bold); +#endif + TEXT.pointSize = 10; + TEXT.style = sf::Text::Regular; - frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // draw the frame + frame_dlog_rect(mainPtr,pc_info_rect); // draw the frame //i = pc_info_rect.left-pc_info_rect.right; //sprintf((char *)temp_str,"Width of pc_info_rect %d ", //(short) i); //win_draw_string(mainPtr,pc_info_rect,temp_str,0,12); - + TEXT.colour = sf::Color::Black; dest_rect = pc_area_buttons[5][0]; dest_rect.right = whole_win_rect.right - 30; //What is this for? Commenting it out has no effect. dest_rect.left += 60; //Off0setRect(&dest_rect,0,45); - OffsetRect(&dest_rect,0,21); - if (file_in_mem == true) - char_win_draw_string(mainPtr,dest_rect,"Click on character to edit it.",0,10); + dest_rect.offset(0,21); + if(!file_in_mem.empty()) + win_draw_string(mainPtr,dest_rect,"Click on character to edit it.",0,10); else - char_win_draw_string(mainPtr,dest_rect,"Select Open from File menu.",0,10); - if(file_in_mem == true && party_in_scen==true && scen_items_loaded==false){ - OffsetRect(&dest_rect,200,0); - char_win_draw_string(mainPtr,dest_rect,"Warning: Scenario item data could not be loaded.",0,10); - OffsetRect(&dest_rect,-200,0); + win_draw_string(mainPtr,dest_rect,"Select Open from File menu.",0,10); + if(!file_in_mem.empty() && party_in_scen && !scen_items_loaded){ + dest_rect.offset(200,0); + win_draw_string(mainPtr,dest_rect,"Warning: Scenario item data could not be loaded.",0,10); + dest_rect.offset(-200,0); } - OffsetRect(&dest_rect,0,12); - if (file_in_mem == true) - char_win_draw_string(mainPtr,dest_rect,"Press 'I' button to identify item, and 'D' button to drop item.",0,10); - TextSize(12); - OffsetRect(&dest_rect,0,16); - if (file_in_mem == true) - char_win_draw_string(mainPtr,dest_rect,"Back up save file before editing it!",0,10); - TextSize(10); - TextFace(0); - OffsetRect(&dest_rect,280,0); - char_win_draw_string(mainPtr,dest_rect,"Created in 1997 by Spiderweb Software, Inc.",0,10); - TextFace(bold); - + dest_rect.offset(0,12); + if(!file_in_mem.empty()) + win_draw_string(mainPtr,dest_rect,"Press 'I' button to identify item, and 'D' button to drop item.",0,10); + TEXT.pointSize = 12; + dest_rect.offset(0,16); + if(!file_in_mem.empty()) + win_draw_string(mainPtr,dest_rect,"Back up save file before editing it!",0,10); + TEXT.pointSize = 10; + TEXT.font = "Geneva"; + dest_rect.offset(280,0); + win_draw_string(mainPtr,dest_rect,"Created in 1997 by Spiderweb Software, Inc.",0,10); + TEXT.font = "Silom"; reg_rect = whole_win_rect; reg_rect.left = reg_rect.right - 170; @@ -369,32 +336,32 @@ void do_button_action(short which_pc,short which_button) current_pressed_button = which_button; display_party(6,0); play_sound(34); - Delay(10,&dummy); + sf::sleep(time_in_ticks(10)); current_pressed_button = -1; display_party(6,0); } -//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 - +//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) //short clear_first; // 0 - redraw over, 1 - don't redraw over { short i; - Str255 to_draw; - Rect d_from = {12,28,24,42},i_from = {12,42,24,56},dest_rect; + char to_draw[256]; + RECT d_from = {12,28,24,42},i_from = {12,42,24,56},dest_rect; - if (file_in_mem == false) // save file loaded + if(file_in_mem.empty()) // save file loaded return; dest_rect = item_string_rects[0][0]; dest_rect.bottom += 3; - OffsetRect(&dest_rect,0,-14); + dest_rect.offset(0,-14); // First erase crap there already by painting background texture over it if (clear_first == 1) { for (i = 0; i < 24; i++) - tileImage(item_string_rects[i][0],bg_gworld,bg[12]); - tileImage(dest_rect,bg_gworld,bg[12]); + tileImage(mainPtr,item_string_rects[i][0],bg_gworld,bg[12]); + tileImage(mainPtr,dest_rect,bg_gworld,bg[12]); } // First, draw "Fred's Items:" @@ -406,9 +373,9 @@ void draw_items(short clear_first) //TextSize(10); if (univ.party[current_active_pc].main_status != 1){ - frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // re draw entire frame - frame_dlog_rect(GetWindowPort(mainPtr),info_area_rect,1); // draw the frame - frame_dlog_rect(GetWindowPort(mainPtr),pc_race_rect,1); // draw the frame + frame_dlog_rect(mainPtr,pc_info_rect); // re draw entire frame + frame_dlog_rect(mainPtr,info_area_rect); // draw the frame + frame_dlog_rect(mainPtr,pc_race_rect); // draw the frame return; // If PC is dead, it has no items } for (i = 0; i < 24; i++) // Loop through items and draw each @@ -427,16 +394,16 @@ void draw_items(short clear_first) // else sprintf((char *) to_draw, "%d %d %d %d", // name_rect.left,name_rect.right,name_rect.top,name_rect.bottom); - char_win_draw_string(mainPtr,item_string_rects[i][0],(char *) to_draw,0,10); + win_draw_string(mainPtr,item_string_rects[i][0],(char *) to_draw,0,10); //Draw id/drop buttons - rect_draw_some_item(invenbtn_gworld,d_from,item_string_rects[i][1],(Point){0,0},transparent); - rect_draw_some_item(invenbtn_gworld,i_from,item_string_rects[i][2],(Point){0,0},transparent); + rect_draw_some_item(invenbtn_gworld,d_from,mainPtr,item_string_rects[i][1],sf::BlendAlpha); + rect_draw_some_item(invenbtn_gworld,i_from,mainPtr,item_string_rects[i][2],sf::BlendAlpha); } - frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // re draw entire frame - frame_dlog_rect(GetWindowPort(mainPtr),name_rect,1); // draw the frame - frame_dlog_rect(GetWindowPort(mainPtr),pc_race_rect,1); // draw the frame - frame_dlog_rect(GetWindowPort(mainPtr),info_area_rect,1); // draw the frame + frame_dlog_rect(mainPtr,pc_info_rect); // re draw entire frame + frame_dlog_rect(mainPtr,name_rect); // draw the frame + frame_dlog_rect(mainPtr,pc_race_rect); // draw the frame + frame_dlog_rect(mainPtr,info_area_rect); // draw the frame } @@ -445,77 +412,83 @@ void display_party(short mode,short clear_first) //short clear_first; // 1 - redraw over what's already there, 0 - don't redraw over { short i,k,string_num, cur_rect=0; - Str255 to_draw, skill_value; - Rect from_base = {0,0,36,28},from_rect,no_party_rect,temp_rect; + const char* to_draw; + const char* skill_value; + RECT from_base = {0,0,36,28},from_rect,no_party_rect,temp_rect; + // TODO: Is this needed? +#if 0 // lots of stuff is global. Like ... // bool file_in_mem // short current_active_pc if (clear_first == 1) { // first erase what's already there for (i = 0; i < 6; i++) - tileImage(pc_area_buttons[i][0],bg_gworld,bg[12]); - tileImage(name_rect,bg_gworld,bg[12]); - tileImage(pc_race_rect,bg_gworld,bg[12]); - tileImage(info_area_rect,bg_gworld,bg[12]); - frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // re-draw the frame + tileImage(mainPtr,pc_area_buttons[i][0],bg_gworld,bg[12]); + tileImage(mainPtr,name_rect,bg_gworld,bg[12]); + tileImage(mainPtr,pc_race_rect,bg_gworld,bg[12]); + tileImage(mainPtr,info_area_rect,bg_gworld,bg[12]); + frame_dlog_rect(mainPtr,pc_info_rect); // re-draw the frame } +#endif - if (file_in_mem == false) { // what if no party loaded? + if(file_in_mem.empty()) { // what if no party loaded? no_party_rect=pc_info_rect; no_party_rect.top+=5; no_party_rect.left+=5; - char_win_draw_string(mainPtr,no_party_rect,"No party loaded.",0,10); + win_draw_string(mainPtr,no_party_rect,"No party loaded.",0,10); } else { from_rect = pc_info_rect; from_rect.top = from_rect.bottom - 14; if (party_in_scen == false) - char_win_draw_string(mainPtr,from_rect,"Party not in a scenario.",0,10); + win_draw_string(mainPtr,from_rect,"Party not in a scenario.",0,10); else - char_win_draw_string(mainPtr,from_rect,"Party is in a scenario.",0,10); + win_draw_string(mainPtr,from_rect,"Party is in a scenario.",0,10); for (i = 0; i < 6; i++) { + // TODO: This appears to be expecting a tint? if (i == current_active_pc) // active pc is drawn in blue - ForeColor(blueColor); - else ForeColor(blackColor); + TEXT.colour = sf::Color::Blue; + else TEXT.colour = sf::Color::Black; from_rect = (current_pressed_button == i) ? ed_buttons_from[1] : ed_buttons_from[0]; if ((current_pressed_button < 0) || (current_pressed_button == i)) - rect_draw_some_item(buttons_gworld,from_rect,pc_area_buttons[i][0],(Point){0,0}); - ForeColor(blackColor); + rect_draw_some_item(buttons_gworld,from_rect,mainPtr,pc_area_buttons[i][0]); + TEXT.colour = sf::Color::Black; // pc_record_type is the records that contains chaarcters // main_status determins 0 - not exist, 1 - alive, OK, 2 - dead, 3 - stoned, 4 - dust if (univ.party[i].main_status != 0) { // PC exists? from_rect = from_base; // draw PC graphic - OffsetRect(&from_rect,56 * (univ.party[i].which_graphic / 8),36 * (univ.party[i].which_graphic % 8)); - rect_draw_some_item(pc_gworld,from_rect,pc_area_buttons[i][1],(Point){0,0},transparent); + from_rect.offset(56 * (univ.party[i].which_graphic / 8),36 * (univ.party[i].which_graphic % 8)); + rect_draw_some_item(pc_gworld,from_rect,mainPtr,pc_area_buttons[i][1],sf::BlendAlpha); //frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][1],0); // draw name - TextSize(9); + TEXT.pointSize = 9; if( (univ.party[i].name.length()) >= 10) { - TextFace(0); - sprintf((char *) to_draw, "%-s ", (char *) univ.party[i].name.c_str()); - TextSize(6); + TEXT.font = "Geneva"; + TEXT.pointSize = 6; + sprintf((char *) to_draw, "%-s ", (char *) univ.party[i].name.c_str()); } else { sprintf((char *) to_draw, "%-s ", (char *) univ.party[i].name.c_str()); } - ForeColor(whiteColor); - win_draw_string(GetWindowPort(mainPtr),pc_area_buttons[i][2],to_draw,1,10); - TextFace(bold); - TextSize(10); + TEXT.colour = sf::Color::White; + win_draw_string(mainPtr,pc_area_buttons[i][2],to_draw,1,10); + TEXT.font = "Silom"; + TEXT.pointSize = 10; if (i == current_active_pc){ sprintf((char *) to_draw, "%-.18s ", (char *) univ.party[i].name.c_str()); if( (univ.party[i].name.length()) > 12) - TextSize(8); - ForeColor(blackColor); - win_draw_string(GetWindowPort(mainPtr),name_rect,to_draw,1,10); - TextSize(10); + TEXT.pointSize = 8; + TEXT.colour = sf::Color::Black; + win_draw_string(mainPtr,name_rect,to_draw,1,10); + TEXT.pointSize = 10; + } if ((current_pressed_button < 0) || (current_pressed_button == i)) switch (univ.party[i].main_status) { @@ -524,274 +497,277 @@ void display_party(short mode,short clear_first) if (i == current_active_pc) { //Draw in race if (univ.party[i].race == 0) - char_win_draw_string(mainPtr,pc_race_rect,"Human ",1,10); + win_draw_string(mainPtr,pc_race_rect,"Human ",1,10); if (univ.party[i].race == 1) - char_win_draw_string(mainPtr,pc_race_rect,"Nephilim ",1,10); + win_draw_string(mainPtr,pc_race_rect,"Nephilim ",1,10); if (univ.party[i].race == 2) - char_win_draw_string(mainPtr,pc_race_rect,"Slithzerikai ",1,10); + win_draw_string(mainPtr,pc_race_rect,"Slithzerikai ",1,10); // Draw in skills sprintf((char *) to_draw, "Skills:"); - win_draw_string(GetWindowPort(mainPtr),skill_rect,to_draw,0,10); + win_draw_string(mainPtr,skill_rect,to_draw,0,10); sprintf((char *) to_draw, "Hp: %d/%d Sp: %d/%d",univ.party[i].cur_health,univ.party[i].max_health,univ.party[i].cur_sp, univ.party[i].max_sp); - win_draw_string(GetWindowPort(mainPtr),hp_sp_rect,to_draw,0,10); + win_draw_string(mainPtr,hp_sp_rect,to_draw,0,10); - TextSize(9); - TextFace(0); + TEXT.pointSize = 9; + TEXT.font = "Geneva"; string_num=1; for( k = 0; k < 19 ; ++k) { temp_rect = pc_skills_rect[k]; temp_rect.left = pc_skills_rect[k].left + 80; - get_str(to_draw,9,string_num); - win_draw_string(GetWindowPort(mainPtr),pc_skills_rect[k],to_draw,0,9); + win_draw_string(mainPtr,pc_skills_rect[k],get_str("skills",string_num),0,9); sprintf((char *) skill_value,"%d",univ.party[i].skills[k]); - win_draw_string(GetWindowPort(mainPtr),temp_rect,skill_value,0,9); + win_draw_string(mainPtr,temp_rect,skill_value,0,9); //frame_dlog_rect(GetWindowPort(mainPtr),pc_skills_rect[k],0); string_num+=2; } //end skills //Write in pc Status - TextSize(10); - TextFace(bold); + TEXT.pointSize = 10; + TEXT.font = "Silom"; sprintf((char *) to_draw, "Status:"); - win_draw_string(GetWindowPort(mainPtr),status_rect,to_draw,0,10); + win_draw_string(mainPtr,status_rect,to_draw,0,10); + + TEXT.pointSize = 9; + TEXT.font = "Geneva"; + + - TextSize(9); - TextFace(0); //for(k = 0 ; k < 10; k++) //frame_dlog_rect(GetWindowPort(mainPtr),pc_status_rect[k],0); if (univ.party[i].status[0] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned Weap.",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned Weap.",0,9); cur_rect++; } if (univ.party[i].status[1] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Blessed",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Blessed",0,9); cur_rect++; } else if(univ.party[i].status[1] < 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Cursed",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Cursed",0,9); cur_rect++; } if (univ.party[i].status[2] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned",0,9); cur_rect++; } if (univ.party[i].status[3] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Hasted",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Hasted",0,9); cur_rect++; } else if(univ.party[i].status[3] < 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Slowed",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Slowed",0,9); cur_rect++; } if (univ.party[i].status[4] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Invulnerable",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Invulnerable",0,9); cur_rect++; } if (univ.party[i].status[5] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Magic Resistant",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Magic Resistant",0,9); cur_rect++; } if (univ.party[i].status[6] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Webbed",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Webbed",0,9); cur_rect++; } if (univ.party[i].status[7] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Diseased",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Diseased",0,9); cur_rect++; } if (univ.party[i].status[8] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Sanctury",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Sanctury",0,9); cur_rect++; } if (univ.party[i].status[9] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Dumbfounded",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Dumbfounded",0,9); cur_rect++; } if (univ.party[i].status[10] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Martyr's Shield",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Martyr's Shield",0,9); cur_rect++; } if (univ.party[i].status[11] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Asleep",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Asleep",0,9); cur_rect++; } if (univ.party[i].status[12] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Paralyzed",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Paralyzed",0,9); cur_rect++; } if (univ.party[i].status[13] > 0) if(cur_rect <= 9) { - char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Acid",0,9); + win_draw_string(mainPtr,pc_status_rect[cur_rect],"Acid",0,9); cur_rect++; } //end pc status section //Write in Traits - TextSize(10); - TextFace(bold); + TEXT.pointSize = 10; + TEXT.font = "Silom"; sprintf((char *) to_draw, "Traits:"); - win_draw_string(GetWindowPort(mainPtr),traits_rect,to_draw,0,10); + win_draw_string(mainPtr,traits_rect,to_draw,0,10); //for(k = 0 ; k < 16; k++) //frame_dlog_rect(GetWindowPort(mainPtr),pc_traits_rect[k],0); - TextSize(9); - TextFace(0); + TEXT.pointSize = 9; + TEXT.font = "Geneva"; + cur_rect=0; if (univ.party[i].traits[0] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Toughness",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Toughness",0,9); cur_rect++; } if (univ.party[i].traits[1] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Apt",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Apt",0,9); cur_rect++; } if (univ.party[i].traits[2] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Ambidextrous",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Ambidextrous",0,9); cur_rect++; } if (univ.party[i].traits[3] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Nimble Fingers",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Nimble Fingers",0,9); cur_rect++; } if (univ.party[i].traits[4] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Cave Lore",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Cave Lore",0,9); cur_rect++; } if (univ.party[i].traits[5] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Woodsman",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Woodsman",0,9); cur_rect++; } if (univ.party[i].traits[6] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Good Constitution",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Good Constitution",0,9); cur_rect++; } if (univ.party[i].traits[7] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Highly Alert",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Highly Alert",0,9); cur_rect++; } if (univ.party[i].traits[8] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Exceptional Str.",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Exceptional Str.",0,9); cur_rect++; } if (univ.party[i].traits[9] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Recuperation",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Recuperation",0,9); cur_rect++; } if (univ.party[i].traits[10] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Sluggish",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Sluggish",0,9); cur_rect++; } if (univ.party[i].traits[11] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Inept",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Inept",0,9); cur_rect++; } if (univ.party[i].traits[12] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Frail",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Frail",0,9); cur_rect++; } if (univ.party[i].traits[13] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Chronic Disease",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Chronic Disease",0,9); cur_rect++; } if (univ.party[i].traits[14] == 1) if(cur_rect <= 15) { - char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Bad Back",0,9); + win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Bad Back",0,9); cur_rect++; } //end traits } - ForeColor(whiteColor); - TextSize(9); - TextFace(0); - char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Alive ",1,10); - TextFace(bold); - TextSize(10); + TEXT.colour = sf::Color::White; + TEXT.pointSize = 9; + TEXT.font = "Geneva"; + win_draw_string(mainPtr,pc_area_buttons[i][3],"Alive ",1,10); + TEXT.font = "Silom"; + TEXT.pointSize = 10; break; case 2: - ForeColor(whiteColor); - TextSize(9); - TextFace(0); - char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Dead ",1,10); - TextFace(bold); - TextSize(10); + TEXT.colour = sf::Color::White; + TEXT.pointSize = 9; + TEXT.font = "Geneva"; + win_draw_string(mainPtr,pc_area_buttons[i][3],"Dead ",1,10); + TEXT.font = "Silom"; + TEXT.pointSize = 10; break; case 3: - ForeColor(whiteColor); - TextSize(9); - TextFace(0); - char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Dust ",1,10); - TextFace(bold); - TextSize(10); + TEXT.colour = sf::Color::White; + TEXT.pointSize = 9; + TEXT.font = "Geneva"; + win_draw_string(mainPtr,pc_area_buttons[i][3],"Dust ",1,10); + TEXT.font = "Silom"; + TEXT.pointSize = 10; break; case 4: - ForeColor(whiteColor); - TextSize(9); - TextFace(0); - char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Stone ",1,10); - TextFace(bold); - TextSize(10); + TEXT.colour = sf::Color::White; + TEXT.pointSize = 9; + TEXT.font = "Geneva"; + win_draw_string(mainPtr,pc_area_buttons[i][3],"Stone ",1,10); + TEXT.font = "Silom"; + TEXT.pointSize = 10; break; case 5: - ForeColor(whiteColor); - TextSize(9); - TextFace(0); - char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Fled ",1,10); - TextFace(bold); - TextSize(10); + TEXT.colour = sf::Color::White; + TEXT.pointSize = 9; + TEXT.font = "Geneva"; + win_draw_string(mainPtr,pc_area_buttons[i][3],"Fled ",1,10); + TEXT.font = "Silom"; + TEXT.pointSize = 10; break; case 6: - ForeColor(whiteColor); - TextSize(9); - TextFace(0); - char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Surface ",1,10); - TextFace(bold); - TextSize(10); + TEXT.colour = sf::Color::White; + TEXT.pointSize = 9; + TEXT.font = "Geneva"; + win_draw_string(mainPtr,pc_area_buttons[i][3],"Surface ",1,10); + TEXT.font = "Silom"; + TEXT.pointSize = 10; break; default: - ForeColor(whiteColor); - TextFace(0); - TextSize(9); - char_win_draw_string(mainPtr,pc_area_buttons[i][3],"Absent ",1,10); - TextFace(bold); - TextSize(10); + TEXT.colour = sf::Color::White; + TEXT.pointSize = 9; + TEXT.font = "Geneva"; + win_draw_string(mainPtr,pc_area_buttons[i][3],"Absent ",1,10); + TEXT.font = "Silom"; + TEXT.pointSize = 10; break; } //frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][0],0); @@ -800,38 +776,40 @@ void display_party(short mode,short clear_first) } } // Closes the for i=6 loop - ForeColor(blackColor); + TEXT.colour = sf::Color::Black; + + for(i = 0; i < 5; i++) if ((current_pressed_button < 0) || (current_pressed_button == i + 10)) { if (clear_first == 1) { // first erase what's already there - tileImage(edit_rect[i][0],bg_gworld,bg[12]); + tileImage(mainPtr,edit_rect[i][0],bg_gworld,bg[12]); } //frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][0],0); //frame_dlog_rect(GetWindowPort(mainPtr),edit_rect[i][1],0); from_rect = (current_pressed_button == i + 10) ? ed_buttons_from[1] : ed_buttons_from[0]; - rect_draw_some_item(buttons_gworld,from_rect,edit_rect[i][0],(Point){0,0}); - ForeColor(whiteColor); + rect_draw_some_item(buttons_gworld,from_rect,mainPtr,edit_rect[i][0]); + TEXT.colour = sf::Color::White; switch(i) { case 0: - char_win_draw_string(mainPtr,edit_rect[0][1]," Add Mage Spells ",0,10); + win_draw_string(mainPtr,edit_rect[0][1]," Add Mage Spells ",0,10); break; case 1: - char_win_draw_string(mainPtr,edit_rect[1][1]," Add Priest Spells ",0,10); + win_draw_string(mainPtr,edit_rect[1][1]," Add Priest Spells ",0,10); break; case 2: - char_win_draw_string(mainPtr,edit_rect[2][1]," Edit Traits",0,10); + win_draw_string(mainPtr,edit_rect[2][1]," Edit Traits",0,10); break; case 3: - char_win_draw_string(mainPtr,edit_rect[3][1]," Edit Skills",0,10); + win_draw_string(mainPtr,edit_rect[3][1]," Edit Skills",0,10); break; case 4: - char_win_draw_string(mainPtr,edit_rect[4][1]," Edit XP",0,10); + win_draw_string(mainPtr,edit_rect[4][1]," Edit XP",0,10); break; default: break; } - ForeColor(blackColor); + TEXT.colour = sf::Color::Black; } // MoveTo(start_h + 10, start_v + 127); @@ -840,24 +818,15 @@ void display_party(short mode,short clear_first) } - ForeColor(blackColor); + TEXT.colour = sf::Color::Black; } - -void undo_clip() -{ - ClipRect(&whole_win_rect); -} - -void add_string_to_buf(char *str) { - - } -//void rect_draw_some_item (GWorldPtr src_gworld, Rect src_rect, GWorldPtr targ_gworld,Rect targ_rect, +//void rect_draw_some_item (GWorldPtr src_gworld, RECT src_rect, GWorldPtr targ_gworld,RECT targ_rect, //char masked,short main_win) ////char masked; // if 10 - make AddOver ////short main_win; // if 2, drawing onto dialog //{ -// Rect destrec; +// RECT destrec; // PixMapHandle test1, test2; // const BitMap *store_dest; // GrafPtr cur_port; @@ -909,7 +878,7 @@ void add_string_to_buf(char *str) { //{ // short text_len[257]; // short total_width = 0,i,len; -// Str255 p_str; +// char p_str[256]; // // for (i = 0; i < 257; i++) // text_len[i]= 0; @@ -925,9 +894,9 @@ void add_string_to_buf(char *str) { // return total_width; //} -//void char_win_draw_string(GrafPtr dest_window,Rect dest_rect,char *str,short mode,short line_height) +//void char_win_draw_string(GrafPtr dest_window,RECT dest_rect,char *str,short mode,short line_height) //{ -// Str255 store_s; +// char store_s[256]; // strcpy((char *) store_s,str); // win_draw_string( dest_window, dest_rect,store_s, mode, line_height); //} @@ -935,11 +904,11 @@ void add_string_to_buf(char *str) { //// mode: 0 - align up and left, 1 - center on one line //// str is a c string, 256 characters //// uses current font -//void win_draw_string(GrafPtr dest_window,Rect dest_rect,Str255 str,short mode,short line_height) +//void win_draw_string(GrafPtr dest_window,RECT dest_rect,Str255 str,short mode,short line_height) //{ // GrafPtr old_port; -// Str255 p_str,str_to_draw,str_to_draw2,c_str; -// Str255 null_s = " "; +// const char* p_str,str_to_draw,str_to_draw2,c_str; +// char null_s[256] = " "; // short str_len,i; // short last_line_break = 0,last_word_break = 0,on_what_line = 0; // short text_len[257]; @@ -1058,7 +1027,7 @@ void record_display_strings(){} // char *title,short sound_num,short graphic_num,short graphic_type,short parent_num) //{ // short item_hit; -// Str255 text; +// char text[256]; // location view_loc; // bool sound_done = false; // @@ -1098,7 +1067,7 @@ void record_display_strings(){} // cd_kill_dialog(store_which_string_dlog,0); //} -//void get_str(Str255 str,short i, short j) +//void get_str(const char* str,short i, short j) //{ // GetIndString(str, i, j); // p2cstr(str); diff --git a/osx/pcedit/pc.graphics.h b/osx/pcedit/pc.graphics.h index 87829591..ce1b70b0 100644 --- a/osx/pcedit/pc.graphics.h +++ b/osx/pcedit/pc.graphics.h @@ -3,14 +3,13 @@ void Set_up_win (); void redraw_screen(); void draw_main_screen(); void do_button_action(short which_pc,short which_button); -GWorldPtr load_pict(short picture_to_get); void draw_items(short clear_first); void display_party(short mode,short clear_first); void undo_clip(); void add_string_to_buf(char *str) ; //void display_strings_event_filter (short item_hit); //void display_strings(short str1a,short str1b,short str2a,short str2b, char *title,short sound_num,short graphic_num,short graphic_type,short parent_num); -//void get_str(Str255 str,short i, short j); +//void get_str(const char* str,short i, short j); short string_length(char *str); void make_cursor_sword(); void init_dialogs(); diff --git a/osx/pcedit/pc.main.cpp b/osx/pcedit/pc.main.cpp index 33e7e14f..91ddae67 100644 --- a/osx/pcedit/pc.main.cpp +++ b/osx/pcedit/pc.main.cpp @@ -9,42 +9,44 @@ #include "pc.action.h" #include "pc.fileio.h" #include "soundtool.h" -#include "dlgtool.h" -#include "dlgconsts.h" #include "graphtool.h" #include "boe.consts.h" -#include "dlgutil.h" +#include "dlogutil.h" #include "fileio.h" +#include "pc.menus.h" +#include "winutil.h" +#ifdef __APPLE__ +#include +#endif + +extern std::string get_str(std::string, short); cUniverse univ; -Rect pc_area_buttons[6][4] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later -Rect item_string_rects[24][4]; // 0 - name 1 - drop 2 - id 3 - -Rect pc_info_rect; // Frame that holds a pc's basic info and items -Rect name_rect; //Holds pc name inside pc_info_rect -Rect info_area_rect; -Rect hp_sp_rect; // Holds hit points and spells points for pc -Rect skill_rect; // Holds "Skills:" string -Rect pc_skills_rect[19]; //Holds current pc's skill levels -Rect status_rect; //Holds the string "Status:" -Rect pc_status_rect[10]; //Holds first 8 effects on pc -Rect traits_rect; //Holds the string "Traits:" -Rect pc_traits_rect[16]; //Holds pc traits -Rect pc_race_rect; //Holds current pc's race -Rect edit_rect[5][2]; //Buttons that bring up pc edit dialog boxs +RECT pc_area_buttons[6][4] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later +RECT item_string_rects[24][4]; // 0 - name 1 - drop 2 - id 3 - +RECT pc_info_rect; // Frame that holds a pc's basic info and items +RECT name_rect; //Holds pc name inside pc_info_rect +RECT info_area_rect; +RECT hp_sp_rect; // Holds hit points and spells points for pc +RECT skill_rect; // Holds "Skills:" string +RECT pc_skills_rect[19]; //Holds current pc's skill levels +RECT status_rect; //Holds the string "Status:" +RECT pc_status_rect[10]; //Holds first 8 effects on pc +RECT traits_rect; //Holds the string "Traits:" +RECT pc_traits_rect[16]; //Holds pc traits +RECT pc_race_rect; //Holds current pc's race +RECT edit_rect[5][2]; //Buttons that bring up pc edit dialog boxs short current_active_pc = 0; //short dialog_answer; /* Mac stuff globals */ -Rect windRect, Drag_Rect; -bool Multifinder_Present, All_Done = false,diff_depth_ok = false; -EventRecord event; -WindowPtr mainPtr; -Handle menu_bar_handle; -MenuHandle apple_menu,file_menu,reg_menu,extra_menu,edit_menu,items_menu[4]; -bool gInBackground = false,file_in_mem = false,save_blocked = false; -long start_time; +bool All_Done = false,diff_depth_ok = false; +sf::Event event; +sf::RenderWindow mainPtr; +bool gInBackground = false; +fs::path file_in_mem; bool party_in_scen = false; bool scen_items_loaded = false; @@ -69,46 +71,32 @@ short store_flags[3]; //stored_town_maps_type town_maps; //stored_outdoor_maps_type o_maps; -short old_depth = 16; -extern FSSpec file_to_load; - /* Display globals */ -bool sys_7_avail; short give_delays = 0; /* XXX this wasn't defined anywhere, is this right? -jmr */ /* Prototypes */ int main(void); void Initialize(void); -void Set_Window_Drag_Bdry(); void Handle_One_Event(); void Handle_Activate(); bool handle_dialog_event() ; void Handle_Update(); void Mouse_Pressed(); -void handle_menu_choice(long choice); void handle_apple_menu(int item_hit); void handle_file_menu(int item_hit); 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 find_quickdraw(); -void check_sys_7(); -pascal OSErr handle_open_app(AppleEvent *theAppleEvent,AppleEvent *reply,long handlerRefcon); -pascal OSErr handle_open_doc(AppleEvent *theAppleEvent,AppleEvent *reply,long handlerRefcon); -pascal OSErr handle_quit(AppleEvent *theAppleEvent,AppleEvent *reply,long handlerRefcon); -bool verify_restore_quit(short mode); +bool verify_restore_quit(bool mode); void set_up_apple_events(); -void set_pixel_depth(); -void restore_depth(); void handle_item_menu(int item_hit); //item_record_type convert_item (short_item_record_type s_item); bool cur_scen_is_mac, mac_is_intel; -std::string progDir; +extern fs::path progDir; // File io short specials_res_id; -Str255 start_name; -ResFileRefNum graphicsRef, soundRef, mainRef; +char start_name[256]; //#include "pc.itemdata.h" cItemRec item_list[400]; @@ -121,55 +109,21 @@ cScenario scenario; //MW specified return type was 'void', changed to ISO C style for Carbonisation -jmr int main(void) { - start_time = TickCount(); - + init_menubar(); Initialize(); init_fileio(); init_main_buttons(); Set_up_win(); - init_graph_tool(redraw_screen); + init_graph_tool(); init_snd_tool(); - find_quickdraw(); - set_pixel_depth(); - Set_Window_Drag_Bdry(); -// init_buf(); - -// register_flag = get_reg_data(); set_up_apple_events(); - - menu_bar_handle = GetNewMBar(128); - if (menu_bar_handle == NULL) { - SysBeep(2); - ExitToShell(); - } - SetMenuBar(menu_bar_handle); - DisposeHandle(menu_bar_handle); - - apple_menu = GetMenuHandle(500); - file_menu = GetMenuHandle(550); - reg_menu = GetMenuHandle(600); - extra_menu = GetMenuHandle(650); - edit_menu = GetMenuHandle(700); - items_menu[0] = GetMenuHandle(750); - items_menu[1] = GetMenuHandle(751); - items_menu[2] = GetMenuHandle(752); - items_menu[3] = GetMenuHandle(753); - - //init_fonts(); - - DrawMenuBar(); - init_dialogs(); + cDialog::init(); + redraw_screen(); - /* Multifinder_Present = (NGetTrapAddress(_WaitNextEvent, ToolTrap) != - NGetTrapAddress(_Unimplemented, ToolTrap)); */ - /* no need to check this with Carbon -jmr */ - Multifinder_Present = true; - - while (All_Done == false) + while(!All_Done) Handle_One_Event(); - restore_depth(); clean_up_graphtool(); return 0; } @@ -184,80 +138,9 @@ int main(void) void check_for_intel(); void Initialize(void) { - - OSErr error; - //SysEnvRec theWorld; - // unsigned long randSeed; - BitMap screenBits; check_for_intel(); - //Open the resource files we'll be needing - char cPath[768]; - CFBundleRef mainBundle=CFBundleGetMainBundle(); - CFURLRef graphicsURL = CFBundleCopyResourceURL(mainBundle,CFSTR("bladespced.rsrc"),CFSTR(""),NULL); - CFStringRef graphicsPath = CFURLCopyFileSystemPath(graphicsURL, kCFURLPOSIXPathStyle); - CFStringGetCString(graphicsPath, cPath, 512, kCFStringEncodingUTF8); - FSRef gRef, sRef; - FSPathMakeRef((UInt8*)cPath, &gRef, false); - error = FSOpenResourceFile(&gRef, 0, NULL, fsRdPerm, &mainRef); - if (error != noErr) { - printf("Error! Main resource file not found.\n"); - ExitToShell(); - } - char *path = "Scenario Editor/Blades of Exile Graphics"; - error = FSPathMakeRef((UInt8*) path, &gRef, false); - error = FSOpenResourceFile(&gRef, 0, NULL, fsRdPerm, &graphicsRef); - if (error != noErr) { - //SysBeep(1); - printf("Error! File Blades of Exile Graphics not found.\n"); - ExitToShell(); - } - path = "Scenario Editor/Blades of Exile Sounds"; - FSPathMakeRef((UInt8*) path, &sRef, false); - error = FSOpenResourceFile(&sRef, 0, NULL, fsRdPerm, &soundRef); - if (error != noErr) { - //SysBeep(1); - printf("Error! File Blades of Exile Sounds not found.\n"); - ExitToShell(); - } - - CFStringRef progURL = CFURLCopyFileSystemPath(CFBundleCopyBundleURL(mainBundle), kCFURLPOSIXPathStyle); - const char* tmp = CFStringGetCStringPtr(progURL, kCFStringEncodingASCII);//kCFStringEncodingUTF8); - if(tmp == NULL){ - bool success = CFStringGetCString(progURL, cPath, sizeof(cPath), kCFStringEncodingUTF8); - if(success) { - progDir = cPath; - std::cout << cPath << "\n\n" << progDir << "\n\n"; - } else { - std::cout << "Couldn't retrieve application path.\n"; - exit(1); - } - }else progDir = tmp; - //progDir = cPath; - size_t last_slash = progDir.find_last_of('/'); - progDir.erase(last_slash); - std::cout<> 8); - if ((event.modifiers & cmdKey) != 0) { - if (event.what != autoKey) { - BringToFront(mainPtr); - SetPort(GetWindowPort(mainPtr)); - menu_choice = MenuKey(chr); - //kludge to prevent stupid system from messing up the shortcut for 'Save As' - if(HiWord(menu_choice)==550 && LoWord(menu_choice)==1 && (event.modifiers & shiftKey)!=0) - menu_choice = (550<<16) + 2; - handle_menu_choice(menu_choice); - } - } + switch(event.type){ + case sf::Event::KeyPressed: break; - case mouseDown: + case sf::Event::MouseButtonPressed: Mouse_Pressed(); break; - case activateEvt: - Handle_Activate(); + case sf::Event::GainedFocus: + set_cursor(sword_curs); break; - - case updateEvt: - set_pixel_depth(); - Handle_Update(); - break; - - case kHighLevelEvent: - AEProcessAppleEvent(&event); - break; - - case osEvt: - /* 1.02 - must BitAND with 0x0FF to get only low byte */ - switch ((event.message >> 24) & 0x0FF) { /* high byte of message */ - case suspendResumeMessage: /* suspend/resume is also an activate/deactivate */ - gInBackground = (event.message & 1) == 0; // 1 is Resume Mask -// DoActivate(FrontWindow(), !gInBackground); -// current_cursor = 300; - break; - } + + case sf::Event::Closed: + All_Done = verify_restore_quit(false); break; } } - -void Handle_Activate() -{ - GrafPtr old_port; - - GetPort(&old_port); - if (FrontWindow() == mainPtr) - SetPort(GetWindowPort(mainPtr)); - set_cursor(sword_curs); -} - - -void Handle_Update() -{ - WindowPtr the_window; - GrafPtr old_port; - - the_window = (WindowPtr) event.message; - - GetPort (&old_port); - SetPort (GetWindowPort(the_window)); - - BeginUpdate(the_window); - - redraw_screen(); - - EndUpdate(the_window); - - SetPort(old_port); -} - - void Mouse_Pressed() { - WindowPtr the_window; - BitMap screenBits; - short the_part; - long menu_choice; bool try_to_end; - the_part = FindWindow( event.where, &the_window); - - switch (the_part) - { - - case inMenuBar: - menu_choice = MenuSelect(event.where); - handle_menu_choice(menu_choice); - break; - - case inSysWindow: - break; - - case inDrag: - GetQDGlobalsScreenBits(&screenBits); - DragWindow(the_window, event.where, &(screenBits.bounds)); - break; - - case inGoAway: - if (the_window == mainPtr) { - - All_Done = verify_restore_quit(0); - } - else { - /* for (i = 0; i < 12; i++) - if ((the_window == modeless_dialogs[i]) && (modeless_exists[i] == true)) { - CloseDialog(modeless_dialogs[i]); - modeless_exists[i] = false; - SelectWindow(mainPtr); - SetPort(mainPtr); - }*/ - } - break; - - case inContent: - if ((the_window != NULL) && (FrontWindow() != the_window)) { - SetPort(GetWindowPort(the_window)); - SelectWindow(the_window); - SetPort(GetWindowPort(the_window)); - } - else{ - if (the_window == mainPtr) { try_to_end = handle_action(event,0); if (try_to_end == true) - All_Done = verify_restore_quit(0); - } - } - break; - } -} - - -void handle_menu_choice(long choice) -{ - int menu,menu_item; - - if (choice != 0) { - menu = HiWord(choice); - menu_item = LoWord(choice); - - switch (menu) { - case 500: - handle_apple_menu(menu_item); - break; - case 550: - handle_file_menu(menu_item); - break; - case 650: - handle_extra_menu(menu_item); - break; - case 700: - handle_edit_menu(menu_item); - break; - case 750: case 751:case 752:case 753: - handle_item_menu(menu_item + 100 * (menu - 750) - 1); - break; - } - } - - HiliteMenu(0); + All_Done = verify_restore_quit(false); } void handle_apple_menu(int item_hit) { - //Str255 desk_acc_name; + //char desk_acc_name[256]; //short desk_acc_num; switch (item_hit) { case 1: - FCD(1062,0); + cChoiceDlog("about-pced.xml").show(); break; default: //GetItem (apple_menu,item_hit,desk_acc_name); @@ -520,54 +213,55 @@ void handle_apple_menu(int item_hit) void handle_file_menu(int item_hit) { - FSSpec file; + fs::path file; switch (item_hit) { case 1://save - save_party(file_to_load); + save_party(file_in_mem); break; case 2://save as - try{ file = nav_put_party(); - save_party(file); - } catch(no_file_chosen){} + if(!file.empty()) save_party(file); break; case 3://open - if (verify_restore_quit(1) == true){ - try{ - file_to_load = nav_get_party(); - load_party(file_to_load); - } catch(no_file_chosen){} + if(verify_restore_quit(true)){ + file = nav_get_party(); + if(!file.empty()) { + load_party(file); + file_in_mem = file; + } + menu_activate(); } break; - case 5://how to order - give_reg_info(); - break; case 7://quit - All_Done = verify_restore_quit(0); + All_Done = verify_restore_quit(false); break; } } void check_for_intel(){ - SInt32 response; - OSErr err; - err = Gestalt(gestaltSysArchitecture,&response); - if(err != noErr){ - printf("Gestalt error %i\n",err); + int response = CFByteOrderGetCurrent(); + if(response == CFByteOrderUnknown){ + printf("Gestalt error\n"); exit(1); } - if(response == gestaltIntel) mac_is_intel = true; + if(response == CFByteOrderLittleEndian) mac_is_intel = true; else mac_is_intel = false; } +static void display_strings(short nstr, pic_num_t pic) { + cStrDlog display_strings(get_str("pcedit", nstr), "", "Editing party", pic, PIC_DLOG); + display_strings.setSound(57); + display_strings.show(); +} + void handle_extra_menu(int item_hit) { short i; //cVehicle v_boat = {{12,17},{0,0},{0,0},80,true,false}; - if (file_in_mem == false) { - display_strings(20,5,0,0,"Editing party",57,7,PICT_DLG,0); + if(file_in_mem.empty()) { + display_strings(5, 7); return; } switch(item_hit) { @@ -580,19 +274,19 @@ void handle_extra_menu(int item_hit) case 4: if (univ.party.is_split() > 0) { - FCD(909,0); + cChoiceDlog("reunite-first.xml").show(); break; } - FCD(901,0); + cChoiceDlog("leave-town.xml").show(); leave_town(); break; case 5: if (univ.party.is_split() == 0) { - FCD(911,0); + cChoiceDlog("not-split.xml").show(); break; } - FCD(910,0); + cChoiceDlog("reunited.xml").show(); univ.town.p_loc = univ.party.left_at(); for (i = 0; i < 6; i++) if (univ.party[i].main_status >= MAIN_STATUS_SPLIT) @@ -601,29 +295,29 @@ void handle_extra_menu(int item_hit) case 6: - display_strings(20,20,0,0,"Editing party",57,7,PICT_DLG,0); + display_strings(20,7); for (i = 0; i < 4; i++) univ.party.creature_save[i].which_town = 200; break; case 8: // damage - display_strings(20,1,0,0,"Editing party",57,15,PICT_DLG,0); + display_strings(1,15); for (i = 0; i < 6; i++) univ.party[i].cur_health = univ.party[i].max_health; break; case 9: // spell pts - display_strings(20,2,0,0,"Editing party",57,15,PICT_DLG,0); + display_strings(2,15); for (i = 0; i < 6; i++) univ.party[i].cur_sp = univ.party[i].max_sp; break; case 10: // raise dead - display_strings(20,3,0,0,"Editing party",57,15,PICT_DLG,0); + display_strings(3,15); for (i = 0; i < 6; i++) if ((univ.party[i].main_status == MAIN_STATUS_DEAD) || (univ.party[i].main_status == MAIN_STATUS_DUST) || (univ.party[i].main_status == MAIN_STATUS_STONE)) univ.party[i].main_status = MAIN_STATUS_ALIVE; break; case 11: // conditions - display_strings(20,4,0,0,"Editing party",57,15,PICT_DLG,0); + display_strings(4,15); for (i = 0; i < 6; i++) { univ.party[i].status[2] = 0; if (univ.party[i].status[3] < 0) @@ -639,10 +333,10 @@ void handle_extra_menu(int item_hit) case 13: if (party_in_scen == false) { - display_strings(20,25,0,0,"Editing party",57,15,PICT_DLG,0); + display_strings(25,15); break; } - if (FCD(912,0) != 1) + if(cChoiceDlog("leave-scenario.xml",{"okay","cancel"}).show() != "okay") break; remove_party_from_scen(); break; @@ -654,20 +348,16 @@ void handle_edit_menu(int item_hit) { short choice,i,j,k; - if (file_in_mem == false) { - display_strings(20,5,0,0,"Editing party",57,7,PICT_DLG,0); + if(file_in_mem.empty()) { + display_strings(5,7); return; } - if (save_blocked == false) - if ((choice = FCD(904,0)) == 1) - return; - else save_blocked = true; switch(item_hit) { case 1: - display_alchemy(); + display_alchemy(true); break; case 2: // all property - display_strings(20,6,0,0,"Editing party",57,7,PICT_DLG,0); + display_strings(6,7); for (i = 0; i < 30; i++) { univ.party.boats[i].property = false; univ.party.horses[i].property = false; @@ -678,10 +368,10 @@ void handle_edit_menu(int item_hit) break; case 6: // ouit maps if (party_in_scen == false) { - display_strings(20,25,0,0,"Editing party",57,15,PICT_DLG,0); + display_strings(25,15); break; } - display_strings(20,13,0,0,"Editing party",57,15,PICT_DLG,0); + display_strings(13,15); for (i = 0; i < 100; i++) for (j = 0; j < 6; j++) for (k = 0; k < 48; k++) @@ -689,10 +379,10 @@ void handle_edit_menu(int item_hit) break; case 7: // town maps if (party_in_scen == false) { - display_strings(20,25,0,0,"Editing party",57,15,PICT_DLG,0); + display_strings(25,15); break; } - display_strings(20,14,0,0,"Editing party",57,15,PICT_DLG,0); + display_strings(14,15); for (i = 0; i < 200; i++) for (j = 0; j < 8; j++) for (k = 0; k < 64; k++) @@ -773,38 +463,16 @@ void handle_item_menu(int item_hit) short choice; cItemRec store_i; - if (file_in_mem == false) { - display_strings(20,5,0,0,"Editing party",57,7,PICT_DLG,0); + if(file_in_mem.empty()) { + display_strings(5,7); return; } - if (save_blocked == false) - if ((choice = FCD(904,0)) == 1) - return; - else save_blocked = true; store_i = item_list[item_hit]; store_i.ident = true; give_to_pc(current_active_pc,store_i,false); draw_items(1); } -void update_item_menu() -{ - short i,j; - MenuHandle item_menu[4]; - Str255 item_name; - - for (i = 0; i < 4; i++) - item_menu[i] = GetMenuHandle(750 + i); - for (j = 0; j < 4; j++){ - DeleteMenuItems(item_menu[j],1,100); - for (i = 0; i < 100; i++) { - sprintf((char *) item_name, " %s",item_list[i + j * 100].full_name.c_str()); - c2pstr((char *) item_name); - AppendMenu(item_menu[j],item_name); - } - } -} - //void set_cursor(CursHandle which_curs) //{ // HLock ((Handle) which_curs); @@ -812,174 +480,30 @@ void update_item_menu() // HUnlock((Handle) which_curs); //} -void find_quickdraw() { - OSErr err; - SInt32 response; - short choice; - err = Gestalt(gestaltQuickdrawVersion, &response); - if (err == noErr) { - if (response == 0x0000) { - choice = choice_dialog(0,1070); - if (choice == 2) - ExitToShell(); - else - diff_depth_ok = true; - } - } - else { - SysBeep(2); - ExitToShell(); - } -} - -void set_pixel_depth() { - GDHandle cur_device; - PixMapHandle screen_pixmap_handle; - OSErr err; - short choice; - static bool diff_depth_ok = false; - short pixel_depth; - - cur_device = GetGDevice(); - - screen_pixmap_handle = (**(cur_device)).gdPMap; - pixel_depth = (**(screen_pixmap_handle)).pixelSize; - - if ((diff_depth_ok == false) && ((pixel_depth <= 16) && (HasDepth(cur_device,16,1,1)) == 0)) { - choice = choice_dialog(0,1070); - if (choice == 1) - ExitToShell(); - if (choice == 2) - diff_depth_ok = true; - } - - if ((pixel_depth != 16) && (diff_depth_ok == true)) - return; - - if (pixel_depth < 16) { - choice = choice_dialog(0,1071); - if (choice == 3) - diff_depth_ok = true; - if (choice == 2) - ExitToShell(); - if (choice == 1) { - err = SetDepth(cur_device,16,1,1); - old_depth = pixel_depth; - } - } -} - -void restore_depth(){ - GDHandle cur_device; - PixMapHandle screen_pixmap_handle; - OSErr err; - cur_device = GetGDevice(); - screen_pixmap_handle = (**(cur_device)).gdPMap; - if(old_depth!=16) - err=SetDepth(cur_device,old_depth,1,1); -} - -void check_sys_7() -{ - OSErr err; - long response; - err = Gestalt(gestaltSystemVersion, &response); - if ((err == noErr) && (response >= 0x0700)) - sys_7_avail = true; - else - sys_7_avail = false; -} - -pascal OSErr handle_open_app(AppleEvent *theAppleEvent,AppleEvent *reply,long handlerRefcon) -{ - return noErr; -} - -pascal OSErr handle_open_doc(AppleEvent *theAppleEvent,AppleEvent *reply,long handlerRefcon) -{ -// FSSpec myFSS; -// AEDescList docList; -// OSErr myErr, ignoreErr; -// long index, itemsInList; -// Size actualSize; -// AEKeyword keywd; -// DescType returnedType; - -/* myErr = AEGetParamDesc(theAppleEvent,keyDirectObject, typeAEList, &docList); - if (myErr == noErr) { - myErr == AECountItems(&docList,&itemsInList); - if (myErr == noErr) { - myErr = AEGetNthPtr(&docList,1,typeFSS, - &keywd,&returnedType,&myFSS, - sizeof(myFSS),&actualSize); - if (myErr == noErr) { - do_apple_event_open(myFSS); - if ((in_startup_mode == false) && (startup_loaded == true)) - end_startup(); - if (in_startup_mode == false) { - post_load(); - } - } - } - }*/ - - - return noErr; -} - -pascal OSErr handle_quit(AppleEvent *theAppleEvent,AppleEvent *reply,long handlerRefcon) -{ - - All_Done = verify_restore_quit(0); - return noErr; -} - -bool verify_restore_quit(short mode) +bool verify_restore_quit(bool mode) //short mode; // 0 - quit 1- restore { - short choice; + std::string choice; - if (file_in_mem == false) + if(file_in_mem.empty()) return true; - choice = FCD(1066 + mode,0); - if (choice == 3) + cChoiceDlog verify(mode ? "save-open.xml" : "save-quit.xml", {"save", "quit", "cancel"}); + choice = verify.show(); + if (choice == "cancel") return false; - if (choice == 2) + if (choice == "quit") return true; - save_party(file_to_load); + save_party(file_in_mem); return true; } - -void set_up_apple_events() -{ - OSErr myErr; - - myErr = AEInstallEventHandler(kCoreEventClass,kAEOpenApplication, - (AEEventHandlerProcPtr) handle_open_app, 0, false); - - if (myErr != noErr) - SysBeep(2); - - myErr = AEInstallEventHandler(kCoreEventClass,kAEOpenDocuments, - (AEEventHandlerProcPtr) handle_open_doc, 0, false); - - if (myErr != noErr) - SysBeep(2); - - myErr = AEInstallEventHandler(kCoreEventClass,kAEQuitApplication, - (AEEventHandlerProcPtr) handle_quit, 0, false); - - if (myErr != noErr) - SysBeep(2); -} //pascal bool cd_event_filter (DialogPtr hDlg, EventRecord *event, short *dummy_item_hit) //{ // char chr,chr2; // short the_type,wind_hit,item_hit; // Handle the_handle = NULL; -// Rect the_rect,button_rect; -// Point the_point; +// RECT the_rect,button_rect; +// location the_point; // CWindowPtr w; // RgnHandle updateRgn; // diff --git a/osx/pcedit/pc.menu.xib b/osx/pcedit/pc.menu.xib new file mode 100644 index 00000000..8241076d --- /dev/null +++ b/osx/pcedit/pc.menu.xib @@ -0,0 +1,1174 @@ + + + + 1070 + 11G63 + 2844 + 1138.51 + 569.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 2844 + + + NSCustomObject + NSMenu + NSMenuItem + + + com.apple.InterfaceBuilder.CocoaPlugin + + + PluginDependencyRecalculationVersion + + + + + NSApplication + + + FirstResponder + + + NSApplication + + + NSFontManager + + + Main Menu + + + + BoE Character Editor + + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + submenuAction: + + BoE Character Editor + + + + About BoE Character Editor + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Preferences… + , + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Services + + 2147483647 + + + submenuAction: + + Services + + _NSServicesMenu + + + + + YES + YES + + + 2147483647 + + + + + + Hide NewApplication + h + 1048576 + 2147483647 + + + + + + Hide Others + h + 1572864 + 2147483647 + + + + + + Show All + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Quit BoE Character Editor + q + 1048576 + 2147483647 + + + + + _NSAppleMenu + + + + + File + + 2147483647 + + + submenuAction: + + File + + + + Open… + o + 1048576 + 2147483647 + + + + + + Close + w + 1048576 + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Save + s + 1048576 + 2147483647 + + + + + + Save As… + S + 1048576 + 2147483647 + + + + + + Revert to Saved + + 2147483647 + + + + + YES + + + + + Free Extras + + 2147483647 + + + submenuAction: + + Free Extras + + + + Edit Gold + + 2147483647 + + + + + + Edit Food + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Leave Town + + 2147483647 + + + + + + Reunite Party + + 2147483647 + + + + + + Make towns forget you + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Heal Damage + + 2147483647 + + + + + + Restore Spell Points + + 2147483647 + + + + + + Raise Dead, Destone, etc + + 2147483647 + + + + + + Remove Bad Conditions + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Remove Party From Scenario + + 2147483647 + + + + + YES + + + + + Special Edit + + 2147483647 + + + submenuAction: + + Special Edit + + + + Item 1 + + 2147483647 + + + + + + Item 2 + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Edit Day + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Add Outdoor Maps + + 2147483647 + + + + + + Add Town Maps + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Add Mage Spells + + 2147483647 + + + + + + Add Priest Spells + + 2147483647 + + + + + + Edit Traits + + 2147483647 + + + + + + Edit Skills + + 2147483647 + + + + + + Edit XP + + 2147483647 + + + + + + YES + YES + + + 2147483647 + + + + + + Set SDF + + 2147483647 + + + + + YES + + + + + Items 1 + + 2147483647 + + + submenuAction: + + Items 1 + + YES + + + + + Items 2 + + 2147483647 + + + submenuAction: + + Items 2 + + + + + + Items 3 + + 2147483647 + + + submenuAction: + + Items 3 + + + + + + Items 4 + + 2147483647 + + + submenuAction: + + Items 4 + + + + + + Help + + 2147483647 + + + submenuAction: + + Help + + + + Boe Character Editor Help + ? + 1048576 + 2147483647 + + + + + _NSHelpMenu + + + + _NSMainMenu + + + + + + + showHelp: + + + + 360 + + + + hide: + + + + 367 + + + + hideOtherApplications: + + + + 368 + + + + unhideAllApplications: + + + + 370 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 29 + + + + + + + + + + + + + + + + 56 + + + + + + + + 103 + + + + + + + + 83 + + + + + + + + 57 + + + + + + + + + + + + + + + + + + 58 + + + + + 134 + + + + + 150 + + + + + 136 + + + + + 144 + + + + + 129 + + + + + 143 + + + + + 236 + + + + + 131 + + + + + + + + 149 + + + + + 145 + + + + + 130 + + + + + 371 + + + + + 81 + + + + + + + + + + + + + 795 + + + + + 79 + + + + + 112 + + + + + 73 + + + + + 72 + + + + + 75 + + + + + 106 + + + + + + + + 111 + + + + + 809 + + + + + + + + 810 + + + + + + + + + + + + + + + + + + + + 811 + + + + + 812 + + + + + 813 + + + + + 814 + + + + + + + + 819 + + + + + + + + 820 + + + + + + + + 821 + + + + + + + + 822 + + + + + + + + 815 + + + + + + + + + + + + + + + + + + + + + + 818 + + + + + 817 + + + + + 816 + + + + + 827 + + + + + + 831 + + + + + + 835 + + + + + + 843 + + + + + + 847 + + + + + 848 + + + + + 849 + + + + + 850 + + + + + 851 + + + + + 852 + + + + + 853 + + + + + 854 + + + + + 855 + + + + + 856 + + + + + 857 + + + + + 858 + + + + + 859 + + + + + 860 + + + + + 861 + + + + + 862 + + + + + 863 + + + + + 864 + + + + + 865 + + + + + 866 + + + + + 867 + + + + + 868 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + 868 + + + 0 + IBCocoaFramework + YES + 3 + + {11, 11} + {10, 3} + + YES + + diff --git a/osx/pcedit/pc.menus.h b/osx/pcedit/pc.menus.h new file mode 100644 index 00000000..c95c5eca --- /dev/null +++ b/osx/pcedit/pc.menus.h @@ -0,0 +1,16 @@ +// +// pc.menus.h +// BoE +// +// Created by Celtic Minstrel on 14-04-15. +// +// + +#ifndef BoE_pc_menus_h +#define BoE_pc_menus_h + +void init_menubar(); +void update_item_menu(); +void menu_activate(); + +#endif diff --git a/osx/pcedit/pc.menus.mac.mm b/osx/pcedit/pc.menus.mac.mm new file mode 100644 index 00000000..2897f539 --- /dev/null +++ b/osx/pcedit/pc.menus.mac.mm @@ -0,0 +1,148 @@ +// +// pc.menus.mac.mm +// BoE +// +// Created by Celtic Minstrel on 14-04-15. +// +// + +#include "pc.menus.h" +#include +#include "item.h" +#include "scenario.h" + +#ifndef __APPLE__ +#error pc.menus.mm is Mac-specific code; try compiling pc.menus.win.cpp instead +#endif + +using MenuHandle = NSMenu*; + +extern void handle_apple_menu(int item_hit); +extern void handle_file_menu(int item_hit); +extern void handle_extra_menu(int item_hit); +extern void handle_edit_menu(int item_hit); +extern void handle_item_menu(int item_hit); + +extern cScenario scenario; +extern fs::path file_in_mem; +MenuHandle menu_bar_handle; +MenuHandle apple_menu, file_menu, reg_menu, extra_menu, items_menu[4]; + +@interface MenuHandler : NSObject +-(void) fileMenu:(id) sender; +-(void) freeMenu:(id) sender; +-(void) specMenu:(id) sender; +-(void) itemMenu:(id) sender; +-(void) helpMenu:(id) sender; +@end + +@interface ItemWrapper : NSObject ++(id) withItem:(int) theItem; +-(cItemRec&) item; +-(void) setItem:(int) theItem; +@end + +static void setMenuCallback(NSMenuItem* item, id targ, SEL selector, int num) { + [item setTarget: targ]; + [item setAction: selector]; + [item setRepresentedObject: [[NSNumber numberWithInt: num] retain]]; +} + +void init_menubar() { + NSApplication* app = [NSApplication sharedApplication]; + [NSBundle loadNibNamed: @"pc.menu" owner: app]; + menu_bar_handle = [app mainMenu]; + + apple_menu = [[menu_bar_handle itemWithTitle: @"BoE Character Editor"] submenu]; + file_menu = [[menu_bar_handle itemWithTitle: @"File"] submenu]; + reg_menu = [[menu_bar_handle itemWithTitle: @"Free Extras"] submenu]; + extra_menu = [[menu_bar_handle itemWithTitle: @"Special Edit"] submenu]; + items_menu[0] = [[menu_bar_handle itemWithTitle: @"Items 1"] submenu]; + items_menu[1] = [[menu_bar_handle itemWithTitle: @"Items 2"] submenu]; + items_menu[2] = [[menu_bar_handle itemWithTitle: @"Items 3"] submenu]; + items_menu[3] = [[menu_bar_handle itemWithTitle: @"Items 4"] submenu]; + + MenuHandler* handler = [[[MenuHandler alloc] init] retain]; + setMenuCallback([apple_menu itemWithTitle: @"About BoE Character Editor"], handler, @selector(helpMenu:), 1); + setMenuCallback([apple_menu itemWithTitle: @"Quit BoE Character Editor"], handler, @selector(fileMenu:), 7); + // TODO: Organize the file menu handling function + setMenuCallback([file_menu itemWithTitle: @"Save"], handler, @selector(fileMenu:), 1); + setMenuCallback([file_menu itemWithTitle: @"Save As…"], handler, @selector(fileMenu:), 2); + setMenuCallback([file_menu itemWithTitle: @"Open…"], handler, @selector(fileMenu:), 3); + + for(int i = 0; i < [reg_menu numberOfItems]; i++) + setMenuCallback([reg_menu itemAtIndex: i], handler, @selector(freeMenu:), i); + for(int i = 0; i < [extra_menu numberOfItems]; i++) + setMenuCallback([extra_menu itemAtIndex: i], handler, @selector(specMenu:), i); + + menu_activate(); +} + +void menu_activate() { + if(file_in_mem.empty()) + for(int i = 3; i < [file_menu numberOfItems]; i++) + [[file_menu itemAtIndex: i] setEnabled: NO]; + else for(int i = 3; i < [file_menu numberOfItems]; i++) + [[file_menu itemAtIndex: i] setEnabled: YES]; +} + +void update_item_menu() { + id targ = [[apple_menu itemAtIndex: 1] target]; + cItemRec(& item_list)[400] = scenario.scen_items; + for(int j = 0; j < 4; j++){ + [items_menu[j] removeAllItems]; + for(int i = 0; i < 100; i++) { + ItemWrapper* item = [ItemWrapper withItem: i + 100 * j]; + NSString* item_name = [NSString stringWithCString: item_list[i + j * 100].full_name.c_str() encoding: NSASCIIStringEncoding]; + NSMenuItem* choice = [items_menu[j] addItemWithTitle: item_name action: @selector(itemMenu:) keyEquivalent: nil]; + [choice setTarget: targ]; + [choice setRepresentedObject: item]; + } + } +} + +@implementation MenuHandler +-(void) fileMenu:(id) sender { + handle_file_menu([[sender representedObject] shortValue]); +} + +-(void) freeMenu:(id) sender { + handle_extra_menu([[sender representedObject] shortValue]); +} + +-(void) specMenu:(id) sender { + handle_edit_menu([[sender representedObject] shortValue]); +} + +-(void) itemMenu:(id) sender { + ItemWrapper* item = [sender representedObject]; + cItemRec& theItem = [item item]; +} + +-(void) helpMenu:(id) sender { + int i = [[sender representedObject] intValue]; + if(i == 0); // TODO: "BoE Character Editor Help" + else if(i == 1) handle_apple_menu(i); +} + +@end + +@implementation ItemWrapper { + int itemID; +} + ++(id) withItem:(int) theItem { + ItemWrapper* item = [[ItemWrapper alloc] init]; + [item setItem: theItem]; + return item; +} + +-(void) setItem:(int) theItem { + self->itemID = theItem; +} + +-(cItemRec&) item { + return scenario.scen_items[self->itemID]; +} + +@end diff --git a/osx/tools/fileio.cpp b/osx/tools/fileio.cpp index 08398c05..7bf29eaa 100644 --- a/osx/tools/fileio.cpp +++ b/osx/tools/fileio.cpp @@ -98,7 +98,7 @@ static header_posix_ustar generateTarHeader(const std::string& fileName, unsigne return(header); } -bool load_scenario(fs::path file_to_load){ +bool load_scenario(fs::path file_to_load, bool skip_strings){ short i,n; bool file_ok = false; long len; @@ -155,11 +155,14 @@ bool load_scenario(fs::path file_to_load){ port_item_list(item_data); scenario = *temp_scenario; scenario.append(*item_data); - // TODO: Consider skipping the fread and assignment when len is 0 - for (i = 0; i < 270; i++) { - len = (long) (scenario.scen_str_len[i]); - n = fread(&(scenario.scen_strs(i)), len, 1, file_id); - scenario.scen_strs(i)[len] = 0; + + if(!skip_strings) { + // TODO: Consider skipping the fread and assignment when len is 0 + for (i = 0; i < 270; i++) { + len = (long) (scenario.scen_str_len[i]); + n = fread(&(scenario.scen_strs(i)), len, 1, file_id); + scenario.scen_strs(i)[len] = 0; + } } fclose(file_id); diff --git a/osx/tools/fileio.h b/osx/tools/fileio.h index ee589a24..122959e1 100644 --- a/osx/tools/fileio.h +++ b/osx/tools/fileio.h @@ -14,7 +14,7 @@ namespace fs = boost::filesystem; // TODO: Centralize this alias! -bool load_scenario(fs::path file_to_load); +bool load_scenario(fs::path file_to_load, bool skip_strings = false); bool load_town(short which_town, cTown*& the_town); bool load_town(short which_town, cSpeech*& the_talk); bool load_town_str(short which_town, short which_str, char* str); diff --git a/osx/tools/soundtool.cpp b/osx/tools/soundtool.cpp index 4c81fc95..6cd10720 100644 --- a/osx/tools/soundtool.cpp +++ b/osx/tools/soundtool.cpp @@ -89,6 +89,7 @@ static std::string sound_to_fname_map(snd_num_t snd_num) { void init_snd_tool(){ short i; + ResMgr::setIdMapFn(sound_to_fname_map); // TODO: Might need sound 0, not sure for (i = 1; i < NUM_SOUNDS; i++) { diff --git a/osx/tools/winutil.h b/osx/tools/winutil.h index 660c9e44..4383243f 100644 --- a/osx/tools/winutil.h +++ b/osx/tools/winutil.h @@ -14,6 +14,8 @@ namespace fs = boost::filesystem; // TODO: Centralize this alias +char keyToChar(sf::Keyboard::Key key, bool isShift); + bool isFrontWindow(sf::Window& win); void makeFrontWindow(sf::Window& win); diff --git a/osx/tools/winutil.mac.mm b/osx/tools/winutil.mac.mm index 3226f4d8..ec7b5022 100644 --- a/osx/tools/winutil.mac.mm +++ b/osx/tools/winutil.mac.mm @@ -10,6 +10,66 @@ #include #include +// TODO: I'm sure there's a better way to do this (maybe one that's keyboard layout agnostic) +char keyToChar(sf::Keyboard::Key key, bool isShift) { + using kb = sf::Keyboard; + switch(key) { + case kb::A: return isShift ? 'A' : 'a'; + case kb::B: return isShift ? 'B' : 'b'; + case kb::C: return isShift ? 'C' : 'c'; + case kb::D: return isShift ? 'D' : 'd'; + case kb::E: return isShift ? 'E' : 'e'; + case kb::F: return isShift ? 'F' : 'f'; + case kb::G: return isShift ? 'G' : 'g'; + case kb::H: return isShift ? 'H' : 'h'; + case kb::I: return isShift ? 'I' : 'i'; + case kb::J: return isShift ? 'J' : 'j'; + case kb::K: return isShift ? 'K' : 'k'; + case kb::L: return isShift ? 'L' : 'l'; + case kb::M: return isShift ? 'M' : 'm'; + case kb::N: return isShift ? 'N' : 'n'; + case kb::O: return isShift ? 'O' : 'o'; + case kb::P: return isShift ? 'P' : 'p'; + case kb::Q: return isShift ? 'Q' : 'q'; + case kb::R: return isShift ? 'R' : 'r'; + case kb::S: return isShift ? 'S' : 's'; + case kb::T: return isShift ? 'T' : 't'; + case kb::U: return isShift ? 'U' : 'u'; + case kb::V: return isShift ? 'V' : 'v'; + case kb::W: return isShift ? 'W' : 'w'; + case kb::X: return isShift ? 'X' : 'x'; + case kb::Y: return isShift ? 'Y' : 'y'; + case kb::Z: return isShift ? 'Z' : 'z'; + case kb::Num1: return isShift ? '!' : '1'; + case kb::Num2: return isShift ? '@' : '2'; + case kb::Num3: return isShift ? '#' : '3'; + case kb::Num4: return isShift ? '$' : '4'; + case kb::Num5: return isShift ? '%' : '5'; + case kb::Num6: return isShift ? '^' : '6'; + case kb::Num7: return isShift ? '&' : '7'; + case kb::Num8: return isShift ? '*' : '8'; + case kb::Num9: return isShift ? '(' : '9'; + case kb::Num0: return isShift ? ')' : '0'; + case kb::Tilde: return isShift ? '~' : '`'; + case kb::Dash: return isShift ? '_' : '-'; + case kb::Equal: return isShift ? '+' : '='; + case kb::LBracket: return isShift ? '{' : '['; + case kb::RBracket: return isShift ? '}' : ']'; + case kb::SemiColon: return isShift ? ':' : ';'; + case kb::Quote: return isShift ? '"' : '\''; + case kb::Comma: return isShift ? '<' : ','; + case kb::Period: return isShift ? '>' : '.'; + case kb::Slash: return isShift ? '?' : '/'; + case kb::BackSlash: return isShift ? '|' : '\\'; + case kb::Tab: return '\t'; + case kb::Space: return ' '; + case kb::Return: return '\n'; + case kb::BackSpace: return '\b'; + case kb::Delete: return '\x7f'; + } + return 0; +} + bool isFrontWindow(sf::Window& win) { sf::WindowHandle handle = win.getSystemHandle(); id nsHandle = id(handle); diff --git a/rsrc/dialogs/about-pced.xml b/rsrc/dialogs/about-pced.xml new file mode 100644 index 00000000..e3949d9f --- /dev/null +++ b/rsrc/dialogs/about-pced.xml @@ -0,0 +1,39 @@ + + + + + + + + Blades of Exile Character Editor v1.0.1
+ Copyright 1997 Jeff Vogel, All rights reserved. +
+ + Blades of Exile (with the editor, hint book, and fully usable scenario editor) is $30. + For information on how to order, select 'How To Order' from the File menu. + + + Comments and questions? + The creators of Exile want to hear them. + Send them to: + + + Internet: SpidWeb@spidweb.com
+ America Online: SpidWeb
+ Compuserve: 76463,1521
+ WWW: http://www.spidweb.com +
+ + The Blades of Exile Editor is brought to you by Spiderweb Software -
+ "Where our aberrations become your reality."
+ "Blades of Exile" and Spiderweb Software are trademarks of Spiderweb Software. +
+ + CREDITS:
+ Concept, Design, Programming: Jeff Vogel
+ Graphics: Andrew Hunter (Wormius@aol.com)
+ Other Programming: Mariann Krizsan +
+
\ No newline at end of file diff --git a/rsrc/dialogs/edit-day.xml b/rsrc/dialogs/edit-day.xml new file mode 100644 index 00000000..dc7864a0 --- /dev/null +++ b/rsrc/dialogs/edit-day.xml @@ -0,0 +1,15 @@ + + + + + + What day would you like it to be? + + + Warning: Changing the day can have dramatically unexpected effects. + Towns will reappear. + People will be shifted around. + The time limits on your jobs may expire. + Back up your save file before doing this. + + \ No newline at end of file diff --git a/rsrc/dialogs/edit-xp.xml b/rsrc/dialogs/edit-xp.xml new file mode 100644 index 00000000..c0ab2c9d --- /dev/null +++ b/rsrc/dialogs/edit-xp.xml @@ -0,0 +1,16 @@ + + + + + + Changing experience: + + Enter how much experience you want this character to have. + Note that the character will not gain any more levels until the character earns at least 1 point more point of experience in the game. + The most you can give is 10000. + + Experience for each level: + + Amount of experience: + + \ No newline at end of file diff --git a/rsrc/dialogs/leave-scenario.xml b/rsrc/dialogs/leave-scenario.xml new file mode 100644 index 00000000..aa160966 --- /dev/null +++ b/rsrc/dialogs/leave-scenario.xml @@ -0,0 +1,12 @@ + + + + + + + Selecting this option removes your party from the scenario they’re currently in. + All of their progress in that adventure is forgotten ... + if you want to play it again, you will need to start over from the very beginning. + + + diff --git a/rsrc/dialogs/leave-town.xml b/rsrc/dialogs/leave-town.xml new file mode 100644 index 00000000..680ef9a7 --- /dev/null +++ b/rsrc/dialogs/leave-town.xml @@ -0,0 +1,7 @@ + + + + + + Your party will now be outdoors. + diff --git a/rsrc/dialogs/not-split.xml b/rsrc/dialogs/not-split.xml new file mode 100644 index 00000000..d932a82e --- /dev/null +++ b/rsrc/dialogs/not-split.xml @@ -0,0 +1,7 @@ + + + + + + Your party is not split up! + diff --git a/rsrc/dialogs/reunite-first.xml b/rsrc/dialogs/reunite-first.xml new file mode 100644 index 00000000..66cf29a2 --- /dev/null +++ b/rsrc/dialogs/reunite-first.xml @@ -0,0 +1,10 @@ + + + + + + + You cannot use this option while the party is split up. + Select Reunite party from this menu. + + diff --git a/rsrc/dialogs/reunited.xml b/rsrc/dialogs/reunited.xml new file mode 100644 index 00000000..92c291f0 --- /dev/null +++ b/rsrc/dialogs/reunited.xml @@ -0,0 +1,13 @@ + + + + + + + Your party is now reunited. + You are located where you were when you split up. + Warning - + doing this can trap your party if you didn't do something you needed to do while split up. + Be sure to back up your save file before saving this change. + + diff --git a/rsrc/dialogs/save-open.xml b/rsrc/dialogs/save-open.xml new file mode 100644 index 00000000..bb4be387 --- /dev/null +++ b/rsrc/dialogs/save-open.xml @@ -0,0 +1,9 @@ + + + + + + + + Do you want to save before opening a new file? + diff --git a/rsrc/dialogs/save-quit.xml b/rsrc/dialogs/save-quit.xml new file mode 100644 index 00000000..d442eca8 --- /dev/null +++ b/rsrc/dialogs/save-quit.xml @@ -0,0 +1,9 @@ + + + + + + + + Do you want to save before quitting? + diff --git a/rsrc/strings/pcedit.txt b/rsrc/strings/pcedit.txt new file mode 100644 index 00000000..b84cd43e --- /dev/null +++ b/rsrc/strings/pcedit.txt @@ -0,0 +1,27 @@ +All of your character's damage has now been healed. Dead characters are still dead. +All of your characters (even dead ones) now have their maximum number of spell points. +All of your characters who were dead (or dust, or stoned) are now alive and intact. You may wish to select Heal Party now. +All negative conditions (poison, dumbfounding, disease, paralysis, etc.) have been removed from your characters (even dead ones). +Before you can do this, you need to load in an Blades of Exile save file. Select Open from the file menu. +All boats and horses are now your property. +Any major NPCs you may have slain, such as Erika or the dragons, are now alive again. You should now use the Leave Town and then Reset Towns menu items to make sure the characters appear. +You are now considered a member of the Anama church. You can no longer cast Mage spells. To get the full effect of this, add Anama Rings above. +If you own Erika Amulets, they are now active. To get the full effect of this, add Erika Amulets above. +If a job dispatcher is angry at you for making a late delivery, he/she has just forgiven you. +If you belong to the Anama, you are no longer a member. If you robbed the Anama temple in Shayder, the people there will no longer attack you on sight. +If you slew the vampire Vahkohs but did not destroy the crystal containing his soul, he is now totally dead and will torment you no longer. +Your party now has the complete maps for the outdoors of your current scenario. +Your party now has the complete maps for the towns in your current scenario. +Your party now has the complete maps for outdoors southern Valorim. If your Save Maps preference is not set, this will have no effect. +Your party now has the complete maps for large (64x64) dungeons, and for Valorim's 5 large cities. If your Save Maps preference is not set, this will have no effect. +Your party now has the complete maps for medium (64x64) dungeons, and for medium size cities. If your Save Maps preference is not set, this will have no effect. +Your party now has the complete maps for small (32x32) dungeons, and for small huts, etc. across the Valorim countryside. If your Save Maps preference is not set, this will have no effect. +Your party now has the complete maps for thge small towns dotting the Valorim countryside. If your Save Maps preference is not set, this will have no effect. +Your save file no longer contains information on the towns you've visited. Monsters have reappeared, angry guards have forgotten you, etc. Note, if you are in town now, the game will still remember what happened in this town. +The Tower of Magi timer is not currently running, so this will have no effect. +You now have a bit more time before the Tower of Magi timer runs out. This time can be used to accumulate potions, train, and do other things to help you survive. Note that the Tower of Magi messages will eventually repeat themselves. +If your characters became addicted to Skribbane herb, the addiction is now cured. +You are now able to see all dungeons and towns, whether or not someone has told you about them. +You can only use this feature if the current party is in a scenario. + +