Merge remote-tracking branch 'origin/master' into waterbox2
# Conflicts: # BizHawk.Client.EmuHawk/MainForm.Designer.cs # BizHawk.Client.EmuHawk/MainForm.cs
This commit is contained in:
commit
f99a080e60
|
@ -270,6 +270,7 @@ sha1:81D72ACD08A6255AE44639D40D6D90C1EFCF61AF B 77-in-1 (NT141) [p1][b1] NES bo
|
|||
sha1:1C3771B7F116F439D684D04DF792570271C93F86 75 Bingo (Sachen-English) [U] NES board=Sachen_CNROM
|
||||
sha1:4097D5A814308E39D592466B60B64862699CC22A 2-in-1 - Yuu Yuu + Dragonball Z [p1][!] NES board=MAPPER023_BMC
|
||||
sha1:4C499A857087E6C121522435786792A2E4105AC1 Fuuun Shaolin Kyo (FDS Conversion) (Unl) [U][!] NES board=UNIF_UNL-LH10;WRAM=8;VRAM=8
|
||||
sha1:CAAC1E829133851648BA7C7CD6EAA7D26A464999 Metal Fighter (Asia) (Unl) (Sachen) NES board=UNIF_UNL-SA-016-1M;PRG=32;CHR=32;PAD_V=0;PAD_H=1
|
||||
;;;;;;;;;;;;;;;;;;;-----------------------------------------------------------------------
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;-----------------------------------------------------------------------
|
||||
|
@ -294,6 +295,7 @@ sha1:6143D80047FFC17C752078C622A44C3E0CB7466E B Dong Fang de Chuan Shuo The Hyru
|
|||
sha1:CEFEBA536DB507DBDEF8A538F9C332D7A75BF613 You Ling Xing Dong (Ch) NES board=MAPPER192;VRAM=4
|
||||
sha1:DBFCC70CC2DEC7A889429ED542267F0F1BD967BF Ying Xiong Chuan Qi (Ch) NES board=MAPPER224
|
||||
sha1:FFB4706E49B826C6CDD12E502E8AE94FC9810B7F Monty no Doki Doki Daisassou (FDS Conversion) (Unl) [U][!] NES board=UNIF_UNL-LH32;WRAM=8;VRAM=8;PAD_H=1
|
||||
sha1:17473C223453D2D80FCB9DCFA317947287DC5C52 Xing He Zhan Shi (China) (Unl) NES board=WAIXINGMAPPER176
|
||||
|
||||
;wrong vram info
|
||||
sha1:32D71DD6C5A8D78A918FE1B9D6D6C4A570D9652D Oeka Kids Anpanman no Hiragana Daisuki (J) NES board=MAPPER096;VRAM=32
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
;;NOTE: These hashes were generated using trimmed ROM headers
|
||||
md5:4332c24e4f3bc72e7fe1b77adf66c2b7 3D Asteroids A78 NTSC=true;board=0
|
||||
md5:0be996d25144966d5541c9eb4919b289 Ace of Aces A78 NTSC=true;board=A78SG
|
||||
md5:aadde920b3aaba03bc10b40bd0619c94 Ace of Aces A78 PAL=true;board=A78SG
|
||||
md5:877dcc97a775ed55081864b2dbf5f1e2 Alien Brigade A78 NTSC=true;board=A78S9
|
||||
md5:de3e9496cb7341f865f27e5a72c7f2f5 Alien Brigade A78 PAL=true;board=A78S9
|
||||
md5:0a9e58ef5eb9ff93246e0fff684dc7f1 Arkanoid (0911) A78 NTSC=true;board=A7832P
|
||||
md5:f9fb84658c5586df159a0c75cc46b54c Asteroids Deluxe A78 NTSC=true;board=0
|
||||
md5:a65f79ad4a0bbdecd59d5f7eb3623fd7 Asteroids Deluxe A78 NTSC=true;board=A7832
|
||||
md5:1baf41de200f26ec643625021290bec2 Asteroids Deluxe A78 PAL=true;board=A7832
|
||||
md5:07342c78619ba6ffcc61c10e907e3b50 Asteroids A78 NTSC=true;board=0
|
||||
md5:8fc3a695eaea3984912d98ed4a543376 Ballblazer A78 NTSC=true;board=A7832P
|
||||
md5:b558814d54904ce0582e2f6a801d03af Ballblazer A78 PAL=true;board=A7832P
|
||||
md5:42682415906c21c6af80e4198403ffda Barnyard Blaster A78 NTSC=true;board=A78SG
|
||||
md5:babe2bc2976688bafb8b23c192658126 Barnyard Blaster A78 PAL=true;board=A78SG
|
||||
md5:f5f6b69c5eb4b55fc163158d1a6b423e Basketbrawl A78 NTSC=true;board=A78SG
|
||||
md5:fba002089fcfa176454ab507e0eb76cb Basketbrawl A78 PAL=true;board=A78SG
|
||||
md5:6010a398070dfacb4c0173d75d73c50a Beef Drop A78 NTSC=true;board=0
|
||||
md5:c534db0a062225b17cfb8ecce0fb9090 Beef Drop A78 NTSC=true;board=0
|
||||
md5:6da5b1b9fa0001e3517f6084ff651b07 Bentley Bear - Crystal Quest A78 NTSC=true;board=A78S9
|
||||
md5:5a09946e57dbe30408a8f253a28d07db Centipede A78 NTSC=true;board=0
|
||||
md5:38c056a48472d9a9e16ebda5ed91dae7 Centipede A78 PAL=true;board=0
|
||||
md5:93e4387864b014c155d7c17877990d1e Choplifter! A78 NTSC=true;board=0
|
||||
md5:59d4edb0230b5acc918b94f6bc94779f Choplifter! A78 PAL=true;board=0
|
||||
md5:441ac404cdc7bcbd4d787f911df7bf0d Color Test A78 NTSC=true;board=0
|
||||
md5:2e8e28f6ad8b9b9267d518d880c73ebb Commando A78 NTSC=true;board=A78SGP
|
||||
md5:55da6c6c3974d013f517e725aa60f48e Commando A78 PAL=true;board=A78SGP
|
||||
md5:db691469128d9a4217ec7e315930b646 Crack'ed A78 NTSC=true;board=A78SG
|
||||
md5:7cbe78fa06f47ba6516a67a4b003c9ee Crack'ed A78 PAL=true;board=A78SG
|
||||
md5:0c9b124355d5328697a3b9e0011353f2 Crazy Brix A78 NTSC=true;board=A7816
|
||||
md5:45e1d527becc96d1715e810d1c07ac27 Crazy Brix A78 NTSC=true;board=A7816
|
||||
md5:fc7db1a9243ce2140f716762b8352a5c Crazy Brix A78 PAL=true;board=A7816
|
||||
md5:a94e4560b6ad053a1c24e096f1262ebf Crossbow A78 NTSC=true;board=A78S9
|
||||
md5:63db371d67a98daec547b2abd5e7aa95 Crossbow A78 PAL=true;board=A78S9
|
||||
md5:179b76ff729d4849b8f66a502398acae CDark Chambers A78 NTSC=true;board=A78SG
|
||||
md5:a2b8e2f159642c4b91de82e9a2928494 Dark Chambers A78 PAL=true;board=A78SG
|
||||
md5:95ac811c7d27af0032ba090f28c107bd Desert Falcon A78 NTSC=true;board=0
|
||||
md5:2d5d99b993a885b063f9f22ce5e6523d Desert Falcon A78 PAL=true;board=0
|
||||
md5:731879ea82fc0ca245e39e036fe293e6 Dig Dug A78 NTSC=true;board=0
|
||||
md5:408dca9fc40e2b5d805f403fa0509436 Dig Dug A78 PAL=true;board=0
|
||||
md5:5e332fbfc1e0fc74223d2e73271ce650 Donkey Kong Junior A78 NTSC=true;board=0
|
||||
md5:4dc5f88243250461bd61053b13777060 Donkey Kong Junior A78 PAL=true;board=0
|
||||
md5:19f1ee292a23636bd57d408b62de79c7 Donkey Kong A78 NTSC=true;board=0
|
||||
md5:8e96ef14ce9b5d84bcbc996b66d6d4c7 Donkey Kong A78 PAL=true;board=0
|
||||
md5:de2ebafcf0e37aaa9d0e9525a7f4dd62 Double Dragon A78 PAL=true;board=A78AC
|
||||
md5:543484c00ba233736bcaba2da20eeea9 Double Dragon A78 NTSC=true;board=A78AC
|
||||
md5:2251a6a0f3aec84cc0aff66fc9fa91e8 F-18 Hornet A78 NTSC=true;board=A78AB
|
||||
md5:e7709da8e49d3767301947a0a0b9d2e6 F-18 Hornet A78 PAL=true;board=A78AB
|
||||
md5:6287727ab36391a62f728bbdee88675c FailSafe A78 NTSC=true;board=A7848
|
||||
md5:d2bb22f704f1610a4c396c51f5188e15 FailSafe A78 NTSC=true;board=A7848
|
||||
md5:d25d5d19188e9f149977c49eb0367cd1 Fatal Run A78 NTSC=true;board=A78SG
|
||||
md5:23505651ac2e47f3637152066c3aa62f Fatal Run A78 PAL=true;board=A78SG
|
||||
md5:e80f24e953563e6b61556737d67d3836 Fight Night A78 PAL=true;board=A78SG
|
||||
md5:07dbbfe612a0a28e283c01545e59f25e Fight Night A78 NTSC=true;board=A78SG
|
||||
md5:cf76b00244105b8e03cdc37677ec1073 Food Fight A78 NTSC=true;board=0
|
||||
md5:de0d4f5a9bf1c1bddee3ed2f7ec51209 Food Fight A78 PAL=true;board=0
|
||||
md5:45136d1d9eddf0bebad32995647b3298 Frogger Demo A78 NTSC=true;board=0
|
||||
md5:fb8d803b328b2e442548f7799cfa9a4a Galaga A78 NTSC=true;board=0
|
||||
md5:f5dc7dc8e38072d3d65bd90a660148ce Galaga A78 PAL=true;board=0
|
||||
md5:06204dadc975be5e5e37e7cc66f984cf Gato A78 NTSC=true;board=0
|
||||
md5:0baec96787ce17f390e204de1a136e59 Hat Trick A78 PAL=true;board=0
|
||||
md5:fd9e78e201b6baafddfd3e1fbfe6ba31 Hat Trick A78 NTSC=true;board=0
|
||||
md5:c3672482ca93f70eafd9134b936c3feb Ikari Warriors A78 NTSC=true;board=A78SG
|
||||
md5:8c2c2a1ea6e9a928a44c3151ba5c1ce3 Ikari Warriors A78 PAL=true;board=A78SG
|
||||
md5:1745feadabb24e7cefc375904c73fa4c Impossible Mission Fixed A78 NTSC=true;board=A78SGR
|
||||
md5:baebc9246c087e893dfa489632157180 Impossible Mission A78 NTSC=true;board=A78SGR
|
||||
md5:80dead01ea2db5045f6f4443faa6fce8 Impossible Mission A78 PAL=true;board=A78SGR
|
||||
md5:045fd12050b7f2b842d5970f2414e912 Jinks A78 NTSC=true;board=A78SGR
|
||||
md5:dfb86f4d06f05ad00cf418f0a59a24f7 Jinks A78 PAL=true;board=A78SGR
|
||||
md5:f18b3b897a25ab3885b43b4bd141b396 Joust A78 NTSC=true;board=0
|
||||
md5:f2dae0264a4b4a73762b9d7177e989f6 Joust A78 PAL=true;board=0
|
||||
md5:548ba2e54e4fc45ab84ed634d702c136 Jr. Ms. Pac-Man A78 NTSC=true;board=A7832P
|
||||
md5:6bc2daeb48e28d103a4298a276e7e551 Jr. Pac-Man (Tunnels) A78 NTSC=true;board=A7832P
|
||||
md5:0b3baf47886915dd2eec5da7671bfa63 Jr. Pac-Man A78 NTSC=true;board=A78SGR
|
||||
md5:8281ab17fa3bfc0a6c497d6a4f350061 Jr. Pac-Man A78 NTSC=true;board=A78SGR
|
||||
md5:17b3b764d33eae9b5260f01df7bb9d2f KLAX A78 NTSC=true;board=A78SG
|
||||
md5:5e0a1e832bbcea6facb832fde23a440a Karateka A78 PAL=true;board=A78S4
|
||||
md5:c3a5a8692a423d43d9d28dd5b7d109d9 Karateka A78 NTSC=true;board=0
|
||||
md5:f57d0af323d4e173fb49ed447f0563d7 Kung-Fu Master A78 NTSC=true;board=0
|
||||
md5:2931b75811ad03f3ac9330838f3d231b Kung-Fu Master A78 PAL=true;board=0
|
||||
md5:431ca060201ee1f9eb49d44962874049 Mario Bros. A78 NTSC=true;board=0
|
||||
md5:d2e861306be78e44248bb71d7475d8a3 Mario Bros. A78 PAL=true;board=0
|
||||
md5:37b5692e33a98115e574185fa8398c22 Mat Mania Challenge A78 NTSC=true;board=A78SG
|
||||
md5:6819c37b96063b024898a19dbae2df54 Mat Mania Challenge A78 PAL=true;board=A78SG
|
||||
md5:f2f5e5841e4dda89a2faf8933dc33ea6 Mean 18 Ultimate Golf A78 NTSC=true;board=A78SG
|
||||
md5:2e9dbad6c0fa381a6cd1bb9abf98a104 Mean 18 Ultimate Golf A78 PAL=true;board=A78SG
|
||||
md5:bedc30ec43587e0c98fc38c39c1ef9d0 Meltdown A78 NTSC=true;board=A78SG
|
||||
md5:c80155d7eec9e3dcb79aa6b83c9ccd1e Meltdown A78 PAL=true;board=A78SG
|
||||
md5:b02f93661f4b7e712810d2bf8e02ad79 Meteor Shower A78 NTSC=true;board=A7816
|
||||
md5:2f1f199ecc2b414d28e01f0de53ca8f7 Meteor Shower A78 PAL=true;board=A7816
|
||||
md5:bc1e905db1008493a9632aa83ab4682b Midnight Mutants A78 NTSC=true;board=A78SG
|
||||
md5:6794ea31570eba0b88a0bf1ead3f3f1b Midnight Mutants A78 PAL=true;board=A78SG
|
||||
md5:017066f522908081ec3ee624f5e4a8aa Missing in Action A78 NTSC=true;board=A78S9
|
||||
md5:d0f46bf92ed6e7b1cce63278420cae8a Missing in Action A78 NTSC=true;board=A78S9
|
||||
md5:9ff38ea62004201d870caa8bd9463525 Moon Cresta A78 NTSC=true;board=A7832
|
||||
md5:3bc8f554cf86f8132a623cc2201a564b Motor Psycho A78 NTSC=true;board=A78SG
|
||||
md5:5330bfe428a6b601b7e76c2cfc4cd049 Motor Psycho A78 PAL=true;board=A78SG
|
||||
md5:fc0ea52a9fac557251b65ee680d951e5 Ms. Pac-Man A78 NTSC=true;board=0
|
||||
md5:56469e8c5ff8983c6cb8dadc64eb0363 Ms. Pac-Man A78 PAL=true;board=0
|
||||
md5:220121f771fc4b98cef97dc040e8d378 Ninja Golf A78 NTSC=true;board=A78SG
|
||||
md5:ea0c859aa54fe5eaf4c1f327fab06221 Ninja Golf A78 PAL=true;board=A78SG
|
||||
md5:74569571a208f8b0b1ccfb22d7c914e1 One on One Basketball A78 NTSC=true;board=0
|
||||
md5:8dba0425f0262e5704581d8757a1a6e3 One on One Basketball A78 PAL=true;board=0
|
||||
md5:5d7bc7092de69095137456733e7b685d Pac-Man Collection A78 NTSC=true;board=0
|
||||
md5:90223a8a363bdf643a19d0f97e63b1b2 PacArcade A78 NTSC=true;board=A7816
|
||||
md5:386bded4a944bae455fedf56206dd1dd Pete Rose Baseball A78 PAL=true;board=0
|
||||
md5:1a5207870dec6fae9111cb747e20d8e3 Pete Rose Baseball A78 NTSC=true;board=0
|
||||
md5:05f43244465943ce819780a71a5b572a Pitfighter A78 NTSC=true;board=A78S4
|
||||
md5:33aea1e2b6634a1dec8c7006d9afda22 Planet Smashers A78 NTSC=true;board=A78SG
|
||||
md5:2837a8fd49b7fc7ccd70fd45b69c5099 Planet Smashers A78 PAL=true;board=A78SG
|
||||
md5:86546808dc60961cdb1b20e761c50ab1 Plutos A78 NTSC=true;board=A78SGR
|
||||
md5:584582bb09ee8122e7fc09dc7d1ed813 Pole Position II A78 NTSC=true;board=0
|
||||
md5:865457e0e0f48253b08f77b9e18f93b2 Pole Position II A78 PAL=true;board=0
|
||||
md5:66e7230f7ef9d14db82d76b06b241bc0 Q-bert A78 NTSC=true;board=A7832
|
||||
md5:ac03806cef2558fc795a7d5d8dba7bc0 Rampage A78 NTSC=true;board=A78AC
|
||||
md5:383ed9bd1efb9b6cb3388a777678c928 Realsports Baseball A78 NTSC=true;board=A78S4
|
||||
md5:8f7eb10ad0bd75474abf0c6c36c08486 Rescue on Fractalus A78 NTSC=true;board=A7832
|
||||
md5:43525a0405184875c2ecfd0196886a34 Rip Off A78 NTSC=true;board=A7816
|
||||
md5:106b409c6f4c219b1a3b3d099ead3b2b Rip Off A78 PAL=true;board=0A7816
|
||||
md5:505f05e7f161f62ccd749dab3c4a204b Robot Finds Kitten A78 NTSC=true;board=A7832
|
||||
md5:66ecaafe1b82ae68ffc96267aaf7a4d7 Robotron 2084 A78 NTSC=true;board=0
|
||||
md5:ae85689b21bdf85cb9dc57c3b1fec9db Santa Simon A78 NTSC=true;board=A7848
|
||||
md5:57651b6c8e62811fab0361cea537b79c Scramble A78 NTSC=true;board=0
|
||||
md5:c265cfd65534a4514f226cb4c7f7d6bf Scramble A78 NTSC=true;board=0
|
||||
md5:1ee26fc6b06b4c9ba74931914b7e719d Scramble A78 PAL=true;board=0
|
||||
md5:65fe82f419f6583a0f9a736242cb303d Scramble A78 PAL=true;board=0
|
||||
md5:980c35ae9625773a450aa7ef51751c04 Scrapyard Dog A78 NTSC=true;board=A78SG
|
||||
md5:53db322c201323fe2ca8f074c0a2bf86 Scrapyard Dog A78 PAL=true;board=A78SG
|
||||
md5:b697d9c2d1b9f6cb21041286d1bbfa7f Sentinel A78 NTSC=true;board=A78SG
|
||||
md5:5469b4de0608f23a5c4f98f331c9e75f Sentinel A78 PAL=true;board=A78SG
|
||||
md5:2d643ac548c40e58c99d0fe433ba4ba0 Sirius A78 NTSC=true;board=A78SGR
|
||||
md5:a84c1b2300fbfbf21b1c02387f613dad Space Duel A78 PAL=true;board=0
|
||||
md5:771cb4609347657f63e6f0eb26036e35 Space Duel A78 NTSC=true;board=A7832
|
||||
md5:6adf79558a3d7f5beca1bb8d34337417 Space Invaders A78 NTSC=true;board=0
|
||||
md5:cbb0746192540a13b4c7775c7ce2021f Summer Games A78 NTSC=true;board=A78SGR
|
||||
md5:cc18e3b37a507c4217eb6cb1de8c8538 Super Huey UH-IX A78 NTSC=true;board=0
|
||||
md5:162f9c953f0657689cc74ab20b40280f Super Huey UH-IX A78 PAL=true;board=0
|
||||
md5:59b5793bece1c80f77b55d60fb39cb94 Super Skateboardin' A78 NTSC=true;board=0
|
||||
md5:95d7c321dce8f57623a9c5b4947bb375 Super Skateboardin' A78 PAL=true;board=0
|
||||
md5:5c4f752371a523f15e9980fea73b874d Tank Command A78 NTSC=true;board=A78S4
|
||||
md5:3bb9c8d9adc912dd7f8471c97445cd8d Titlematch Pro Wrestling A78 PAL=true;board=0
|
||||
md5:1af475ff6429a160752b592f0f92b287 Titlematch Pro Wrestling A78 NTSC=true;board=0
|
||||
md5:c3903ab01a51222a52197dbfe6538ecf Tomcat F14 A78 NTSC=true;board=0
|
||||
md5:682338364243b023ecc9d24f0abfc9a7 Tomcat F14 A78 PAL=true;board=0
|
||||
md5:208ef955fa90a29815eb097bce89bace Touchdown Football A78 NTSC=true;board=A78SG
|
||||
md5:8d64763db3100aadc552db5e6868506a Tower Toppler A78 NTSC=true;board=A78S4R
|
||||
md5:32a37244a9c6cc928dcdf02b45365aa8 Tower Toppler A78 PAL=true;board=A78S4R
|
||||
md5:412cc5bfa08bd03244b9c4e8d46cd0a0 Wasp (Standard Edition) A78 NTSC=true;board=A7832
|
||||
md5:427cb05d0a1abb068998e2760d77f4fb Water Ski A78 NTSC=true;board=A78S4
|
||||
md5:3799d72f78dda2ee87b0ef8bf7b91186 Winter Games A78 NTSC=true;board=A78SGR
|
||||
md5:6813ffff510f930c867b3f0aba78ac85 Worm (0703) A78 NTSC=true;board=A7816
|
||||
md5:05fb699db9eef564e2fe45c568746dbc Xenophobe A78 NTSC=true;board=A78SG
|
||||
md5:70937c3184f0be33d06f7f4382ca54de Xenophobe A78 PAL=true;board=A78SG
|
||||
md5:d7dc17379aa25e5ae3c14b9e780c6f6d Xevious A78 NTSC=true;board=0
|
||||
md5:b1a9f196ce5f47ca8caf8fa7bc4ca46c Xevious A78 PAL=true;board=0
|
||||
md5:ce6fbdc7b037a4efdaf87267f5f292cc b*nQ A78 NTSC=true;board=0
|
|
@ -86,8 +86,8 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public virtual string ReadName => Name;
|
||||
public virtual string WriteName => Ext != null ? Name + '.' + Ext : Name;
|
||||
public string ReadName => Name;
|
||||
public string WriteName => Ext != null ? Name + '.' + Ext : Name;
|
||||
|
||||
public string Name { get; protected set; }
|
||||
public string Ext { get; protected set; }
|
||||
|
@ -203,7 +203,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
private static byte[] zipheader = { 0x50, 0x4b, 0x03, 0x04 };
|
||||
private static readonly byte[] Zipheader = { 0x50, 0x4b, 0x03, 0x04 };
|
||||
public static BinaryStateLoader LoadAndDetect(string filename, bool isMovieLoad = false)
|
||||
{
|
||||
var ret = new BinaryStateLoader();
|
||||
|
@ -212,7 +212,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
byte[] data = new byte[4];
|
||||
fs.Read(data, 0, 4);
|
||||
if (!data.SequenceEqual(zipheader))
|
||||
if (!data.SequenceEqual(Zipheader))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
// zero 09-mar-2015 - not sure if adding + 1 here is correct.. but... maybe?
|
||||
var output = (input * multiplier + 10000.0f) * (range.Max - range.Min + 1) / 20000.0f + range.Min;
|
||||
var output = (((input * multiplier) + 10000.0f) * (range.Max - range.Min + 1) / 20000.0f) + range.Min;
|
||||
|
||||
// zero 09-mar-2015 - at this point, we should only have integers, since thats all 100% of consoles ever see
|
||||
// if this becomes a problem we can add flags to the range and update GUIs to be able to display floats
|
||||
|
|
|
@ -96,8 +96,9 @@ namespace BizHawk.Client.Common
|
|||
return resolved.FilePath;
|
||||
}
|
||||
|
||||
public class RealFirmwareReader : IDisposable
|
||||
private class RealFirmwareReader : IDisposable
|
||||
{
|
||||
private readonly List<RealFirmwareFile> _files = new List<RealFirmwareFile>();
|
||||
private SHA1 _sha1 = SHA1.Create();
|
||||
|
||||
public void Dispose()
|
||||
|
@ -117,13 +118,12 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
rff.Hash = _sha1.Hash.BytesToHexString();
|
||||
dict[rff.Hash] = rff;
|
||||
Dict[rff.Hash] = rff;
|
||||
_files.Add(rff);
|
||||
return rff;
|
||||
}
|
||||
|
||||
public readonly Dictionary<string, RealFirmwareFile> dict = new Dictionary<string, RealFirmwareFile>();
|
||||
private readonly List<RealFirmwareFile> _files = new List<RealFirmwareFile>();
|
||||
public Dictionary<string, RealFirmwareFile> Dict { get; } = new Dictionary<string, RealFirmwareFile>();
|
||||
}
|
||||
|
||||
public void DoScanAndResolve()
|
||||
|
@ -184,12 +184,12 @@ namespace BizHawk.Client.Common
|
|||
var hash = fo.Hash;
|
||||
|
||||
// did we find this firmware?
|
||||
if (reader.dict.ContainsKey(hash))
|
||||
if (reader.Dict.ContainsKey(hash))
|
||||
{
|
||||
// rad! then we can use it
|
||||
var ri = new ResolutionInfo
|
||||
{
|
||||
FilePath = reader.dict[hash].FileInfo.FullName,
|
||||
FilePath = reader.Dict[hash].FileInfo.FullName,
|
||||
KnownFirmwareFile = FirmwareDatabase.FirmwareFilesByHash[hash],
|
||||
Hash = hash,
|
||||
Size = fo.Size
|
||||
|
|
|
@ -28,12 +28,10 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public static int SoundMaxBufferDeficitMs;
|
||||
|
||||
public static AutofireController AutofireNullControls;
|
||||
|
||||
// the movie will be spliced inbetween these if it is present
|
||||
public static CopyControllerAdapter MovieInputSourceAdapter = new CopyControllerAdapter();
|
||||
public static CopyControllerAdapter MovieOutputHardpoint = new CopyControllerAdapter();
|
||||
public static MultitrackRewiringControllerAdapter MultitrackRewiringAdapter = new MultitrackRewiringControllerAdapter();
|
||||
public static readonly CopyControllerAdapter MovieInputSourceAdapter = new CopyControllerAdapter();
|
||||
public static readonly CopyControllerAdapter MovieOutputHardpoint = new CopyControllerAdapter();
|
||||
public static readonly MultitrackRewiringControllerAdapter MultitrackRewiringAdapter = new MultitrackRewiringControllerAdapter();
|
||||
|
||||
// dont take my word for it, since the final word is actually in RewireInputChain, but here is a guide...
|
||||
// user -> Input -> ActiveController -> UDLR -> StickyXORPlayerInputAdapter -> TurboAdapter(TBD) -> Lua(?TBD?) -> ..
|
||||
|
@ -47,26 +45,26 @@ namespace BizHawk.Client.Common
|
|||
public static AutofireController AutoFireController;
|
||||
|
||||
// the "output" port for the controller chain.
|
||||
public static CopyControllerAdapter ControllerOutput = new CopyControllerAdapter();
|
||||
public static readonly CopyControllerAdapter ControllerOutput = new CopyControllerAdapter();
|
||||
|
||||
public static UD_LR_ControllerAdapter UD_LR_ControllerAdapter = new UD_LR_ControllerAdapter();
|
||||
public static readonly UD_LR_ControllerAdapter UD_LR_ControllerAdapter = new UD_LR_ControllerAdapter();
|
||||
|
||||
public static AutoFireStickyXorAdapter AutofireStickyXORAdapter = new AutoFireStickyXorAdapter();
|
||||
public static readonly AutoFireStickyXorAdapter AutofireStickyXORAdapter = new AutoFireStickyXorAdapter();
|
||||
|
||||
/// <summary>
|
||||
/// provides an opportunity to mutate the player's input in an autohold style
|
||||
/// </summary>
|
||||
public static StickyXorAdapter StickyXORAdapter = new StickyXorAdapter();
|
||||
public static readonly StickyXorAdapter StickyXORAdapter = new StickyXorAdapter();
|
||||
|
||||
/// <summary>
|
||||
/// Used to AND to another controller, used for Joypad.Set()
|
||||
/// </summary>
|
||||
public static OverrideAdaptor LuaAndAdaptor = new OverrideAdaptor();
|
||||
public static readonly OverrideAdaptor LuaAndAdaptor = new OverrideAdaptor();
|
||||
|
||||
/// <summary>
|
||||
/// fire off one-frame logical button clicks here. useful for things like ti-83 virtual pad and reset buttons
|
||||
/// </summary>
|
||||
public static ClickyVirtualPadController ClickyVirtualPadController = new ClickyVirtualPadController();
|
||||
public static readonly ClickyVirtualPadController ClickyVirtualPadController = new ClickyVirtualPadController();
|
||||
|
||||
public static SimpleController MovieOutputController = new SimpleController();
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ using System.Runtime.InteropServices;
|
|||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable StyleCop.SA1304
|
||||
// ReSharper disable StyleCop.SA1307
|
||||
// ReSharper disable StyleCop.SA1401
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public class QuickBmpFile
|
||||
|
@ -12,23 +16,24 @@ namespace BizHawk.Client.Common
|
|||
#region Structs
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
class BITMAPFILEHEADER
|
||||
private class Bitmapfileheader
|
||||
{
|
||||
public readonly uint bfSize;
|
||||
public ushort bfType;
|
||||
public uint bfSize;
|
||||
|
||||
public ushort bfReserved1;
|
||||
public ushort bfReserved2;
|
||||
public uint bfOffBits;
|
||||
|
||||
public BITMAPFILEHEADER()
|
||||
public Bitmapfileheader()
|
||||
{
|
||||
bfSize = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
|
||||
public static BITMAPFILEHEADER FromStream(Stream s)
|
||||
public static Bitmapfileheader FromStream(Stream s)
|
||||
{
|
||||
var ret = GetObject<BITMAPFILEHEADER>(s);
|
||||
if (ret.bfSize != Marshal.SizeOf(typeof(BITMAPFILEHEADER)))
|
||||
var ret = GetObject<Bitmapfileheader>(s);
|
||||
if (ret.bfSize != Marshal.SizeOf(typeof(Bitmapfileheader)))
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
@ -38,9 +43,9 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
class BITMAPINFOHEADER
|
||||
private class Bitmapinfoheader
|
||||
{
|
||||
public uint biSize;
|
||||
public readonly uint biSize;
|
||||
public int biWidth;
|
||||
public int biHeight;
|
||||
public ushort biPlanes;
|
||||
|
@ -52,15 +57,15 @@ namespace BizHawk.Client.Common
|
|||
public uint biClrUsed;
|
||||
public uint biClrImportant;
|
||||
|
||||
public BITMAPINFOHEADER()
|
||||
public Bitmapinfoheader()
|
||||
{
|
||||
biSize = (uint)Marshal.SizeOf(this);
|
||||
}
|
||||
|
||||
public static BITMAPINFOHEADER FromStream(Stream s)
|
||||
public static Bitmapinfoheader FromStream(Stream s)
|
||||
{
|
||||
var ret = GetObject<BITMAPINFOHEADER>(s);
|
||||
if (ret.biSize != Marshal.SizeOf(typeof(BITMAPINFOHEADER)))
|
||||
var ret = GetObject<Bitmapinfoheader>(s);
|
||||
if (ret.biSize != Marshal.SizeOf(typeof(Bitmapinfoheader)))
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
@ -141,18 +146,18 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
int w = dst.Width;
|
||||
int h = dst.Height;
|
||||
int in_w = src.Width;
|
||||
int in_h = src.Height;
|
||||
int inW = src.Width;
|
||||
int inH = src.Height;
|
||||
int* sp = src.Data;
|
||||
int* dp = dst.Data;
|
||||
|
||||
// vflip along the way
|
||||
for (int j = h - 1; j >= 0; j--)
|
||||
{
|
||||
sp = src.Data + in_w * (j * in_h / h);
|
||||
sp = src.Data + (inW * (j * inH / h));
|
||||
for (int i = 0; i < w; i++)
|
||||
{
|
||||
dp[i] = sp[i * in_w / w];
|
||||
dp[i] = sp[i * inW / w];
|
||||
}
|
||||
|
||||
dp += w;
|
||||
|
@ -163,17 +168,17 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
int w = dst.Width;
|
||||
int h = dst.Height;
|
||||
int in_w = src.Width;
|
||||
int in_h = src.Height;
|
||||
int inW = src.Width;
|
||||
int inH = src.Height;
|
||||
int* sp = src.Data;
|
||||
int* dp = dst.Data;
|
||||
|
||||
for (int j = 0; j < h; j++)
|
||||
{
|
||||
sp = src.Data + in_w * (j * in_h / h);
|
||||
sp = src.Data + (inW * (j * inH / h));
|
||||
for (int i = 0; i < w; i++)
|
||||
{
|
||||
dp[i] = sp[i * in_w / w];
|
||||
dp[i] = sp[i * inW / w];
|
||||
}
|
||||
|
||||
dp += w;
|
||||
|
@ -239,8 +244,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public static unsafe bool Load(IVideoProvider v, Stream s)
|
||||
{
|
||||
var bf = BITMAPFILEHEADER.FromStream(s);
|
||||
var bi = BITMAPINFOHEADER.FromStream(s);
|
||||
var bf = Bitmapfileheader.FromStream(s);
|
||||
var bi = Bitmapinfoheader.FromStream(s);
|
||||
if (bf.bfType != 0x4d42
|
||||
|| bf.bfOffBits != bf.bfSize + bi.biSize
|
||||
|| bi.biPlanes != 1
|
||||
|
@ -250,17 +255,17 @@ namespace BizHawk.Client.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
int in_w = bi.biWidth;
|
||||
int in_h = bi.biHeight;
|
||||
int inW = bi.biWidth;
|
||||
int inH = bi.biHeight;
|
||||
|
||||
byte[] src = new byte[in_w * in_h * 4];
|
||||
byte[] src = new byte[inW * inH * 4];
|
||||
s.Read(src, 0, src.Length);
|
||||
if (v is LoadedBMP)
|
||||
{
|
||||
var l = v as LoadedBMP;
|
||||
l.BufferWidth = in_w;
|
||||
l.BufferHeight = in_h;
|
||||
l.VideoBuffer = new int[in_w * in_h];
|
||||
l.BufferWidth = inW;
|
||||
l.BufferHeight = inH;
|
||||
l.VideoBuffer = new int[inW * inH];
|
||||
}
|
||||
|
||||
int[] dst = v.GetVideoBuffer();
|
||||
|
@ -273,8 +278,8 @@ namespace BizHawk.Client.Common
|
|||
Blit(new BMP
|
||||
{
|
||||
Data = (int*)srcp,
|
||||
Width = in_w,
|
||||
Height = in_h
|
||||
Width = inW,
|
||||
Height = inH
|
||||
},
|
||||
new BMP
|
||||
{
|
||||
|
@ -290,8 +295,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public static unsafe void Save(IVideoProvider v, Stream s, int w, int h)
|
||||
{
|
||||
var bf = new BITMAPFILEHEADER();
|
||||
var bi = new BITMAPINFOHEADER();
|
||||
var bf = new Bitmapfileheader();
|
||||
var bi = new Bitmapinfoheader();
|
||||
bf.bfType = 0x4d42;
|
||||
bf.bfOffBits = bf.bfSize + bi.biSize;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ using BizHawk.Common;
|
|||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores;
|
||||
using BizHawk.Emulation.Cores.Libretro;
|
||||
using BizHawk.Emulation.Cores.Atari.A7800Hawk;
|
||||
using BizHawk.Emulation.Cores.Atari.Atari7800;
|
||||
using BizHawk.Emulation.Cores.Calculators;
|
||||
using BizHawk.Emulation.Cores.Computers.AppleII;
|
||||
|
@ -569,6 +570,7 @@ namespace BizHawk.Client.Common
|
|||
nextEmulator = new C64(
|
||||
nextComm,
|
||||
xmlGame.Assets.Select(a => a.Value),
|
||||
GameInfo.NullInstance,
|
||||
(C64.C64Settings)GetCoreSettings<C64>(),
|
||||
(C64.C64SyncSettings)GetCoreSyncSettings<C64>());
|
||||
break;
|
||||
|
@ -835,14 +837,16 @@ namespace BizHawk.Client.Common
|
|||
break;
|
||||
case "A78":
|
||||
var gamedbpath = Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "EMU7800.csv");
|
||||
nextEmulator = new Atari7800(nextComm, game, rom.RomData, gamedbpath);
|
||||
|
||||
nextEmulator = Global.Config.A78_UseEmu7800
|
||||
? nextEmulator = new Atari7800(nextComm, game, rom.RomData, gamedbpath)
|
||||
: nextEmulator = new A7800Hawk(nextComm, game, rom.RomData, gamedbpath);
|
||||
break;
|
||||
case "C64":
|
||||
var c64 = new C64(nextComm, Enumerable.Repeat(rom.RomData, 1), GetCoreSettings<C64>(), GetCoreSyncSettings<C64>());
|
||||
var c64 = new C64(nextComm, Enumerable.Repeat(rom.RomData, 1), rom.GameInfo, GetCoreSettings<C64>(), GetCoreSyncSettings<C64>());
|
||||
nextEmulator = c64;
|
||||
break;
|
||||
case "GBA":
|
||||
// core = CoreInventory.Instance["GBA", "Meteor"];
|
||||
if (Global.Config.GBA_UsemGBA)
|
||||
{
|
||||
core = CoreInventory.Instance["GBA", "mGBA"];
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
using (new SimpleTime("Save Framebuffer"))
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.Framebuffer, (s) => QuickBmpFile.Save(Global.Emulator.AsVideoProvider(), s, out_w, out_h));
|
||||
bs.PutLump(BinaryStateLump.Framebuffer, s => QuickBmpFile.Save(Global.Emulator.AsVideoProvider(), s, out_w, out_h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,20 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
private class RangBuffer
|
||||
{
|
||||
const int LEN = 4096;
|
||||
const int MASK = 4095;
|
||||
byte[] buff = new byte[LEN];
|
||||
private const int Len = 4096;
|
||||
private const int Mask = 4095;
|
||||
|
||||
int wpos = 0;
|
||||
int rpos = 0;
|
||||
private readonly byte[] _buff = new byte[Len];
|
||||
|
||||
bool writeclosed;
|
||||
bool readclosed;
|
||||
private readonly object _sharedlock = new object();
|
||||
private readonly ManualResetEvent _full = new ManualResetEvent(true);
|
||||
private readonly ManualResetEvent _empty = new ManualResetEvent(false);
|
||||
|
||||
object sharedlock = new object();
|
||||
ManualResetEvent full = new ManualResetEvent(true);
|
||||
ManualResetEvent empty = new ManualResetEvent(false);
|
||||
private int _wpos;
|
||||
private int _rpos;
|
||||
|
||||
private bool _writeclosed;
|
||||
private bool _readclosed;
|
||||
|
||||
public Stream W { get; }
|
||||
public Stream R { get; }
|
||||
|
@ -38,23 +39,23 @@ namespace BizHawk.Client.Common
|
|||
// slow, but faster than using the other overload with byte[1]
|
||||
while (true)
|
||||
{
|
||||
empty.WaitOne();
|
||||
lock (sharedlock)
|
||||
_empty.WaitOne();
|
||||
lock (_sharedlock)
|
||||
{
|
||||
if (rpos != wpos)
|
||||
if (_rpos != _wpos)
|
||||
{
|
||||
byte ret = buff[rpos++];
|
||||
rpos &= MASK;
|
||||
full.Set();
|
||||
byte ret = _buff[_rpos++];
|
||||
_rpos &= Mask;
|
||||
_full.Set();
|
||||
return ret;
|
||||
}
|
||||
else if (writeclosed)
|
||||
else if (_writeclosed)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
empty.Reset();
|
||||
_empty.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,14 +66,14 @@ namespace BizHawk.Client.Common
|
|||
int ret = 0;
|
||||
while (count > 0)
|
||||
{
|
||||
empty.WaitOne();
|
||||
lock (sharedlock)
|
||||
_empty.WaitOne();
|
||||
lock (_sharedlock)
|
||||
{
|
||||
int start = rpos;
|
||||
int end = wpos;
|
||||
int start = _rpos;
|
||||
int end = _wpos;
|
||||
if (end < start) // wrap
|
||||
{
|
||||
end = LEN;
|
||||
end = Len;
|
||||
}
|
||||
|
||||
if (end - start > count)
|
||||
|
@ -83,20 +84,20 @@ namespace BizHawk.Client.Common
|
|||
int c = end - start;
|
||||
if (c > 0)
|
||||
{
|
||||
Buffer.BlockCopy(buff, start, buffer, offset, c);
|
||||
Buffer.BlockCopy(_buff, start, buffer, offset, c);
|
||||
count -= c;
|
||||
ret += c;
|
||||
offset += c;
|
||||
rpos = end & MASK;
|
||||
full.Set();
|
||||
_rpos = end & Mask;
|
||||
_full.Set();
|
||||
}
|
||||
else if (writeclosed)
|
||||
else if (_writeclosed)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
empty.Reset();
|
||||
_empty.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,10 +107,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void CloseRead()
|
||||
{
|
||||
lock (sharedlock)
|
||||
lock (_sharedlock)
|
||||
{
|
||||
readclosed = true;
|
||||
full.Set();
|
||||
_readclosed = true;
|
||||
_full.Set();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,25 +118,24 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
while (true)
|
||||
{
|
||||
full.WaitOne();
|
||||
lock (sharedlock)
|
||||
_full.WaitOne();
|
||||
lock (_sharedlock)
|
||||
{
|
||||
int next = (wpos + 1) & MASK;
|
||||
if (next != rpos)
|
||||
int next = (_wpos + 1) & Mask;
|
||||
if (next != _rpos)
|
||||
{
|
||||
buff[wpos] = value;
|
||||
wpos = next;
|
||||
empty.Set();
|
||||
_buff[_wpos] = value;
|
||||
_wpos = next;
|
||||
_empty.Set();
|
||||
return true;
|
||||
}
|
||||
else if (readclosed)
|
||||
|
||||
if (_readclosed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
full.Reset();
|
||||
}
|
||||
|
||||
_full.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,14 +145,14 @@ namespace BizHawk.Client.Common
|
|||
int ret = 0;
|
||||
while (count > 0)
|
||||
{
|
||||
full.WaitOne();
|
||||
lock (sharedlock)
|
||||
_full.WaitOne();
|
||||
lock (_sharedlock)
|
||||
{
|
||||
int start = wpos;
|
||||
int end = (rpos - 1) & MASK;
|
||||
int start = _wpos;
|
||||
int end = (_rpos - 1) & Mask;
|
||||
if (end < start) // wrap
|
||||
{
|
||||
end = LEN;
|
||||
end = Len;
|
||||
}
|
||||
|
||||
if (end - start > count)
|
||||
|
@ -163,20 +163,20 @@ namespace BizHawk.Client.Common
|
|||
int c = end - start;
|
||||
if (c > 0)
|
||||
{
|
||||
Buffer.BlockCopy(buffer, offset, buff, start, c);
|
||||
Buffer.BlockCopy(buffer, offset, _buff, start, c);
|
||||
count -= c;
|
||||
ret += c;
|
||||
offset += c;
|
||||
wpos = end & MASK;
|
||||
empty.Set();
|
||||
_wpos = end & Mask;
|
||||
_empty.Set();
|
||||
}
|
||||
else if (readclosed)
|
||||
else if (_readclosed)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
full.Reset();
|
||||
_full.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,10 +186,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void CloseWrite()
|
||||
{
|
||||
lock (sharedlock)
|
||||
lock (_sharedlock)
|
||||
{
|
||||
writeclosed = true;
|
||||
empty.Set();
|
||||
_writeclosed = true;
|
||||
_empty.Set();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,11 +262,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private class RStream : Stream
|
||||
{
|
||||
public override bool CanRead { get { return true; } }
|
||||
public override bool CanSeek { get { return false; } }
|
||||
public override bool CanWrite { get { return false; } }
|
||||
public override bool CanRead => true;
|
||||
public override bool CanSeek => false;
|
||||
public override bool CanWrite => false;
|
||||
|
||||
public override void Flush() { }
|
||||
public override long Length { get { return 1; } } // { get { throw new NotSupportedException(); } }
|
||||
public override long Length => 1; // { get { throw new NotSupportedException(); } }
|
||||
public override long Seek(long offset, SeekOrigin origin) { return 0; } // { throw new NotSupportedException(); }
|
||||
public override void SetLength(long value) { throw new NotSupportedException(); }
|
||||
public override long Position
|
||||
|
@ -328,43 +329,43 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
private SevenZip.SevenZipCompressor svc;
|
||||
private readonly SevenZip.SevenZipCompressor _svc;
|
||||
private readonly string _path;
|
||||
|
||||
private bool first = true;
|
||||
private string path;
|
||||
private int compressionlevel;
|
||||
private bool _first = true;
|
||||
private int _compressionlevel;
|
||||
|
||||
public SevenZipWriter(string path, int compressionlevel)
|
||||
{
|
||||
this.path = path;
|
||||
this.compressionlevel = compressionlevel;
|
||||
_path = path;
|
||||
_compressionlevel = compressionlevel;
|
||||
|
||||
svc = new SevenZip.SevenZipCompressor { ArchiveFormat = SevenZip.OutArchiveFormat.Zip };
|
||||
_svc = new SevenZip.SevenZipCompressor { ArchiveFormat = SevenZip.OutArchiveFormat.Zip };
|
||||
|
||||
switch (compressionlevel)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.None;
|
||||
_svc.CompressionLevel = SevenZip.CompressionLevel.None;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.Fast;
|
||||
_svc.CompressionLevel = SevenZip.CompressionLevel.Fast;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.Low;
|
||||
_svc.CompressionLevel = SevenZip.CompressionLevel.Low;
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.Normal;
|
||||
_svc.CompressionLevel = SevenZip.CompressionLevel.Normal;
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.High;
|
||||
_svc.CompressionLevel = SevenZip.CompressionLevel.High;
|
||||
break;
|
||||
case 9:
|
||||
svc.CompressionLevel = SevenZip.CompressionLevel.Ultra;
|
||||
_svc.CompressionLevel = SevenZip.CompressionLevel.Ultra;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -374,19 +375,19 @@ namespace BizHawk.Client.Common
|
|||
var dict = new Dictionary<string, Stream>();
|
||||
var r = new RangBuffer();
|
||||
dict[name] = r.R;
|
||||
if (first)
|
||||
if (_first)
|
||||
{
|
||||
first = false;
|
||||
svc.CompressionMode = SevenZip.CompressionMode.Create;
|
||||
_first = false;
|
||||
_svc.CompressionMode = SevenZip.CompressionMode.Create;
|
||||
}
|
||||
else
|
||||
{
|
||||
svc.CompressionMode = SevenZip.CompressionMode.Append;
|
||||
_svc.CompressionMode = SevenZip.CompressionMode.Append;
|
||||
}
|
||||
|
||||
var task = Task.Factory.StartNew(() =>
|
||||
{
|
||||
svc.CompressStreamDictionary(dict, path);
|
||||
_svc.CompressStreamDictionary(dict, _path);
|
||||
});
|
||||
try
|
||||
{
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the haschode for current insance
|
||||
/// Gets the haschode for current instance
|
||||
/// </summary>
|
||||
/// <returns>This instance hashcode</returns>
|
||||
public override int GetHashCode()
|
||||
|
@ -241,7 +241,7 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
/// <param name="system1">First <see cref="SystemInfo"/></param>
|
||||
/// <param name="system2">Second <see cref="SystemInfo"/></param>
|
||||
/// <returns>True if both system are diferent; otherwise, false</returns>
|
||||
/// <returns>True if both system are different; otherwise, false</returns>
|
||||
public static bool operator !=(SystemInfo system1, SystemInfo system2)
|
||||
{
|
||||
return !(system1 == system2);
|
||||
|
|
|
@ -13,17 +13,10 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class XmlGame
|
||||
{
|
||||
public XmlGame()
|
||||
{
|
||||
Assets = new List<KeyValuePair<string, byte[]>>();
|
||||
AssetFullPaths = new List<string>();
|
||||
GI = new GameInfo();
|
||||
}
|
||||
|
||||
public XmlDocument Xml { get; set; }
|
||||
public GameInfo GI { get; }
|
||||
public IList<KeyValuePair<string, byte[]>> Assets { get; }
|
||||
public IList<string> AssetFullPaths { get; } // TODO: Hack work around, to avoid having to refactor Assets into a object array, should be refactored!
|
||||
public GameInfo GI { get; } = new GameInfo();
|
||||
public IList<KeyValuePair<string, byte[]>> Assets { get; } = new List<KeyValuePair<string, byte[]>>();
|
||||
public IList<string> AssetFullPaths { get; } = new List<string>(); // TODO: Hack work around, to avoid having to refactor Assets into a object array, should be refactored!
|
||||
|
||||
public static XmlGame Create(HawkFile f)
|
||||
{
|
||||
|
@ -52,8 +45,8 @@ namespace BizHawk.Client.Common
|
|||
var n = y.SelectSingleNode("./LoadAssets");
|
||||
if (n != null)
|
||||
{
|
||||
var HashStream = new MemoryStream();
|
||||
int? OriginalIndex = null;
|
||||
var hashStream = new MemoryStream();
|
||||
int? originalIndex = null;
|
||||
|
||||
foreach (XmlNode a in n.ChildNodes)
|
||||
{
|
||||
|
@ -65,9 +58,9 @@ namespace BizHawk.Client.Common
|
|||
var ai = f.FindArchiveMember(filename.Substring(1));
|
||||
if (ai != null)
|
||||
{
|
||||
if (OriginalIndex == null)
|
||||
if (originalIndex == null)
|
||||
{
|
||||
OriginalIndex = f.GetBoundIndex();
|
||||
originalIndex = f.GetBoundIndex();
|
||||
}
|
||||
|
||||
f.Unbind();
|
||||
|
@ -112,16 +105,16 @@ namespace BizHawk.Client.Common
|
|||
using (var sha1 = System.Security.Cryptography.SHA1.Create())
|
||||
{
|
||||
sha1.TransformFinalBlock(data, 0, data.Length);
|
||||
HashStream.Write(sha1.Hash, 0, sha1.Hash.Length);
|
||||
hashStream.Write(sha1.Hash, 0, sha1.Hash.Length);
|
||||
}
|
||||
}
|
||||
|
||||
ret.GI.Hash = HashStream.GetBuffer().HashSHA1(0, (int)HashStream.Length);
|
||||
HashStream.Close();
|
||||
if (OriginalIndex != null)
|
||||
ret.GI.Hash = hashStream.GetBuffer().HashSHA1(0, (int)hashStream.Length);
|
||||
hashStream.Close();
|
||||
if (originalIndex != null)
|
||||
{
|
||||
f.Unbind();
|
||||
f.BindArchiveMember((int)OriginalIndex);
|
||||
f.BindArchiveMember((int)originalIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -15,12 +15,12 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class Binding
|
||||
{
|
||||
public string DisplayName;
|
||||
public string Bindings;
|
||||
public string DefaultBinding;
|
||||
public string TabGroup;
|
||||
public string ToolTip;
|
||||
public int Ordinal = 0;
|
||||
public string DisplayName { get; set; }
|
||||
public string Bindings { get; set; }
|
||||
public string DefaultBinding { get; set; }
|
||||
public string TabGroup { get; set; }
|
||||
public string ToolTip { get; set; }
|
||||
public int Ordinal { get; set; }
|
||||
}
|
||||
|
||||
[Newtonsoft.Json.JsonObject]
|
||||
|
@ -29,9 +29,9 @@ namespace BizHawk.Client.Common
|
|||
public List<Binding> Bindings { get; }
|
||||
|
||||
[Newtonsoft.Json.JsonConstructor]
|
||||
public BindingCollection(List<Binding> Bindings)
|
||||
public BindingCollection(List<Binding> bindings)
|
||||
{
|
||||
this.Bindings = Bindings;
|
||||
Bindings = bindings;
|
||||
}
|
||||
|
||||
public BindingCollection()
|
||||
|
@ -105,15 +105,15 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
private static List<Binding> s_DefaultValues;
|
||||
private static List<Binding> _defaultValues;
|
||||
|
||||
public static List<Binding> DefaultValues
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_DefaultValues == null)
|
||||
if (_defaultValues == null)
|
||||
{
|
||||
s_DefaultValues = new List<Binding>
|
||||
_defaultValues = new List<Binding>
|
||||
{
|
||||
Bind("General", "Frame Advance", "F"),
|
||||
Bind("General", "Rewind", "Shift+R, J1 B7, X1 LeftTrigger"),
|
||||
|
@ -261,13 +261,13 @@ namespace BizHawk.Client.Common
|
|||
};
|
||||
|
||||
// set ordinals based on order in list
|
||||
for (int i = 0; i < s_DefaultValues.Count; i++)
|
||||
for (int i = 0; i < _defaultValues.Count; i++)
|
||||
{
|
||||
s_DefaultValues[i].Ordinal = i;
|
||||
_defaultValues[i].Ordinal = i;
|
||||
}
|
||||
} // if (s_DefaultValues == null)
|
||||
|
||||
return s_DefaultValues;
|
||||
return _defaultValues;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -537,6 +537,7 @@ namespace BizHawk.Client.Common
|
|||
public bool NES_InQuickNES = true;
|
||||
public bool SNES_InSnes9x = false;
|
||||
public bool GBA_UsemGBA = false;
|
||||
public bool A78_UseEmu7800 = true;
|
||||
public bool CoreForcingViaGameDB = true;
|
||||
public string LibretroCore;
|
||||
}
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
{
|
||||
public class AutoPatternBool
|
||||
{
|
||||
public readonly bool SkipsLag = true;
|
||||
public readonly bool[] Pattern;
|
||||
public readonly int Loop = 0;
|
||||
private int _index = 0;
|
||||
|
||||
public AutoPatternBool()
|
||||
{
|
||||
Pattern = new[] { true };
|
||||
|
@ -36,6 +31,12 @@
|
|||
Loop = loop;
|
||||
}
|
||||
|
||||
private int _index;
|
||||
|
||||
public bool SkipsLag { get; } = true;
|
||||
public bool[] Pattern { get; }
|
||||
public int Loop { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the next value and increments index.
|
||||
/// </summary>
|
||||
|
@ -70,11 +71,6 @@
|
|||
|
||||
public class AutoPatternFloat
|
||||
{
|
||||
public readonly bool SkipsLag = true;
|
||||
public readonly float[] Pattern;
|
||||
public readonly int Loop = 0;
|
||||
private int _index;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutoPatternFloat"/> class.
|
||||
/// Defaults to 0.
|
||||
|
@ -85,11 +81,12 @@
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AutoPatternFloat"/> class.
|
||||
/// Simple on/off pattern, using the given values as on/off.
|
||||
/// </summary>
|
||||
public AutoPatternFloat(float valueOn, int on, float valueOff, int off, bool skip_lag = true, int offset = 0, int loop = 0)
|
||||
public AutoPatternFloat(float valueOn, int on, float valueOff, int off, bool skipLag = true, int offset = 0, int loop = 0)
|
||||
{
|
||||
SkipsLag = skip_lag;
|
||||
SkipsLag = skipLag;
|
||||
_index = offset;
|
||||
Loop = loop;
|
||||
Pattern = new float[on + off];
|
||||
|
@ -104,14 +101,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
public AutoPatternFloat(float[] pattern, bool skip_lag = true, int offset = 0, int loop = 0)
|
||||
public AutoPatternFloat(float[] pattern, bool skipLag = true, int offset = 0, int loop = 0)
|
||||
{
|
||||
SkipsLag = skip_lag;
|
||||
SkipsLag = skipLag;
|
||||
Pattern = pattern;
|
||||
_index = offset;
|
||||
Loop = loop;
|
||||
}
|
||||
|
||||
private int _index;
|
||||
|
||||
public bool SkipsLag { get; } = true;
|
||||
public float[] Pattern { get; }
|
||||
public int Loop { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the next value and increments index.
|
||||
/// </summary>
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public ControllerDefinition Definition { get; set; }
|
||||
|
||||
protected WorkingDictionary<string, bool> Buttons = new WorkingDictionary<string, bool>();
|
||||
protected WorkingDictionary<string, float> Floats = new WorkingDictionary<string, float>();
|
||||
protected WorkingDictionary<string, bool> Buttons { get; private set; } = new WorkingDictionary<string, bool>();
|
||||
protected WorkingDictionary<string, float> Floats { get; private set; } = new WorkingDictionary<string, float>();
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
|
@ -43,14 +43,6 @@ namespace BizHawk.Client.Common
|
|||
return Buttons;
|
||||
}
|
||||
|
||||
public void LatchFrom(IController source)
|
||||
{
|
||||
foreach (var button in source.Definition.BoolButtons)
|
||||
{
|
||||
Buttons[button] = source.IsPressed(button);
|
||||
}
|
||||
}
|
||||
|
||||
public void AcceptNewFloats(IEnumerable<Tuple<string, float>> newValues)
|
||||
{
|
||||
foreach (var sv in newValues)
|
||||
|
|
|
@ -58,7 +58,7 @@ namespace BizHawk.Client.Common
|
|||
public bool IsPressed(string button)
|
||||
{
|
||||
var source = Source.IsPressed(button);
|
||||
source ^= stickySet.Contains(button);
|
||||
source ^= _stickySet.Contains(button);
|
||||
return source;
|
||||
}
|
||||
|
||||
|
@ -81,15 +81,13 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public IController Source { get; set; }
|
||||
|
||||
public bool Locked { get; set; } // Pretty much a hack,
|
||||
|
||||
private List<string> _justPressed = new List<string>();
|
||||
|
||||
protected readonly HashSet<string> stickySet = new HashSet<string>();
|
||||
private readonly HashSet<string> _stickySet = new HashSet<string>();
|
||||
|
||||
// if SetFloat() is called (typically virtual pads), then that float will entirely override the Source input
|
||||
// otherwise, the source is passed thru.
|
||||
protected readonly WorkingDictionary<string, float?> _floatSet = new WorkingDictionary<string, float?>();
|
||||
private readonly WorkingDictionary<string, float?> _floatSet = new WorkingDictionary<string, float?>();
|
||||
|
||||
public void SetFloat(string name, float? value)
|
||||
{
|
||||
|
@ -112,30 +110,30 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (isSticky)
|
||||
{
|
||||
stickySet.Add(button);
|
||||
_stickySet.Add(button);
|
||||
}
|
||||
else
|
||||
{
|
||||
stickySet.Remove(button);
|
||||
_stickySet.Remove(button);
|
||||
}
|
||||
}
|
||||
|
||||
public void Unset(string button)
|
||||
{
|
||||
stickySet.Remove(button);
|
||||
_stickySet.Remove(button);
|
||||
_floatSet.Remove(button);
|
||||
}
|
||||
|
||||
public bool IsSticky(string button)
|
||||
{
|
||||
return stickySet.Contains(button);
|
||||
return _stickySet.Contains(button);
|
||||
}
|
||||
|
||||
public HashSet<string> CurrentStickies => stickySet;
|
||||
public HashSet<string> CurrentStickies => _stickySet;
|
||||
|
||||
public void ClearStickies()
|
||||
{
|
||||
stickySet.Clear();
|
||||
_stickySet.Clear();
|
||||
_floatSet.Clear();
|
||||
}
|
||||
|
||||
|
@ -143,13 +141,13 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
foreach (var button in buttons.Where(button => !_justPressed.Contains(button)))
|
||||
{
|
||||
if (stickySet.Contains(button))
|
||||
if (_stickySet.Contains(button))
|
||||
{
|
||||
stickySet.Remove(button);
|
||||
_stickySet.Remove(button);
|
||||
}
|
||||
else
|
||||
{
|
||||
stickySet.Add(button);
|
||||
_stickySet.Add(button);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,13 +205,13 @@ namespace BizHawk.Client.Common
|
|||
|
||||
// TODO: Change the AutoHold adapter to be one of these, with an 'Off' value of 0?
|
||||
// Probably would have slightly lower performance, but it seems weird to have such a similar class that is only used once.
|
||||
private int On;
|
||||
private int Off;
|
||||
private int _on;
|
||||
private int _off;
|
||||
|
||||
public void SetOnOffPatternFromConfig()
|
||||
{
|
||||
On = Global.Config.AutofireOn < 1 ? 0 : Global.Config.AutofireOn;
|
||||
Off = Global.Config.AutofireOff < 1 ? 0 : Global.Config.AutofireOff;
|
||||
_on = Global.Config.AutofireOn < 1 ? 0 : Global.Config.AutofireOn;
|
||||
_off = Global.Config.AutofireOff < 1 ? 0 : Global.Config.AutofireOff;
|
||||
}
|
||||
|
||||
private readonly WorkingDictionary<string, AutoPatternBool> _boolPatterns = new WorkingDictionary<string, AutoPatternBool>();
|
||||
|
@ -221,21 +219,19 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public AutoFireStickyXorAdapter()
|
||||
{
|
||||
On = 1;
|
||||
Off = 1;
|
||||
_on = 1;
|
||||
_off = 1;
|
||||
}
|
||||
|
||||
public IController Source { get; set; }
|
||||
|
||||
public bool Locked { get; set; } // Pretty much a hack,
|
||||
|
||||
public void SetFloat(string name, float? value, AutoPatternFloat pattern = null)
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
if (pattern == null)
|
||||
{
|
||||
pattern = new AutoPatternFloat(value.Value, On, 0, Off);
|
||||
pattern = new AutoPatternFloat(value.Value, _on, 0, _off);
|
||||
}
|
||||
|
||||
_floatPatterns[name] = pattern;
|
||||
|
@ -246,18 +242,13 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public void ClearStickyFloats()
|
||||
{
|
||||
_floatPatterns.Clear();
|
||||
}
|
||||
|
||||
public void SetSticky(string button, bool isSticky, AutoPatternBool pattern = null)
|
||||
{
|
||||
if (isSticky)
|
||||
{
|
||||
if (pattern == null)
|
||||
{
|
||||
pattern = new AutoPatternBool(On, Off);
|
||||
pattern = new AutoPatternBool(_on, _off);
|
||||
}
|
||||
|
||||
_boolPatterns[button] = pattern;
|
||||
|
@ -268,12 +259,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public void Unset(string button)
|
||||
{
|
||||
_boolPatterns.Remove(button);
|
||||
_floatPatterns.Remove(button);
|
||||
}
|
||||
|
||||
public bool IsSticky(string button)
|
||||
{
|
||||
return _boolPatterns.ContainsKey(button) || _floatPatterns.ContainsKey(button);
|
||||
|
|
|
@ -28,14 +28,14 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (!Source.IsPressed(button))
|
||||
{
|
||||
Unpresses.Remove(button);
|
||||
_unpresses.Remove(button);
|
||||
}
|
||||
|
||||
prefix = button.GetPrecedingString("Down");
|
||||
string other = prefix + "Up";
|
||||
if (Source.IsPressed(other))
|
||||
{
|
||||
if (Unpresses.Contains(button))
|
||||
if (_unpresses.Contains(button))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ namespace BizHawk.Client.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
Unpresses.Add(other);
|
||||
_unpresses.Add(other);
|
||||
}
|
||||
else
|
||||
{
|
||||
Unpresses.Remove(button);
|
||||
_unpresses.Remove(button);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,14 +57,14 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (!Source.IsPressed(button))
|
||||
{
|
||||
Unpresses.Remove(button);
|
||||
_unpresses.Remove(button);
|
||||
}
|
||||
|
||||
prefix = button.GetPrecedingString("Up");
|
||||
string other = prefix + "Down";
|
||||
if (Source.IsPressed(other))
|
||||
{
|
||||
if (Unpresses.Contains(button))
|
||||
if (_unpresses.Contains(button))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -74,11 +74,11 @@ namespace BizHawk.Client.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
Unpresses.Add(other);
|
||||
_unpresses.Add(other);
|
||||
}
|
||||
else
|
||||
{
|
||||
Unpresses.Remove(button);
|
||||
_unpresses.Remove(button);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,14 +86,14 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (!Source.IsPressed(button))
|
||||
{
|
||||
Unpresses.Remove(button);
|
||||
_unpresses.Remove(button);
|
||||
}
|
||||
|
||||
prefix = button.GetPrecedingString("Right");
|
||||
string other = prefix + "Left";
|
||||
if (Source.IsPressed(other))
|
||||
{
|
||||
if (Unpresses.Contains(button))
|
||||
if (_unpresses.Contains(button))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -103,11 +103,11 @@ namespace BizHawk.Client.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
Unpresses.Add(other);
|
||||
_unpresses.Add(other);
|
||||
}
|
||||
else
|
||||
{
|
||||
Unpresses.Remove(button);
|
||||
_unpresses.Remove(button);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,14 +115,14 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (!Source.IsPressed(button))
|
||||
{
|
||||
Unpresses.Remove(button);
|
||||
_unpresses.Remove(button);
|
||||
}
|
||||
|
||||
prefix = button.GetPrecedingString("Left");
|
||||
string other = prefix + "Right";
|
||||
if (Source.IsPressed(other))
|
||||
{
|
||||
if (Unpresses.Contains(button))
|
||||
if (_unpresses.Contains(button))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -132,11 +132,11 @@ namespace BizHawk.Client.Common
|
|||
return false;
|
||||
}
|
||||
|
||||
Unpresses.Add(other);
|
||||
_unpresses.Add(other);
|
||||
}
|
||||
else
|
||||
{
|
||||
Unpresses.Remove(button);
|
||||
_unpresses.Remove(button);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ namespace BizHawk.Client.Common
|
|||
return Source.GetFloat(name);
|
||||
}
|
||||
|
||||
private readonly HashSet<string> Unpresses = new HashSet<string>();
|
||||
private readonly HashSet<string> _unpresses = new HashSet<string>();
|
||||
|
||||
public IController Source { get; set; }
|
||||
}
|
||||
|
|
|
@ -17,25 +17,25 @@ namespace BizHawk.Client.Common
|
|||
public sealed class EmulatorLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
[RequiredService]
|
||||
public IEmulator Emulator { get; set; }
|
||||
private IEmulator Emulator { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
public IDebuggable DebuggableCore { get; set; }
|
||||
private IDebuggable DebuggableCore { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
public IDisassemblable DisassemblableCore { get; set; }
|
||||
private IDisassemblable DisassemblableCore { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
private IMemoryDomains MemoryDomains { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
public IInputPollable InputPollableCore { get; set; }
|
||||
private IInputPollable InputPollableCore { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
public IRegionable RegionableCore { get; set; }
|
||||
private IRegionable RegionableCore { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
public IBoardInfo BoardInfo { get; set; }
|
||||
private IBoardInfo BoardInfo { get; set; }
|
||||
|
||||
public Action FrameAdvanceCallback { get; set; }
|
||||
public Action YieldCallback { get; set; }
|
||||
|
|
|
@ -14,13 +14,13 @@ namespace BizHawk.Client.Common
|
|||
public sealed class EventLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
[OptionalService]
|
||||
public IInputPollable InputPollableCore { get; set; }
|
||||
private IInputPollable InputPollableCore { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
public IDebuggable DebuggableCore { get; set; }
|
||||
private IDebuggable DebuggableCore { get; set; }
|
||||
|
||||
[RequiredService]
|
||||
public IEmulator Emulator { get; set; }
|
||||
private IEmulator Emulator { get; set; }
|
||||
|
||||
private readonly LuaFunctionList _luaFunctions = new LuaFunctionList();
|
||||
|
||||
|
|
|
@ -7,11 +7,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public sealed class GameInfoLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
[RequiredService]
|
||||
public IEmulator Emulator { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
public IBoardInfo BoardInfo { get; set; }
|
||||
private IBoardInfo BoardInfo { get; set; }
|
||||
|
||||
public GameInfoLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
|
|
@ -18,19 +18,19 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public override string Name => "memorysavestate";
|
||||
|
||||
private readonly Dictionary<Guid, byte[]> MemorySavestates = new Dictionary<Guid, byte[]>();
|
||||
|
||||
[RequiredService]
|
||||
private IStatable _statableCore { get; set; }
|
||||
private IStatable StatableCore { get; set; }
|
||||
|
||||
private readonly Dictionary<Guid, byte[]> _memorySavestates = new Dictionary<Guid, byte[]>();
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"savecorestate", "creates a core savestate and stores it in memory. Note: a core savestate is only the raw data from the core, and not extras such as movie input logs, or framebuffers. Returns a unique identifer for the savestate")]
|
||||
public string SaveCoreStateToMemory()
|
||||
{
|
||||
var guid = Guid.NewGuid();
|
||||
var bytes = (byte[])_statableCore.SaveStateBinary().Clone();
|
||||
var bytes = (byte[])StatableCore.SaveStateBinary().Clone();
|
||||
|
||||
MemorySavestates.Add(guid, bytes);
|
||||
_memorySavestates.Add(guid, bytes);
|
||||
|
||||
return guid.ToString();
|
||||
}
|
||||
|
@ -42,12 +42,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
try
|
||||
{
|
||||
var state = MemorySavestates[guid];
|
||||
var state = _memorySavestates[guid];
|
||||
|
||||
using (var ms = new MemoryStream(state))
|
||||
using (var br = new BinaryReader(ms))
|
||||
{
|
||||
_statableCore.LoadStateBinary(br);
|
||||
StatableCore.LoadStateBinary(br);
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
@ -60,13 +60,13 @@ namespace BizHawk.Client.Common
|
|||
public void DeleteState(string identifier)
|
||||
{
|
||||
var guid = new Guid(identifier);
|
||||
MemorySavestates.Remove(guid);
|
||||
_memorySavestates.Remove(guid);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes("clearstatesfrommemory", "clears all savestates stored in memory")]
|
||||
public void ClearInMemoryStates()
|
||||
{
|
||||
MemorySavestates.Clear();
|
||||
_memorySavestates.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,17 +21,17 @@ namespace BizHawk.Client.Common
|
|||
: base(lua) { }
|
||||
|
||||
[OptionalService]
|
||||
private NES _neshawk { get; set; }
|
||||
private NES Neshawk { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
private QuickNES _quicknes { get; set; }
|
||||
private QuickNES Quicknes { get; set; }
|
||||
|
||||
[OptionalService]
|
||||
private IMemoryDomains _memoryDomains { get; set; }
|
||||
private IMemoryDomains MemoryDomains { get; set; }
|
||||
|
||||
private bool NESAvailable => _neshawk != null || _quicknes != null;
|
||||
private bool NESAvailable => Neshawk != null || Quicknes != null;
|
||||
|
||||
private bool HasMemoryDOmains => _memoryDomains != null;
|
||||
private bool HasMemoryDOmains => MemoryDomains != null;
|
||||
|
||||
public NesLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
@ -46,7 +46,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
var decoder = new NESGameGenieDecoder(code);
|
||||
var watch = Watch.GenerateWatch(
|
||||
_memoryDomains["System Bus"],
|
||||
MemoryDomains["System Bus"],
|
||||
decoder.Address,
|
||||
WatchSize.Byte,
|
||||
DisplayType.Hex,
|
||||
|
@ -64,14 +64,14 @@ namespace BizHawk.Client.Common
|
|||
"getallowmorethaneightsprites", "Gets the NES setting 'Allow more than 8 sprites per scanline' value")]
|
||||
public bool GetAllowMoreThanEightSprites()
|
||||
{
|
||||
if (_quicknes != null)
|
||||
if (Quicknes != null)
|
||||
{
|
||||
return _quicknes.GetSettings().NumSprites != 8;
|
||||
return Quicknes.GetSettings().NumSprites != 8;
|
||||
}
|
||||
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
return _neshawk.GetSettings().AllowMoreThanEightSprites;
|
||||
return Neshawk.GetSettings().AllowMoreThanEightSprites;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
|
@ -81,16 +81,16 @@ namespace BizHawk.Client.Common
|
|||
"getbottomscanline", "Gets the current value for the bottom scanline value")]
|
||||
public int GetBottomScanline(bool pal = false)
|
||||
{
|
||||
if (_quicknes != null)
|
||||
if (Quicknes != null)
|
||||
{
|
||||
return _quicknes.GetSettings().ClipTopAndBottom ? 231 : 239;
|
||||
return Quicknes.GetSettings().ClipTopAndBottom ? 231 : 239;
|
||||
}
|
||||
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
return pal
|
||||
? _neshawk.GetSettings().PAL_BottomLine
|
||||
: _neshawk.GetSettings().NTSC_BottomLine;
|
||||
? Neshawk.GetSettings().PAL_BottomLine
|
||||
: Neshawk.GetSettings().NTSC_BottomLine;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
|
@ -100,14 +100,14 @@ namespace BizHawk.Client.Common
|
|||
"getclipleftandright", "Gets the current value for the Clip Left and Right sides option")]
|
||||
public bool GetClipLeftAndRight()
|
||||
{
|
||||
if (_quicknes != null)
|
||||
if (Quicknes != null)
|
||||
{
|
||||
return _quicknes.GetSettings().ClipLeftAndRight;
|
||||
return Quicknes.GetSettings().ClipLeftAndRight;
|
||||
}
|
||||
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
return _neshawk.GetSettings().ClipLeftAndRight;
|
||||
return Neshawk.GetSettings().ClipLeftAndRight;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
|
@ -117,14 +117,14 @@ namespace BizHawk.Client.Common
|
|||
"getdispbackground", "Indicates whether or not the bg layer is being displayed")]
|
||||
public bool GetDisplayBackground()
|
||||
{
|
||||
if (_quicknes != null)
|
||||
if (Quicknes != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
return _neshawk.GetSettings().DispBackground;
|
||||
return Neshawk.GetSettings().DispBackground;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
|
@ -134,14 +134,14 @@ namespace BizHawk.Client.Common
|
|||
"getdispsprites", "Indicates whether or not sprites are being displayed")]
|
||||
public bool GetDisplaySprites()
|
||||
{
|
||||
if (_quicknes != null)
|
||||
if (Quicknes != null)
|
||||
{
|
||||
return _quicknes.GetSettings().NumSprites > 0;
|
||||
return Quicknes.GetSettings().NumSprites > 0;
|
||||
}
|
||||
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
return _neshawk.GetSettings().DispSprites;
|
||||
return Neshawk.GetSettings().DispSprites;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
|
@ -151,16 +151,16 @@ namespace BizHawk.Client.Common
|
|||
"gettopscanline", "Gets the current value for the top scanline value")]
|
||||
public int GetTopScanline(bool pal = false)
|
||||
{
|
||||
if (_quicknes != null)
|
||||
if (Quicknes != null)
|
||||
{
|
||||
return _quicknes.GetSettings().ClipTopAndBottom ? 8 : 0;
|
||||
return Quicknes.GetSettings().ClipTopAndBottom ? 8 : 0;
|
||||
}
|
||||
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
return pal
|
||||
? _neshawk.GetSettings().PAL_TopLine
|
||||
: _neshawk.GetSettings().NTSC_TopLine;
|
||||
? Neshawk.GetSettings().PAL_TopLine
|
||||
: Neshawk.GetSettings().NTSC_TopLine;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException();
|
||||
|
@ -182,17 +182,17 @@ namespace BizHawk.Client.Common
|
|||
"setallowmorethaneightsprites", "Sets the NES setting 'Allow more than 8 sprites per scanline'")]
|
||||
public void SetAllowMoreThanEightSprites(bool allow)
|
||||
{
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
var s = _neshawk.GetSettings();
|
||||
var s = Neshawk.GetSettings();
|
||||
s.AllowMoreThanEightSprites = allow;
|
||||
_neshawk.PutSettings(s);
|
||||
Neshawk.PutSettings(s);
|
||||
}
|
||||
else if (_quicknes != null)
|
||||
else if (Quicknes != null)
|
||||
{
|
||||
var s = _quicknes.GetSettings();
|
||||
var s = Quicknes.GetSettings();
|
||||
s.NumSprites = allow ? 64 : 8;
|
||||
_quicknes.PutSettings(s);
|
||||
Quicknes.PutSettings(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,17 +200,17 @@ namespace BizHawk.Client.Common
|
|||
"setclipleftandright", "Sets the Clip Left and Right sides option")]
|
||||
public void SetClipLeftAndRight(bool leftandright)
|
||||
{
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
var s = _neshawk.GetSettings();
|
||||
var s = Neshawk.GetSettings();
|
||||
s.ClipLeftAndRight = leftandright;
|
||||
_neshawk.PutSettings(s);
|
||||
Neshawk.PutSettings(s);
|
||||
}
|
||||
else if (_quicknes != null)
|
||||
else if (Quicknes != null)
|
||||
{
|
||||
var s = _quicknes.GetSettings();
|
||||
var s = Quicknes.GetSettings();
|
||||
s.ClipLeftAndRight = leftandright;
|
||||
_quicknes.PutSettings(s);
|
||||
Quicknes.PutSettings(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,11 +218,11 @@ namespace BizHawk.Client.Common
|
|||
"setdispbackground", "Sets whether or not the background layer will be displayed")]
|
||||
public void SetDisplayBackground(bool show)
|
||||
{
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
var s = _neshawk.GetSettings();
|
||||
var s = Neshawk.GetSettings();
|
||||
s.DispBackground = show;
|
||||
_neshawk.PutSettings(s);
|
||||
Neshawk.PutSettings(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,17 +230,17 @@ namespace BizHawk.Client.Common
|
|||
"setdispsprites", "Sets whether or not sprites will be displayed")]
|
||||
public void SetDisplaySprites(bool show)
|
||||
{
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
var s = _neshawk.GetSettings();
|
||||
var s = Neshawk.GetSettings();
|
||||
s.DispSprites = show;
|
||||
_neshawk.PutSettings(s);
|
||||
Neshawk.PutSettings(s);
|
||||
}
|
||||
else if (_quicknes != null)
|
||||
else if (Quicknes != null)
|
||||
{
|
||||
var s = _quicknes.GetSettings();
|
||||
var s = Quicknes.GetSettings();
|
||||
s.NumSprites = show ? 8 : 0;
|
||||
_quicknes.PutSettings(s);
|
||||
Quicknes.PutSettings(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ namespace BizHawk.Client.Common
|
|||
"setscanlines", "sets the top and bottom scanlines to be drawn (same values as in the graphics options dialog). Top must be in the range of 0 to 127, bottom must be between 128 and 239. Not supported in the Quick Nes core")]
|
||||
public void SetScanlines(int top, int bottom, bool pal = false)
|
||||
{
|
||||
if (_neshawk != null)
|
||||
if (Neshawk != null)
|
||||
{
|
||||
if (top > 127)
|
||||
{
|
||||
|
@ -268,7 +268,7 @@ namespace BizHawk.Client.Common
|
|||
bottom = 128;
|
||||
}
|
||||
|
||||
var s = _neshawk.GetSettings();
|
||||
var s = Neshawk.GetSettings();
|
||||
|
||||
if (pal)
|
||||
{
|
||||
|
@ -281,7 +281,7 @@ namespace BizHawk.Client.Common
|
|||
s.NTSC_BottomLine = bottom;
|
||||
}
|
||||
|
||||
_neshawk.PutSettings(s);
|
||||
Neshawk.PutSettings(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ __Types and notation__
|
|||
public string Scope { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "completions")]
|
||||
public List<Completion> Completions = new List<Completion>();
|
||||
public List<Completion> Completions { get; set; } = new List<Completion>();
|
||||
|
||||
public class Completion
|
||||
{
|
||||
|
|
|
@ -16,10 +16,10 @@ namespace BizHawk.Client.Common
|
|||
[OptionalService]
|
||||
protected IMemoryDomains MemoryDomainCore { get; set; }
|
||||
|
||||
public LuaMemoryBase(Lua lua)
|
||||
protected LuaMemoryBase(Lua lua)
|
||||
: base(lua) { }
|
||||
|
||||
public LuaMemoryBase(Lua lua, Action<string> logOutputCallback)
|
||||
protected LuaMemoryBase(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
protected abstract MemoryDomain Domain { get; }
|
||||
|
|
|
@ -7,6 +7,8 @@ using BizHawk.Emulation.Cores.Nintendo.NES;
|
|||
using BizHawk.Emulation.Cores.Nintendo.SNES9X;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.GBA;
|
||||
using BizHawk.Emulation.Cores.Atari.A7800Hawk;
|
||||
using BizHawk.Emulation.Cores.Atari.Atari7800;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
|
@ -40,12 +42,14 @@ namespace BizHawk.Client.Common
|
|||
public Func<string, string, bool> AskYesNoCallback { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Required
|
||||
/// Gets or sets a callback that allows the movie session to pause the emulator
|
||||
/// This is Required!
|
||||
/// </summary>
|
||||
public Action PauseCallback { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Required
|
||||
/// Gets or sets a callback that is invoked when the movie mode has changed
|
||||
/// This is Required!
|
||||
/// </summary>
|
||||
public Action ModeChangedCallback { get; set; }
|
||||
|
||||
|
@ -96,7 +100,7 @@ namespace BizHawk.Client.Common
|
|||
MessageCallback?.Invoke(message);
|
||||
}
|
||||
|
||||
private void LatchMultitrackPlayerInput(IController playerSource, MultitrackRewiringControllerAdapter rewiredSource)
|
||||
private void LatchMultitrackPlayerInput(MultitrackRewiringControllerAdapter rewiredSource)
|
||||
{
|
||||
if (MultiTrack.IsActive)
|
||||
{
|
||||
|
@ -297,7 +301,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (MultiTrack.IsActive)
|
||||
{
|
||||
LatchMultitrackPlayerInput(Global.MovieInputSourceAdapter, Global.MultitrackRewiringAdapter);
|
||||
LatchMultitrackPlayerInput(Global.MultitrackRewiringAdapter);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -461,6 +465,7 @@ namespace BizHawk.Client.Common
|
|||
public bool? PreviousNES_InQuickNES { get; set; }
|
||||
public bool? PreviousSNES_InSnes9x { get; set; }
|
||||
public bool? PreviousGBA_UsemGBA { get; set; }
|
||||
public bool? PreviousA78_UseEmu7800 { get; set; }
|
||||
|
||||
public void QueueNewMovie(IMovie movie, bool record, IEmulator emulator)
|
||||
{
|
||||
|
@ -475,13 +480,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Delete this, this save is utterly useless.
|
||||
// Movie was saved immediately before calling QueeuNewMovie. (StartNewMovie)
|
||||
////if (Movie.IsActive && !string.IsNullOrEmpty(Movie.Filename))
|
||||
////{
|
||||
//// Movie.Save();
|
||||
////}
|
||||
|
||||
// Note: this populates MovieControllerAdapter's Type with the approparite controller
|
||||
// Don't set it to a movie instance of the adapter or you will lose the definition!
|
||||
InputManager.RewireInputChain();
|
||||
|
@ -513,7 +511,7 @@ namespace BizHawk.Client.Common
|
|||
PreviousSNES_InSnes9x = Global.Config.SNES_InSnes9x;
|
||||
Global.Config.SNES_InSnes9x = true;
|
||||
}
|
||||
else
|
||||
else if (movie.Core == bsnesName)
|
||||
{
|
||||
PreviousSNES_InSnes9x = Global.Config.SNES_InSnes9x;
|
||||
Global.Config.SNES_InSnes9x = false;
|
||||
|
@ -529,12 +527,28 @@ namespace BizHawk.Client.Common
|
|||
PreviousGBA_UsemGBA = Global.Config.GBA_UsemGBA;
|
||||
Global.Config.GBA_UsemGBA = true;
|
||||
}
|
||||
else
|
||||
else if (movie.Core == vbaNextName)
|
||||
{
|
||||
PreviousSNES_InSnes9x = Global.Config.GBA_UsemGBA;
|
||||
PreviousGBA_UsemGBA = Global.Config.GBA_UsemGBA;
|
||||
Global.Config.GBA_UsemGBA = false;
|
||||
}
|
||||
}
|
||||
else if (!record && emulator.SystemId == "A78") // meh, copy pasta one more time, last time, I promise
|
||||
{
|
||||
var atari7800HawkName = ((CoreAttributes)Attribute.GetCustomAttribute(typeof(A7800Hawk), typeof(CoreAttributes))).CoreName;
|
||||
var emu7800HawkName = ((CoreAttributes)Attribute.GetCustomAttribute(typeof(Atari7800), typeof(CoreAttributes))).CoreName;
|
||||
|
||||
if (movie.Core == atari7800HawkName)
|
||||
{
|
||||
PreviousA78_UseEmu7800 = Global.Config.A78_UseEmu7800;
|
||||
Global.Config.A78_UseEmu7800 = true;
|
||||
}
|
||||
else if (movie.Core == emu7800HawkName)
|
||||
{
|
||||
PreviousA78_UseEmu7800 = Global.Config.A78_UseEmu7800;
|
||||
Global.Config.A78_UseEmu7800 = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (record) // This is a hack really, we need to set the movie to its propert state so that it will be considered active later
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace BizHawk.Client.Common
|
|||
// Color tag open
|
||||
if (addcolortag)
|
||||
{
|
||||
uint rgb = (Color & 0x00FFFFFF);
|
||||
uint rgb = Color & 0x00FFFFFF;
|
||||
sb.Append("<font color=\"#");
|
||||
sb.Append(rgb.ToString("X6"));
|
||||
sb.Append("\">");
|
||||
|
|
|
@ -15,49 +15,46 @@ namespace BizHawk.Client.Common
|
|||
.Replace("P4 ", "")
|
||||
.Replace("Key ", "");
|
||||
|
||||
if (SystemOverrides.ContainsKey(Global.Emulator.SystemId) && SystemOverrides[Global.Emulator.SystemId].ContainsKey(key))
|
||||
if (_systemOverrides.ContainsKey(Global.Emulator.SystemId) && _systemOverrides[Global.Emulator.SystemId].ContainsKey(key))
|
||||
{
|
||||
return SystemOverrides[Global.Emulator.SystemId][key];
|
||||
return _systemOverrides[Global.Emulator.SystemId][key];
|
||||
}
|
||||
|
||||
if (BaseMnemonicLookupTable.ContainsKey(key))
|
||||
if (_baseMnemonicLookupTable.ContainsKey(key))
|
||||
{
|
||||
return BaseMnemonicLookupTable[key];
|
||||
return _baseMnemonicLookupTable[key];
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, string> BaseMnemonicLookupTable = new Dictionary<string, string>
|
||||
private readonly Dictionary<string, string> _baseMnemonicLookupTable = new Dictionary<string, string>
|
||||
{
|
||||
{ "Zapper X", "zapX" },
|
||||
{ "Zapper Y", "zapY" },
|
||||
{ "Paddle", "Pad" },
|
||||
{ "Pen", "Pen" },
|
||||
{ "Mouse X", "mX" },
|
||||
{ "Mouse Y", "mY" },
|
||||
{ "Lightgun X", "lX" },
|
||||
{ "Lightgun Y", "lY" },
|
||||
{ "X Axis", "aX" },
|
||||
{ "Y Axis", "aY" },
|
||||
{ "LStick X", "lsX" },
|
||||
{ "LStick Y", "lsY" },
|
||||
{ "RStick X", "rsX" },
|
||||
{ "RStick Y", "rsY" },
|
||||
{ "Disc Select", "Disc" }
|
||||
["Zapper X"] = "zapX",
|
||||
["Zapper Y"] = "zapY",
|
||||
["Paddle"] = "Pad",
|
||||
["Pen"] = "Pen",
|
||||
["Mouse X"] = "mX",
|
||||
["Mouse Y"] = "mY",
|
||||
["Lightgun X"] = "lX",
|
||||
["Lightgun Y"] = "lY",
|
||||
["X Axis"] = "aX",
|
||||
["Y Axis"] = "aY",
|
||||
["LStick X"] = "lsX",
|
||||
["LStick Y"] = "lsY",
|
||||
["RStick X"] = "rsX",
|
||||
["RStick Y"] = "rsY",
|
||||
["Disc Select"] = "Disc"
|
||||
};
|
||||
|
||||
private readonly Dictionary<string, Dictionary<string, string>> SystemOverrides = new Dictionary<string, Dictionary<string, string>>
|
||||
private readonly Dictionary<string, Dictionary<string, string>> _systemOverrides = new Dictionary<string, Dictionary<string, string>>
|
||||
{
|
||||
["A78"] = new Dictionary<string, string>
|
||||
{
|
||||
"A78",
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
{ "VPos", "X" },
|
||||
{ "HPos", "Y" }
|
||||
}
|
||||
},
|
||||
["VPos"] = "X",
|
||||
["HPos"] = "Y"
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class Bk2LogEntryGenerator : ILogEntryGenerator
|
||||
{
|
||||
private readonly Bk2MnemonicConstants Mnemonics = new Bk2MnemonicConstants();
|
||||
private readonly Bk2FloatConstants FloatLookup = new Bk2FloatConstants();
|
||||
private readonly Bk2MnemonicConstants _mnemonics = new Bk2MnemonicConstants();
|
||||
private readonly Bk2FloatConstants _floatLookup = new Bk2FloatConstants();
|
||||
|
||||
private readonly string _logKey;
|
||||
private IController _source;
|
||||
|
@ -72,11 +72,11 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (_source.Definition.BoolButtons.Contains(button))
|
||||
{
|
||||
dict.Add(button, Mnemonics[button].ToString());
|
||||
dict.Add(button, _mnemonics[button].ToString());
|
||||
}
|
||||
else if (_source.Definition.FloatControls.Contains(button))
|
||||
{
|
||||
dict.Add(button, FloatLookup[button]);
|
||||
dict.Add(button, _floatLookup[button]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
sb.Append(_source.IsPressed(button) ? Mnemonics[button] : forInputDisplay ? ' ' : '.');
|
||||
sb.Append(_source.IsPressed(button) ? _mnemonics[button] : forInputDisplay ? ' ' : '.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ namespace BizHawk.Client.Common
|
|||
bs.PutLump(BinaryStateLump.Subtitles, tw => tw.WriteLine(Subtitles.ToString()));
|
||||
bs.PutLump(BinaryStateLump.SyncSettings, tw => tw.WriteLine(_syncSettingsJson));
|
||||
|
||||
bs.PutLump(BinaryStateLump.Input, tw => WriteInputLog(tw));
|
||||
bs.PutLump(BinaryStateLump.Input, WriteInputLog);
|
||||
|
||||
if (StartsFromSavestate)
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ namespace BizHawk.Client.Common
|
|||
protected void ClearBeforeLoad()
|
||||
{
|
||||
Header.Clear();
|
||||
_log.Clear();
|
||||
Log.Clear();
|
||||
Subtitles.Clear();
|
||||
Comments.Clear();
|
||||
_syncSettingsJson = "";
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public partial class Bk2Movie
|
||||
{
|
||||
protected IStringLog _log;
|
||||
protected string LogKey = "";
|
||||
protected IStringLog Log { get; set; }
|
||||
protected string LogKey { get; set; } = "";
|
||||
|
||||
public void WriteInputLog(TextWriter writer)
|
||||
{
|
||||
|
@ -24,13 +24,13 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (LoopOffset.HasValue)
|
||||
{
|
||||
if (frame < _log.Count)
|
||||
if (frame < Log.Count)
|
||||
{
|
||||
getframe = frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
getframe = ((frame - LoopOffset.Value) % (_log.Count - LoopOffset.Value)) + LoopOffset.Value;
|
||||
getframe = ((frame - LoopOffset.Value) % (Log.Count - LoopOffset.Value)) + LoopOffset.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -38,7 +38,7 @@ namespace BizHawk.Client.Common
|
|||
getframe = frame;
|
||||
}
|
||||
|
||||
return _log[getframe];
|
||||
return Log[getframe];
|
||||
}
|
||||
|
||||
return "";
|
||||
|
@ -52,13 +52,13 @@ namespace BizHawk.Client.Common
|
|||
// We are in record mode so replace the movie log with the one from the savestate
|
||||
if (!Global.MovieSession.MultiTrack.IsActive)
|
||||
{
|
||||
if (Global.Config.EnableBackupMovies && MakeBackup && _log.Count != 0)
|
||||
if (Global.Config.EnableBackupMovies && MakeBackup && Log.Count != 0)
|
||||
{
|
||||
SaveBackup();
|
||||
MakeBackup = false;
|
||||
}
|
||||
|
||||
_log.Clear();
|
||||
Log.Clear();
|
||||
while (true)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
|
@ -102,7 +102,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else if (line[0] == '|')
|
||||
{
|
||||
_log.Add(line);
|
||||
Log.Add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,21 +162,21 @@ namespace BizHawk.Client.Common
|
|||
|
||||
var stateFramei = stateFrame ?? 0;
|
||||
|
||||
if (stateFramei > 0 && stateFramei < _log.Count)
|
||||
if (stateFramei > 0 && stateFramei < Log.Count)
|
||||
{
|
||||
if (!Global.Config.VBAStyleMovieLoadState)
|
||||
{
|
||||
Truncate(stateFramei);
|
||||
}
|
||||
}
|
||||
else if (stateFramei > _log.Count) // Post movie savestate
|
||||
else if (stateFramei > Log.Count) // Post movie savestate
|
||||
{
|
||||
if (!Global.Config.VBAStyleMovieLoadState)
|
||||
{
|
||||
Truncate(_log.Count);
|
||||
Truncate(Log.Count);
|
||||
}
|
||||
|
||||
_mode = Moviemode.Finished;
|
||||
Mode = Moviemode.Finished;
|
||||
}
|
||||
|
||||
if (IsCountingRerecords)
|
||||
|
@ -243,7 +243,7 @@ namespace BizHawk.Client.Common
|
|||
stateFrame = newLog.Count; // In case the frame count failed to parse, revert to using the entire state input log
|
||||
}
|
||||
|
||||
if (_log.Count < stateFrame)
|
||||
if (Log.Count < stateFrame)
|
||||
{
|
||||
if (IsFinished)
|
||||
{
|
||||
|
@ -253,14 +253,14 @@ namespace BizHawk.Client.Common
|
|||
errorMessage = "The savestate is from frame "
|
||||
+ newLog.Count
|
||||
+ " which is greater than the current movie length of "
|
||||
+ _log.Count;
|
||||
+ Log.Count;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0; i < stateFrame; i++)
|
||||
{
|
||||
if (_log[i] != newLog[i])
|
||||
if (Log[i] != newLog[i])
|
||||
{
|
||||
errorMessage = "The savestate input does not match the movie input at frame "
|
||||
+ (i + 1)
|
||||
|
@ -272,18 +272,18 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (stateFrame > newLog.Count) // stateFrame is greater than state input log, so movie finished mode
|
||||
{
|
||||
if (_mode == Moviemode.Play || _mode == Moviemode.Finished)
|
||||
if (Mode == Moviemode.Play || Mode == Moviemode.Finished)
|
||||
{
|
||||
_mode = Moviemode.Finished;
|
||||
Mode = Moviemode.Finished;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_mode == Moviemode.Finished)
|
||||
if (Mode == Moviemode.Finished)
|
||||
{
|
||||
_mode = Moviemode.Play;
|
||||
Mode = Moviemode.Play;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -296,7 +296,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
writer.WriteLine(lg.GenerateLogKey());
|
||||
|
||||
foreach (var record in _log)
|
||||
foreach (var record in Log)
|
||||
{
|
||||
writer.WriteLine(record);
|
||||
}
|
||||
|
|
|
@ -9,41 +9,41 @@ namespace BizHawk.Client.Common
|
|||
Inactive, Play, Record, Finished
|
||||
}
|
||||
|
||||
protected Moviemode _mode = Moviemode.Inactive;
|
||||
protected Moviemode Mode { get; set; } = Moviemode.Inactive;
|
||||
|
||||
public bool IsActive => _mode != Moviemode.Inactive;
|
||||
public bool IsActive => Mode != Moviemode.Inactive;
|
||||
|
||||
public bool IsPlaying => _mode == Moviemode.Play || _mode == Moviemode.Finished;
|
||||
public bool IsPlaying => Mode == Moviemode.Play || Mode == Moviemode.Finished;
|
||||
|
||||
public bool IsRecording => _mode == Moviemode.Record;
|
||||
public bool IsRecording => Mode == Moviemode.Record;
|
||||
|
||||
public bool IsFinished => _mode == Moviemode.Finished;
|
||||
public bool IsFinished => Mode == Moviemode.Finished;
|
||||
|
||||
public virtual void StartNewRecording()
|
||||
{
|
||||
_mode = Moviemode.Record;
|
||||
if (Global.Config.EnableBackupMovies && MakeBackup && _log.Any())
|
||||
Mode = Moviemode.Record;
|
||||
if (Global.Config.EnableBackupMovies && MakeBackup && Log.Any())
|
||||
{
|
||||
SaveBackup();
|
||||
MakeBackup = false;
|
||||
}
|
||||
|
||||
_log.Clear();
|
||||
Log.Clear();
|
||||
}
|
||||
|
||||
public virtual void StartNewPlayback()
|
||||
{
|
||||
_mode = Moviemode.Play;
|
||||
Mode = Moviemode.Play;
|
||||
}
|
||||
|
||||
public virtual void SwitchToRecord()
|
||||
{
|
||||
_mode = Moviemode.Record;
|
||||
Mode = Moviemode.Record;
|
||||
}
|
||||
|
||||
public virtual void SwitchToPlay()
|
||||
{
|
||||
_mode = Moviemode.Play;
|
||||
Mode = Moviemode.Play;
|
||||
}
|
||||
|
||||
public virtual bool Stop(bool saveChanges = true)
|
||||
|
@ -51,7 +51,7 @@ namespace BizHawk.Client.Common
|
|||
bool saved = false;
|
||||
if (saveChanges)
|
||||
{
|
||||
if (_mode == Moviemode.Record || (IsActive && Changes))
|
||||
if (Mode == Moviemode.Record || (IsActive && Changes))
|
||||
{
|
||||
Save();
|
||||
saved = true;
|
||||
|
@ -59,14 +59,14 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
Changes = false;
|
||||
_mode = Moviemode.Inactive;
|
||||
Mode = Moviemode.Inactive;
|
||||
|
||||
return saved;
|
||||
}
|
||||
|
||||
public void FinishedMode()
|
||||
{
|
||||
_mode = Moviemode.Finished;
|
||||
Mode = Moviemode.Finished;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public partial class Bk2Movie : IMovie
|
||||
{
|
||||
protected bool MakeBackup = true;
|
||||
|
||||
public Bk2Movie(string filename)
|
||||
: this()
|
||||
{
|
||||
|
@ -22,14 +20,16 @@ namespace BizHawk.Client.Common
|
|||
|
||||
Filename = "";
|
||||
IsCountingRerecords = true;
|
||||
_mode = Moviemode.Inactive;
|
||||
Mode = Moviemode.Inactive;
|
||||
MakeBackup = true;
|
||||
|
||||
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0.0";
|
||||
|
||||
_log = StringLogUtil.MakeStringLog();
|
||||
Log = StringLogUtil.MakeStringLog();
|
||||
}
|
||||
|
||||
protected bool MakeBackup { get; set; }
|
||||
|
||||
private string _filename;
|
||||
|
||||
public string Filename
|
||||
|
@ -70,11 +70,11 @@ namespace BizHawk.Client.Common
|
|||
return double.PositiveInfinity;
|
||||
}
|
||||
|
||||
return _log.Count;
|
||||
return Log.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public int InputLogLength => _log.Count;
|
||||
public int InputLogLength => Log.Count;
|
||||
|
||||
#region Log Editing
|
||||
|
||||
|
@ -82,7 +82,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
var lg = LogGeneratorInstance();
|
||||
lg.SetSource(source);
|
||||
_log.Add(lg.GenerateLogEntry());
|
||||
Log.Add(lg.GenerateLogEntry());
|
||||
Changes = true;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (Global.Config.VBAStyleMovieLoadState)
|
||||
{
|
||||
if (Global.Emulator.Frame < _log.Count)
|
||||
if (Global.Emulator.Frame < Log.Count)
|
||||
{
|
||||
Truncate(Global.Emulator.Frame);
|
||||
}
|
||||
|
@ -109,9 +109,9 @@ namespace BizHawk.Client.Common
|
|||
// and it is weird for Truncate to possibly not truncate
|
||||
if (!Global.MovieSession.MultiTrack.IsActive)
|
||||
{
|
||||
if (frame < _log.Count)
|
||||
if (frame < Log.Count)
|
||||
{
|
||||
_log.RemoveRange(frame, _log.Count - frame);
|
||||
Log.RemoveRange(frame, Log.Count - frame);
|
||||
Changes = true;
|
||||
}
|
||||
}
|
||||
|
@ -125,13 +125,13 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (LoopOffset.HasValue)
|
||||
{
|
||||
if (frame < _log.Count)
|
||||
if (frame < Log.Count)
|
||||
{
|
||||
getframe = frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
getframe = ((frame - LoopOffset.Value) % (_log.Count - LoopOffset.Value)) + LoopOffset.Value;
|
||||
getframe = ((frame - LoopOffset.Value) % (Log.Count - LoopOffset.Value)) + LoopOffset.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -144,7 +144,7 @@ namespace BizHawk.Client.Common
|
|||
Definition = Global.MovieSession.MovieControllerAdapter.Definition
|
||||
};
|
||||
|
||||
adapter.SetControllersAsMnemonic(_log[getframe]);
|
||||
adapter.SetControllersAsMnemonic(Log[getframe]);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
|
@ -172,13 +172,13 @@ namespace BizHawk.Client.Common
|
|||
|
||||
protected void SetFrameAt(int frameNum, string frame)
|
||||
{
|
||||
if (_log.Count > frameNum)
|
||||
if (Log.Count > frameNum)
|
||||
{
|
||||
_log[frameNum] = frame;
|
||||
Log[frameNum] = frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.Add(frame);
|
||||
Log.Add(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public static class StringLogUtil
|
||||
{
|
||||
public static bool DefaultToDisk;
|
||||
public static bool DefaultToAWE;
|
||||
public static bool DefaultToDisk { get; set; }
|
||||
public static bool DefaultToAWE { get; set; }
|
||||
public static IStringLog MakeStringLog()
|
||||
{
|
||||
if (DefaultToDisk)
|
||||
|
@ -55,23 +55,24 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// A dumb-ish IStringLog with storage on disk with no provision for recovering lost space, except upon Clear()
|
||||
/// The purpose here is to avoid having too complicated buggy logic or a dependency on sqlite or such.
|
||||
/// A dumb IStringLog with storage on disk with no provision for recovering lost space, except upon Clear()
|
||||
/// The purpose here is to avoid having too complicated buggy logic or a dependency on SQLite or such.
|
||||
/// It should be faster than those alternatives, but wasteful of disk space.
|
||||
/// It should also be easier to add new IList<string>-like methods than dealing with a database
|
||||
/// </summary>
|
||||
internal class StreamStringLog : IStringLog
|
||||
{
|
||||
List<long> Offsets = new List<long>();
|
||||
long cursor = 0;
|
||||
BinaryWriter bw;
|
||||
BinaryReader br;
|
||||
bool mDisk;
|
||||
private readonly Stream stream;
|
||||
private readonly List<long> _offsets = new List<long>();
|
||||
private readonly BinaryWriter _bw;
|
||||
private readonly BinaryReader _br;
|
||||
private readonly bool _mDisk;
|
||||
|
||||
private long _cursor;
|
||||
|
||||
Stream stream;
|
||||
public StreamStringLog(bool disk)
|
||||
{
|
||||
mDisk = disk;
|
||||
_mDisk = disk;
|
||||
if (disk)
|
||||
{
|
||||
var path = TempFileCleaner.GetTempFilename("movieOnDisk");
|
||||
|
@ -82,13 +83,13 @@ namespace BizHawk.Client.Common
|
|||
stream = new AWEMemoryStream();
|
||||
}
|
||||
|
||||
bw = new BinaryWriter(stream);
|
||||
br = new BinaryReader(stream);
|
||||
_bw = new BinaryWriter(stream);
|
||||
_br = new BinaryReader(stream);
|
||||
}
|
||||
|
||||
public IStringLog Clone()
|
||||
{
|
||||
StreamStringLog ret = new StreamStringLog(mDisk); // doesnt necessarily make sense to copy the mDisk value, they could be designated for different targets...
|
||||
StreamStringLog ret = new StreamStringLog(_mDisk); // doesnt necessarily make sense to copy the mDisk value, they could be designated for different targets...
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
ret.Add(this[i]);
|
||||
|
@ -102,52 +103,52 @@ namespace BizHawk.Client.Common
|
|||
stream.Dispose();
|
||||
}
|
||||
|
||||
public int Count => Offsets.Count;
|
||||
public int Count => _offsets.Count;
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
stream.SetLength(0);
|
||||
Offsets.Clear();
|
||||
cursor = 0;
|
||||
_offsets.Clear();
|
||||
_cursor = 0;
|
||||
}
|
||||
|
||||
public void Add(string str)
|
||||
{
|
||||
stream.Position = stream.Length;
|
||||
Offsets.Add(stream.Position);
|
||||
bw.Write(str);
|
||||
bw.Flush();
|
||||
_offsets.Add(stream.Position);
|
||||
_bw.Write(str);
|
||||
_bw.Flush();
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
// no garbage collection in the disk file... oh well.
|
||||
Offsets.RemoveAt(index);
|
||||
_offsets.RemoveAt(index);
|
||||
}
|
||||
|
||||
public string this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
stream.Position = Offsets[index];
|
||||
return br.ReadString();
|
||||
stream.Position = _offsets[index];
|
||||
return _br.ReadString();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
stream.Position = stream.Length;
|
||||
Offsets[index] = stream.Position;
|
||||
bw.Write(value);
|
||||
bw.Flush();
|
||||
_offsets[index] = stream.Position;
|
||||
_bw.Write(value);
|
||||
_bw.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
public void Insert(int index, string val)
|
||||
{
|
||||
stream.Position = stream.Length;
|
||||
Offsets.Insert(index, stream.Position);
|
||||
bw.Write(val);
|
||||
bw.Flush();
|
||||
_offsets.Insert(index, stream.Position);
|
||||
_bw.Write(val);
|
||||
_bw.Flush();
|
||||
}
|
||||
|
||||
public void InsertRange(int index, IEnumerable<string> collection)
|
||||
|
@ -168,35 +169,37 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private class Enumerator : IEnumerator<string>
|
||||
{
|
||||
public StreamStringLog log;
|
||||
int index = -1;
|
||||
public string Current { get { return log[index]; } }
|
||||
object System.Collections.IEnumerator.Current { get { return log[index]; } }
|
||||
public StreamStringLog Log { get; set; }
|
||||
private int _index = -1;
|
||||
|
||||
public string Current => Log[_index];
|
||||
object System.Collections.IEnumerator.Current => Log[_index];
|
||||
|
||||
bool System.Collections.IEnumerator.MoveNext()
|
||||
{
|
||||
index++;
|
||||
if (index >= log.Count)
|
||||
_index++;
|
||||
if (_index >= Log.Count)
|
||||
{
|
||||
index = log.Count;
|
||||
_index = Log.Count;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void System.Collections.IEnumerator.Reset() { index = -1; }
|
||||
void System.Collections.IEnumerator.Reset() { _index = -1; }
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
IEnumerator<string> IEnumerable<string>.GetEnumerator()
|
||||
{
|
||||
return new Enumerator { log = this };
|
||||
return new Enumerator { Log = this };
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return new Enumerator { log = this };
|
||||
return new Enumerator { Log = this };
|
||||
}
|
||||
|
||||
public void RemoveRange(int index, int count)
|
||||
|
|
|
@ -487,7 +487,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
for (int player = 1; player <= BkmMnemonicConstants.Players[ControlType]; player++)
|
||||
{
|
||||
int srcindex = (player - 1) * (BkmMnemonicConstants.Buttons[ControlType].Count + BkmMnemonicConstants.Analogs[ControlType].Count * 4 + 1 + 1);
|
||||
int srcindex = (player - 1) * (BkmMnemonicConstants.Buttons[ControlType].Count + (BkmMnemonicConstants.Analogs[ControlType].Count * 4) + 1 + 1);
|
||||
|
||||
if (mnemonic.Length < srcindex + 3 + BkmMnemonicConstants.Buttons[ControlType].Count - 1)
|
||||
{
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else if (line.ToLower().StartsWith("emuversion"))
|
||||
{
|
||||
Result.Movie.Comments.Add($"{EMULATIONORIGIN} {emulator} version {ParseHeader(line, "emuVersion")}");
|
||||
Result.Movie.Comments.Add($"{Emulationorigin} {emulator} version {ParseHeader(line, "emuVersion")}");
|
||||
}
|
||||
else if (line.ToLower().StartsWith("version"))
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
else
|
||||
{
|
||||
Result.Movie.Comments.Add(MOVIEORIGIN + " .fm2 version 3");
|
||||
Result.Movie.Comments.Add(Movieorigin + " .fm2 version 3");
|
||||
}
|
||||
}
|
||||
else if (line.ToLower().StartsWith("romfilename"))
|
||||
|
|
|
@ -11,25 +11,25 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public abstract class MovieImporter : IMovieImport
|
||||
{
|
||||
public const string COMMENT = "comment";
|
||||
public const string COREORIGIN = "CoreOrigin";
|
||||
public const string Comment = "comment";
|
||||
public const string Coreorigin = "CoreOrigin";
|
||||
public const string CRC16 = "CRC16";
|
||||
public const string CRC32 = "CRC32";
|
||||
public const string EMULATIONORIGIN = "emuOrigin";
|
||||
public const string GAMECODE = "GameCode";
|
||||
public const string INTERNALCHECKSUM = "InternalChecksum";
|
||||
public const string JAPAN = "Japan";
|
||||
public const string MD5 = "MD5";
|
||||
public const string MOVIEORIGIN = "MovieOrigin";
|
||||
public const string PORT1 = "port1";
|
||||
public const string PORT2 = "port2";
|
||||
public const string PROJECTID = "ProjectID";
|
||||
protected const string Emulationorigin = "emuOrigin";
|
||||
public const string Gamecode = "GameCode";
|
||||
public const string InternalChecksum = "InternalChecksum";
|
||||
public const string Japan = "Japan";
|
||||
protected const string MD5 = "MD5";
|
||||
protected const string Movieorigin = "MovieOrigin";
|
||||
public const string Port1 = "port1";
|
||||
public const string Port2 = "port2";
|
||||
public const string ProjectId = "ProjectID";
|
||||
public const string SHA256 = "SHA256";
|
||||
public const string SUPERGAMEBOYMODE = "SuperGameBoyMode";
|
||||
public const string STARTSECOND = "StartSecond";
|
||||
public const string STARTSUBSECOND = "StartSubSecond";
|
||||
public const string SYNCHACK = "SyncHack";
|
||||
public const string UNITCODE = "UnitCode";
|
||||
public const string SuperGameboyMode = "SuperGameBoyMode";
|
||||
public const string StartSecond = "StartSecond";
|
||||
public const string StartSubSecond = "StartSubSecond";
|
||||
public const string SyncHack = "SyncHack";
|
||||
public const string UnitCode = "UnitCode";
|
||||
|
||||
public ImportResult Import(string path)
|
||||
{
|
||||
|
@ -49,9 +49,9 @@ namespace BizHawk.Client.Common
|
|||
return Result;
|
||||
}
|
||||
|
||||
protected ImportResult Result = new ImportResult();
|
||||
protected ImportResult Result { get; } = new ImportResult();
|
||||
|
||||
protected FileInfo SourceFile;
|
||||
protected FileInfo SourceFile { get; private set; }
|
||||
|
||||
protected abstract void RunImport();
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
var info = ParseHeader(movie, "PJM ", br);
|
||||
|
||||
fs.Seek(info.controllerDataOffset, SeekOrigin.Begin);
|
||||
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
|
||||
|
||||
if (info.binaryFormat)
|
||||
if (info.BinaryFormat)
|
||||
{
|
||||
ParseBinaryInputLog(br, movie, info);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if ((flags & 0x40) != 0)
|
||||
{
|
||||
info.binaryFormat = false;
|
||||
info.BinaryFormat = false;
|
||||
}
|
||||
|
||||
if ((flags & 0x80) != 0 || (flags2 & 0x01) != 0)
|
||||
|
@ -103,13 +103,13 @@ namespace BizHawk.Client.Common
|
|||
// to mean no controller present.
|
||||
case 0:
|
||||
case 8:
|
||||
info.player1Type = OctoshockDll.ePeripheralType.None;
|
||||
info.Player1Type = OctoshockDll.ePeripheralType.None;
|
||||
break;
|
||||
case 4:
|
||||
info.player1Type = OctoshockDll.ePeripheralType.Pad;
|
||||
info.Player1Type = OctoshockDll.ePeripheralType.Pad;
|
||||
break;
|
||||
case 7:
|
||||
info.player1Type = OctoshockDll.ePeripheralType.DualShock;
|
||||
info.Player1Type = OctoshockDll.ePeripheralType.DualShock;
|
||||
break;
|
||||
default:
|
||||
Result.Errors.Add("Movie has unrecognised controller type for Player 1.");
|
||||
|
@ -121,13 +121,13 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
case 0:
|
||||
case 8:
|
||||
info.player1Type = OctoshockDll.ePeripheralType.None;
|
||||
info.Player1Type = OctoshockDll.ePeripheralType.None;
|
||||
break;
|
||||
case 4:
|
||||
info.player1Type = OctoshockDll.ePeripheralType.Pad;
|
||||
info.Player1Type = OctoshockDll.ePeripheralType.Pad;
|
||||
break;
|
||||
case 7:
|
||||
info.player1Type = OctoshockDll.ePeripheralType.DualShock;
|
||||
info.Player1Type = OctoshockDll.ePeripheralType.DualShock;
|
||||
break;
|
||||
default:
|
||||
Result.Errors.Add("Movie has unrecognised controller type for Player 2.");
|
||||
|
@ -140,11 +140,11 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
Devices8 = new[]
|
||||
{
|
||||
info.player1Type,
|
||||
info.Player1Type,
|
||||
OctoshockDll.ePeripheralType.None,
|
||||
OctoshockDll.ePeripheralType.None,
|
||||
OctoshockDll.ePeripheralType.None,
|
||||
info.player2Type,
|
||||
info.Player2Type,
|
||||
OctoshockDll.ePeripheralType.None,
|
||||
OctoshockDll.ePeripheralType.None,
|
||||
OctoshockDll.ePeripheralType.None
|
||||
|
@ -162,7 +162,7 @@ namespace BizHawk.Client.Common
|
|||
};
|
||||
movie.SyncSettingsJson = JsonConvert.SerializeObject(new { o = (object)syncsettings }, jsonSettings);
|
||||
|
||||
info.frameCount = br.ReadUInt32();
|
||||
info.FrameCount = br.ReadUInt32();
|
||||
uint rerecordCount = br.ReadUInt32();
|
||||
movie.HeaderEntries[HeaderKeys.RERECORDS] = rerecordCount.ToString();
|
||||
|
||||
|
@ -176,14 +176,14 @@ namespace BizHawk.Client.Common
|
|||
// so not so useful.
|
||||
br.ReadBytes(20);
|
||||
|
||||
info.controllerDataOffset = br.ReadUInt32();
|
||||
info.ControllerDataOffset = br.ReadUInt32();
|
||||
|
||||
uint authorNameLength = br.ReadUInt32();
|
||||
char[] authorName = br.ReadChars((int)authorNameLength);
|
||||
|
||||
movie.HeaderEntries[HeaderKeys.AUTHOR] = new string(authorName);
|
||||
|
||||
info.parseSuccessful = true;
|
||||
info.ParseSuccessful = true;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
@ -193,9 +193,9 @@ namespace BizHawk.Client.Common
|
|||
SimpleController controllers = new SimpleController();
|
||||
settings.FIOConfig.Devices8 = new[]
|
||||
{
|
||||
info.player1Type,
|
||||
info.Player1Type,
|
||||
OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None,
|
||||
info.player2Type,
|
||||
info.Player2Type,
|
||||
OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None
|
||||
};
|
||||
controllers.Definition = Octoshock.CreateControllerDefinition(settings);
|
||||
|
@ -209,9 +209,9 @@ namespace BizHawk.Client.Common
|
|||
bool isCdTrayOpen = false;
|
||||
int cdNumber = 1;
|
||||
|
||||
for (int frame = 0; frame < info.frameCount; ++frame)
|
||||
for (int frame = 0; frame < info.FrameCount; ++frame)
|
||||
{
|
||||
if (info.player1Type != OctoshockDll.ePeripheralType.None)
|
||||
if (info.Player1Type != OctoshockDll.ePeripheralType.None)
|
||||
{
|
||||
ushort controllerState = br.ReadUInt16();
|
||||
|
||||
|
@ -228,7 +228,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
if (info.player1Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
if (info.Player1Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
{
|
||||
controllers["P1 L3"] = (controllerState & 0x2) != 0;
|
||||
controllers["P1 R3"] = (controllerState & 0x4) != 0;
|
||||
|
@ -241,7 +241,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
if (info.player2Type != OctoshockDll.ePeripheralType.None)
|
||||
if (info.Player2Type != OctoshockDll.ePeripheralType.None)
|
||||
{
|
||||
ushort controllerState = br.ReadUInt16();
|
||||
for (int button = 0; button < buttons.Length; button++)
|
||||
|
@ -253,7 +253,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
if (info.player2Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
if (info.Player2Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
{
|
||||
Tuple<string, float> leftX = new Tuple<string, float>("P2 LStick X", (float)br.ReadByte());
|
||||
Tuple<string, float> leftY = new Tuple<string, float>("P2 LStick Y", (float)br.ReadByte());
|
||||
|
@ -304,9 +304,9 @@ namespace BizHawk.Client.Common
|
|||
SimpleController controllers = new SimpleController();
|
||||
settings.FIOConfig.Devices8 = new[]
|
||||
{
|
||||
info.player1Type,
|
||||
info.Player1Type,
|
||||
OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None,
|
||||
info.player2Type,
|
||||
info.Player2Type,
|
||||
OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None, OctoshockDll.ePeripheralType.None
|
||||
};
|
||||
controllers.Definition = Octoshock.CreateControllerDefinition(settings);
|
||||
|
@ -320,15 +320,15 @@ namespace BizHawk.Client.Common
|
|||
bool isCdTrayOpen = false;
|
||||
int cdNumber = 1;
|
||||
|
||||
for (int frame = 0; frame < info.frameCount; ++frame)
|
||||
for (int frame = 0; frame < info.FrameCount; ++frame)
|
||||
{
|
||||
if (info.player1Type != OctoshockDll.ePeripheralType.None)
|
||||
if (info.Player1Type != OctoshockDll.ePeripheralType.None)
|
||||
{
|
||||
// As L3 and R3 don't exist on a standard gamepad, handle them separately later. Unfortunately
|
||||
// due to the layout, we handle select separately too first.
|
||||
controllers["P1 Select"] = br.ReadChar() != '.';
|
||||
|
||||
if (info.player1Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
if (info.Player1Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
{
|
||||
controllers["P1 L3"] = br.ReadChar() != '.';
|
||||
controllers["P1 R3"] = br.ReadChar() != '.';
|
||||
|
@ -339,7 +339,7 @@ namespace BizHawk.Client.Common
|
|||
controllers["P1 " + buttons[button]] = br.ReadChar() != '.';
|
||||
}
|
||||
|
||||
if (info.player1Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
if (info.Player1Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
{
|
||||
// The analog controls are encoded as four space-separated numbers with a leading space
|
||||
string leftXRaw = new string(br.ReadChars(4)).Trim();
|
||||
|
@ -359,13 +359,13 @@ namespace BizHawk.Client.Common
|
|||
// Each controller is terminated with a pipeline.
|
||||
br.ReadChar();
|
||||
|
||||
if (info.player2Type != OctoshockDll.ePeripheralType.None)
|
||||
if (info.Player2Type != OctoshockDll.ePeripheralType.None)
|
||||
{
|
||||
// As L3 and R3 don't exist on a standard gamepad, handle them separately later. Unfortunately
|
||||
// due to the layout, we handle select separately too first.
|
||||
controllers["P2 Select"] = br.ReadChar() != '.';
|
||||
|
||||
if (info.player2Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
if (info.Player2Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
{
|
||||
controllers["P2 L3"] = br.ReadChar() != '.';
|
||||
controllers["P2 R3"] = br.ReadChar() != '.';
|
||||
|
@ -376,7 +376,7 @@ namespace BizHawk.Client.Common
|
|||
controllers["P2 " + buttons[button]] = br.ReadChar() != '.';
|
||||
}
|
||||
|
||||
if (info.player2Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
if (info.Player2Type == OctoshockDll.ePeripheralType.DualShock)
|
||||
{
|
||||
// The analog controls are encoded as four space-separated numbers with a leading space
|
||||
string leftXRaw = new string(br.ReadChars(4)).Trim();
|
||||
|
@ -435,13 +435,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
protected class MiscHeaderInfo
|
||||
{
|
||||
public bool binaryFormat = true;
|
||||
public uint controllerDataOffset;
|
||||
public uint frameCount;
|
||||
public OctoshockDll.ePeripheralType player1Type;
|
||||
public OctoshockDll.ePeripheralType player2Type;
|
||||
|
||||
public bool parseSuccessful = false;
|
||||
public bool BinaryFormat { get; set; } = true;
|
||||
public uint ControllerDataOffset { get; set; }
|
||||
public uint FrameCount { get; set; }
|
||||
public OctoshockDll.ePeripheralType Player1Type { get; set; }
|
||||
public OctoshockDll.ePeripheralType Player2Type { get; set; }
|
||||
public bool ParseSuccessful { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ namespace BizHawk.Client.Common.Movie.Import
|
|||
{
|
||||
var info = ParseHeader(movie, "PXM ", br);
|
||||
|
||||
fs.Seek(info.controllerDataOffset, SeekOrigin.Begin);
|
||||
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
|
||||
|
||||
if (info.binaryFormat)
|
||||
if (info.BinaryFormat)
|
||||
{
|
||||
ParseBinaryInputLog(br, movie, info);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace BizHawk.Client.Common
|
|||
bool? PreviousNES_InQuickNES { get; set; }
|
||||
bool? PreviousSNES_InSnes9x { get; set; }
|
||||
bool? PreviousGBA_UsemGBA { get; set; }
|
||||
bool? PreviousA78_UseEmu7800 { get; set; }
|
||||
|
||||
void HandleMovieOnFrameLoop();
|
||||
void HandleMovieAfterFrameLoop();
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace BizHawk.Client.Common
|
|||
return _state;
|
||||
}
|
||||
|
||||
return _manager.ndbdatabase.FetchAll(_id.ToString());
|
||||
return _manager.NdbDatabase.FetchAll(_id.ToString());
|
||||
}
|
||||
|
||||
set
|
||||
|
@ -80,7 +80,7 @@ namespace BizHawk.Client.Common
|
|||
return;
|
||||
}
|
||||
|
||||
_manager.ndbdatabase.Store(_id.ToString(), _state, 0, _state.Length);
|
||||
_manager.NdbDatabase.Store(_id.ToString(), _state, 0, _state.Length);
|
||||
_state = null;
|
||||
}
|
||||
|
||||
|
@ -92,8 +92,8 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
string key = _id.ToString();
|
||||
_state = _manager.ndbdatabase.FetchAll(key);
|
||||
_manager.ndbdatabase.Release(key);
|
||||
_state = _manager.NdbDatabase.FetchAll(key);
|
||||
_manager.NdbDatabase.Release(key);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@ -103,7 +103,7 @@ namespace BizHawk.Client.Common
|
|||
return;
|
||||
}
|
||||
|
||||
_manager.ndbdatabase.Release(_id.ToString());
|
||||
_manager.NdbDatabase.Release(_id.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,27 +9,26 @@ namespace BizHawk.Client.Common
|
|||
public class TasLagLog
|
||||
{
|
||||
// TODO: Change this into a regular list.
|
||||
private List<bool> LagLog = new List<bool>();
|
||||
|
||||
private List<bool> WasLag = new List<bool>();
|
||||
private List<bool> _lagLog = new List<bool>();
|
||||
private List<bool> _wasLag = new List<bool>();
|
||||
|
||||
public bool? this[int frame]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (frame < LagLog.Count)
|
||||
if (frame < _lagLog.Count)
|
||||
{
|
||||
if (frame < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return LagLog[frame];
|
||||
return _lagLog[frame];
|
||||
}
|
||||
|
||||
if (frame == Global.Emulator.Frame && frame == LagLog.Count)
|
||||
if (frame == Global.Emulator.Frame && frame == _lagLog.Count)
|
||||
{
|
||||
// LagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame; // Note: Side effects!
|
||||
////LagLog[frame] = Global.Emulator.AsInputPollable().IsLagFrame; // Note: Side effects!
|
||||
return Global.Emulator.AsInputPollable().IsLagFrame;
|
||||
}
|
||||
|
||||
|
@ -40,7 +39,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (!value.HasValue)
|
||||
{
|
||||
LagLog.RemoveAt(frame);
|
||||
_lagLog.RemoveAt(frame);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,61 +48,61 @@ namespace BizHawk.Client.Common
|
|||
return; // Nothing to do
|
||||
}
|
||||
|
||||
if (frame > LagLog.Count)
|
||||
if (frame > _lagLog.Count)
|
||||
{
|
||||
System.Diagnostics.Debug.Print("Lag Log error. f" + frame + ", log: " + LagLog.Count);
|
||||
System.Diagnostics.Debug.Print("Lag Log error. f" + frame + ", log: " + _lagLog.Count);
|
||||
return; // Can this break anything?
|
||||
}
|
||||
|
||||
bool wasValue;
|
||||
if (frame < LagLog.Count)
|
||||
if (frame < _lagLog.Count)
|
||||
{
|
||||
wasValue = LagLog[frame];
|
||||
wasValue = _lagLog[frame];
|
||||
}
|
||||
else if (frame == WasLag.Count)
|
||||
else if (frame == _wasLag.Count)
|
||||
{
|
||||
wasValue = value.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
wasValue = WasLag[frame];
|
||||
wasValue = _wasLag[frame];
|
||||
}
|
||||
|
||||
if (frame == WasLag.Count)
|
||||
if (frame == _wasLag.Count)
|
||||
{
|
||||
WasLag.Add(wasValue);
|
||||
_wasLag.Add(wasValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
WasLag[frame] = wasValue;
|
||||
_wasLag[frame] = wasValue;
|
||||
}
|
||||
|
||||
if (frame != 0)
|
||||
{
|
||||
WasLag[frame - 1] = LagLog[frame - 1];
|
||||
_wasLag[frame - 1] = _lagLog[frame - 1];
|
||||
}
|
||||
|
||||
if (frame >= LagLog.Count)
|
||||
if (frame >= _lagLog.Count)
|
||||
{
|
||||
LagLog.Add(value.Value);
|
||||
_lagLog.Add(value.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
LagLog[frame] = value.Value;
|
||||
_lagLog[frame] = value.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
LagLog.Clear();
|
||||
_lagLog.Clear();
|
||||
}
|
||||
|
||||
public bool RemoveFrom(int frame)
|
||||
{
|
||||
if (LagLog.Count > frame && frame >= 0)
|
||||
if (_lagLog.Count > frame && frame >= 0)
|
||||
{
|
||||
LagLog.RemoveRange(frame + 1, LagLog.Count - frame - 1);
|
||||
_lagLog.RemoveRange(frame + 1, _lagLog.Count - frame - 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -112,41 +111,41 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void RemoveHistoryAt(int frame)
|
||||
{
|
||||
WasLag.RemoveAt(frame);
|
||||
_wasLag.RemoveAt(frame);
|
||||
}
|
||||
|
||||
public void InsertHistoryAt(int frame, bool isLag)
|
||||
{
|
||||
// LagLog was invalidated when the frame was inserted
|
||||
if (frame <= LagLog.Count)
|
||||
if (frame <= _lagLog.Count)
|
||||
{
|
||||
LagLog.Insert(frame, isLag);
|
||||
_lagLog.Insert(frame, isLag);
|
||||
}
|
||||
|
||||
WasLag.Insert(frame, isLag);
|
||||
_wasLag.Insert(frame, isLag);
|
||||
}
|
||||
|
||||
public void Save(BinaryWriter bw)
|
||||
{
|
||||
bw.Write((byte)1); // New saving format.
|
||||
bw.Write(LagLog.Count);
|
||||
bw.Write(WasLag.Count);
|
||||
for (int i = 0; i < LagLog.Count; i++)
|
||||
bw.Write(_lagLog.Count);
|
||||
bw.Write(_wasLag.Count);
|
||||
for (int i = 0; i < _lagLog.Count; i++)
|
||||
{
|
||||
bw.Write(LagLog[i]);
|
||||
bw.Write(WasLag[i]);
|
||||
bw.Write(_lagLog[i]);
|
||||
bw.Write(_wasLag[i]);
|
||||
}
|
||||
|
||||
for (int i = LagLog.Count; i < WasLag.Count; i++)
|
||||
for (int i = _lagLog.Count; i < _wasLag.Count; i++)
|
||||
{
|
||||
bw.Write(WasLag[i]);
|
||||
bw.Write(_wasLag[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(BinaryReader br)
|
||||
{
|
||||
LagLog.Clear();
|
||||
WasLag.Clear();
|
||||
_lagLog.Clear();
|
||||
_wasLag.Clear();
|
||||
////if (br.BaseStream.Length > 0)
|
||||
////{ BaseStream.Length does not return the expected value.
|
||||
int formatVersion = br.ReadByte();
|
||||
|
@ -157,8 +156,8 @@ namespace BizHawk.Client.Common
|
|||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
br.ReadInt32();
|
||||
LagLog.Add(br.ReadBoolean());
|
||||
WasLag.Add(LagLog.Last());
|
||||
_lagLog.Add(br.ReadBoolean());
|
||||
_wasLag.Add(_lagLog.Last());
|
||||
}
|
||||
}
|
||||
else if (formatVersion == 1)
|
||||
|
@ -167,13 +166,13 @@ namespace BizHawk.Client.Common
|
|||
int lenWas = br.ReadInt32();
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
LagLog.Add(br.ReadBoolean());
|
||||
WasLag.Add(br.ReadBoolean());
|
||||
_lagLog.Add(br.ReadBoolean());
|
||||
_wasLag.Add(br.ReadBoolean());
|
||||
}
|
||||
|
||||
for (int i = length; i < lenWas; i++)
|
||||
{
|
||||
WasLag.Add(br.ReadBoolean());
|
||||
_wasLag.Add(br.ReadBoolean());
|
||||
}
|
||||
}
|
||||
////}
|
||||
|
@ -181,14 +180,14 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public bool? History(int frame)
|
||||
{
|
||||
if (frame < WasLag.Count)
|
||||
if (frame < _wasLag.Count)
|
||||
{
|
||||
if (frame < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return WasLag[frame];
|
||||
return _wasLag[frame];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -198,12 +197,12 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
if (LagLog.Count == 0)
|
||||
if (_lagLog.Count == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return LagLog.Count - 1;
|
||||
return _lagLog.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,21 +210,21 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
return new TasLagLog
|
||||
{
|
||||
LagLog = LagLog.ToList(),
|
||||
WasLag = WasLag.ToList()
|
||||
_lagLog = _lagLog.ToList(),
|
||||
_wasLag = _wasLag.ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void FromLagLog(TasLagLog log)
|
||||
{
|
||||
LagLog = log.LagLog.ToList();
|
||||
WasLag = log.WasLag.ToList();
|
||||
_lagLog = log._lagLog.ToList();
|
||||
_wasLag = log._wasLag.ToList();
|
||||
}
|
||||
|
||||
public void StartFromFrame(int index)
|
||||
{
|
||||
LagLog.RemoveRange(0, index);
|
||||
WasLag.RemoveRange(0, index);
|
||||
_lagLog.RemoveRange(0, index);
|
||||
_wasLag.RemoveRange(0, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace BizHawk.Client.Common
|
|||
bool endBatch = ChangeLog.BeginNewBatch("Truncate Movie: " + frame, true);
|
||||
ChangeLog.AddGeneralUndo(frame, InputLogLength - 1);
|
||||
|
||||
if (frame < _log.Count - 1)
|
||||
if (frame < Log.Count - 1)
|
||||
{
|
||||
Changes = true;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ namespace BizHawk.Client.Common
|
|||
bool endBatch = ChangeLog.BeginNewBatch("Remove Frame: " + frame, true);
|
||||
ChangeLog.AddGeneralUndo(frame, InputLogLength - 1);
|
||||
|
||||
_log.RemoveAt(frame);
|
||||
Log.RemoveAt(frame);
|
||||
if (BindMarkersToInput)
|
||||
{
|
||||
bool wasRecording = ChangeLog.IsRecording;
|
||||
|
@ -138,9 +138,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
foreach (var frame in frames.OrderByDescending(f => f)) // Removing them in reverse order allows us to remove by index;
|
||||
{
|
||||
if (frame < _log.Count)
|
||||
if (frame < Log.Count)
|
||||
{
|
||||
_log.RemoveAt(frame);
|
||||
Log.RemoveAt(frame);
|
||||
}
|
||||
|
||||
if (BindMarkersToInput) // TODO: This is slow, is there a better way to do it?
|
||||
|
@ -186,7 +186,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
for (int i = removeUpTo - 1; i >= removeStart; i--)
|
||||
{
|
||||
_log.RemoveAt(i);
|
||||
Log.RemoveAt(i);
|
||||
}
|
||||
|
||||
if (BindMarkersToInput)
|
||||
|
@ -228,7 +228,7 @@ namespace BizHawk.Client.Common
|
|||
bool endBatch = ChangeLog.BeginNewBatch("Insert Frame: " + frame, true);
|
||||
ChangeLog.AddGeneralUndo(frame, InputLogLength);
|
||||
|
||||
_log.Insert(frame, inputState);
|
||||
Log.Insert(frame, inputState);
|
||||
Changes = true;
|
||||
InvalidateAfter(frame);
|
||||
|
||||
|
@ -261,7 +261,7 @@ namespace BizHawk.Client.Common
|
|||
bool endBatch = ChangeLog.BeginNewBatch("Insert Frame: " + frame, true);
|
||||
ChangeLog.AddGeneralUndo(frame, InputLogLength + inputLog.Count() - 1);
|
||||
|
||||
_log.InsertRange(frame, inputLog);
|
||||
Log.InsertRange(frame, inputLog);
|
||||
Changes = true;
|
||||
InvalidateAfter(frame);
|
||||
|
||||
|
@ -311,22 +311,22 @@ namespace BizHawk.Client.Common
|
|||
var lg = LogGeneratorInstance();
|
||||
var states = inputStates.ToList();
|
||||
|
||||
if (_log.Count < states.Count + frame)
|
||||
if (Log.Count < states.Count + frame)
|
||||
{
|
||||
ExtendMovieForEdit(states.Count + frame - _log.Count);
|
||||
ExtendMovieForEdit(states.Count + frame - Log.Count);
|
||||
}
|
||||
|
||||
ChangeLog.AddGeneralUndo(frame, frame + inputStates.Count() - 1, "Copy Over Input: " + frame);
|
||||
|
||||
for (int i = 0; i < states.Count; i++)
|
||||
{
|
||||
if (_log.Count <= frame + i)
|
||||
if (Log.Count <= frame + i)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
lg.SetSource(states[i]);
|
||||
_log[frame + i] = lg.GenerateLogEntry();
|
||||
Log[frame + i] = lg.GenerateLogEntry();
|
||||
}
|
||||
|
||||
ChangeLog.EndBatch();
|
||||
|
@ -344,14 +344,14 @@ namespace BizHawk.Client.Common
|
|||
var lg = LogGeneratorInstance();
|
||||
lg.SetSource(Global.MovieSession.MovieControllerInstance());
|
||||
|
||||
if (frame > _log.Count())
|
||||
if (frame > Log.Count())
|
||||
{
|
||||
frame = _log.Count();
|
||||
frame = Log.Count();
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_log.Insert(frame, lg.EmptyEntry);
|
||||
Log.Insert(frame, lg.EmptyEntry);
|
||||
}
|
||||
|
||||
if (BindMarkersToInput)
|
||||
|
@ -380,7 +380,7 @@ namespace BizHawk.Client.Common
|
|||
ChangeLog.EndBatch();
|
||||
}
|
||||
|
||||
if (Global.Emulator.Frame < _log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting.
|
||||
if (Global.Emulator.Frame < Log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting.
|
||||
{
|
||||
SwitchToPlay();
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
for (int i = 0; i < numFrames; i++)
|
||||
{
|
||||
_log.Add(lg.GenerateLogEntry());
|
||||
Log.Add(lg.GenerateLogEntry());
|
||||
}
|
||||
|
||||
Changes = true;
|
||||
|
@ -410,7 +410,7 @@ namespace BizHawk.Client.Common
|
|||
ChangeLog.EndBatch();
|
||||
}
|
||||
|
||||
if (Global.Emulator.Frame < _log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting.
|
||||
if (Global.Emulator.Frame < Log.Count) // Don't stay in recording mode? Fixes TAStudio recording after paint inserting.
|
||||
{
|
||||
SwitchToPlay();
|
||||
}
|
||||
|
@ -418,9 +418,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void ToggleBoolState(int frame, string buttonName)
|
||||
{
|
||||
if (frame >= _log.Count) // Insert blank frames up to this point
|
||||
if (frame >= Log.Count) // Insert blank frames up to this point
|
||||
{
|
||||
ExtendMovieForEdit(frame - _log.Count + 1);
|
||||
ExtendMovieForEdit(frame - Log.Count + 1);
|
||||
}
|
||||
|
||||
var adapter = GetInputState(frame) as Bk2ControllerAdapter;
|
||||
|
@ -428,7 +428,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
var lg = LogGeneratorInstance();
|
||||
lg.SetSource(adapter);
|
||||
_log[frame] = lg.GenerateLogEntry();
|
||||
Log[frame] = lg.GenerateLogEntry();
|
||||
Changes = true;
|
||||
InvalidateAfter(frame);
|
||||
|
||||
|
@ -437,9 +437,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SetBoolState(int frame, string buttonName, bool val)
|
||||
{
|
||||
if (frame >= _log.Count) // Insert blank frames up to this point
|
||||
if (frame >= Log.Count) // Insert blank frames up to this point
|
||||
{
|
||||
ExtendMovieForEdit(frame - _log.Count + 1);
|
||||
ExtendMovieForEdit(frame - Log.Count + 1);
|
||||
}
|
||||
|
||||
var adapter = GetInputState(frame) as Bk2ControllerAdapter;
|
||||
|
@ -448,7 +448,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
var lg = LogGeneratorInstance();
|
||||
lg.SetSource(adapter);
|
||||
_log[frame] = lg.GenerateLogEntry();
|
||||
Log[frame] = lg.GenerateLogEntry();
|
||||
|
||||
if (old != val)
|
||||
{
|
||||
|
@ -460,9 +460,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SetBoolStates(int frame, int count, string buttonName, bool val)
|
||||
{
|
||||
if (frame + count >= _log.Count) // Insert blank frames up to this point
|
||||
if (Log.Count < frame + count)
|
||||
{
|
||||
ExtendMovieForEdit(frame - _log.Count + 1);
|
||||
ExtendMovieForEdit(frame + count - Log.Count);
|
||||
}
|
||||
|
||||
ChangeLog.AddGeneralUndo(frame, frame + count - 1, "Set " + buttonName + "(" + (val ? "On" : "Off") + "): " + frame + "-" + (frame + count - 1));
|
||||
|
@ -476,7 +476,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
var lg = LogGeneratorInstance();
|
||||
lg.SetSource(adapter);
|
||||
_log[frame + i] = lg.GenerateLogEntry();
|
||||
Log[frame + i] = lg.GenerateLogEntry();
|
||||
|
||||
if (changed == -1 && old != val)
|
||||
{
|
||||
|
@ -495,9 +495,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SetFloatState(int frame, string buttonName, float val)
|
||||
{
|
||||
if (frame >= _log.Count) // Insert blank frames up to this point
|
||||
if (frame >= Log.Count) // Insert blank frames up to this point
|
||||
{
|
||||
ExtendMovieForEdit(frame - _log.Count + 1);
|
||||
ExtendMovieForEdit(frame - Log.Count + 1);
|
||||
}
|
||||
|
||||
var adapter = GetInputState(frame) as Bk2ControllerAdapter;
|
||||
|
@ -506,7 +506,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
var lg = LogGeneratorInstance();
|
||||
lg.SetSource(adapter);
|
||||
_log[frame] = lg.GenerateLogEntry();
|
||||
Log[frame] = lg.GenerateLogEntry();
|
||||
|
||||
if (old != val)
|
||||
{
|
||||
|
@ -518,9 +518,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SetFloatStates(int frame, int count, string buttonName, float val)
|
||||
{
|
||||
if (frame + count >= _log.Count) // Insert blank frames up to this point
|
||||
if (frame + count >= Log.Count) // Insert blank frames up to this point
|
||||
{
|
||||
ExtendMovieForEdit(frame - _log.Count + 1);
|
||||
ExtendMovieForEdit(frame - Log.Count + 1);
|
||||
}
|
||||
|
||||
ChangeLog.AddGeneralUndo(frame, frame + count - 1, "Set " + buttonName + "(" + val + "): " + frame + "-" + (frame + count - 1));
|
||||
|
@ -534,7 +534,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
var lg = LogGeneratorInstance();
|
||||
lg.SetSource(adapter);
|
||||
_log[frame + i] = lg.GenerateLogEntry();
|
||||
Log[frame + i] = lg.GenerateLogEntry();
|
||||
|
||||
if (changed == -1 && old != val)
|
||||
{
|
||||
|
|
|
@ -6,10 +6,21 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class TasMovieChangeLog
|
||||
{
|
||||
private readonly List<List<IMovieAction>> History;
|
||||
public List<string> Names;
|
||||
public int UndoIndex = -1;
|
||||
public TasMovieChangeLog(TasMovie movie)
|
||||
{
|
||||
_history = new List<List<IMovieAction>>();
|
||||
_movie = movie;
|
||||
}
|
||||
|
||||
private readonly List<List<IMovieAction>> _history = new List<List<IMovieAction>>();
|
||||
private readonly TasMovie _movie;
|
||||
|
||||
private int _maxSteps = 100;
|
||||
private int _totalSteps;
|
||||
private bool _recordingBatch;
|
||||
|
||||
public List<string> Names { get; } = new List<string>();
|
||||
public int UndoIndex { get; private set; } = -1;
|
||||
|
||||
public int MaxSteps
|
||||
{
|
||||
|
@ -21,46 +32,35 @@ namespace BizHawk.Client.Common
|
|||
set
|
||||
{
|
||||
_maxSteps = value;
|
||||
if (History.Count > value)
|
||||
if (_history.Count > value)
|
||||
{
|
||||
if (History.Count <= value)
|
||||
if (_history.Count <= value)
|
||||
{
|
||||
ClearLog();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearLog(History.Count - value);
|
||||
ClearLog(_history.Count - value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _totalSteps = 0;
|
||||
private bool RecordingBatch = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the movie is in recording mode
|
||||
/// This is not intended to turn off the ChangeLog, but to disable the normal recording process.
|
||||
/// Use this to manually control the ChangeLog. (Useful for when you are making lots of
|
||||
/// </summary>
|
||||
public bool IsRecording = true;
|
||||
|
||||
public TasMovie Movie;
|
||||
|
||||
public TasMovieChangeLog(TasMovie movie)
|
||||
{
|
||||
History = new List<List<IMovieAction>>();
|
||||
Names = new List<string>();
|
||||
Movie = movie;
|
||||
}
|
||||
public bool IsRecording { get; set; } = true;
|
||||
|
||||
public void ClearLog(int upTo = -1)
|
||||
{
|
||||
if (upTo == -1)
|
||||
{
|
||||
upTo = History.Count;
|
||||
upTo = _history.Count;
|
||||
}
|
||||
|
||||
History.RemoveRange(0, upTo);
|
||||
_history.RemoveRange(0, upTo);
|
||||
Names.RemoveRange(0, upTo);
|
||||
UndoIndex -= upTo;
|
||||
if (UndoIndex < -1)
|
||||
|
@ -68,25 +68,25 @@ namespace BizHawk.Client.Common
|
|||
UndoIndex = -1;
|
||||
}
|
||||
|
||||
if (History.Count == 0)
|
||||
if (_history.Count == 0)
|
||||
{
|
||||
RecordingBatch = false;
|
||||
_recordingBatch = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void TruncateLog(int from)
|
||||
{
|
||||
History.RemoveRange(from, History.Count - from);
|
||||
_history.RemoveRange(from, _history.Count - from);
|
||||
Names.RemoveRange(from, Names.Count - from);
|
||||
|
||||
if (UndoIndex < History.Count - 1)
|
||||
if (UndoIndex < _history.Count - 1)
|
||||
{
|
||||
UndoIndex = History.Count - 1;
|
||||
UndoIndex = _history.Count - 1;
|
||||
}
|
||||
|
||||
if (RecordingBatch)
|
||||
if (_recordingBatch)
|
||||
{
|
||||
RecordingBatch = false;
|
||||
_recordingBatch = false;
|
||||
BeginNewBatch();
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
bool ret = true;
|
||||
if (RecordingBatch)
|
||||
if (_recordingBatch)
|
||||
{
|
||||
if (keepOldBatch)
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ namespace BizHawk.Client.Common
|
|||
ret = AddMovieAction(name);
|
||||
}
|
||||
|
||||
RecordingBatch = true;
|
||||
_recordingBatch = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -134,16 +134,16 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public void EndBatch()
|
||||
{
|
||||
if (!IsRecording || !RecordingBatch)
|
||||
if (!IsRecording || !_recordingBatch)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RecordingBatch = false;
|
||||
List<IMovieAction> last = History.Last();
|
||||
_recordingBatch = false;
|
||||
List<IMovieAction> last = _history.Last();
|
||||
if (last.Count == 0) // Remove batch if it's empty.
|
||||
{
|
||||
History.RemoveAt(History.Count - 1);
|
||||
_history.RemoveAt(_history.Count - 1);
|
||||
Names.RemoveAt(Names.Count - 1);
|
||||
UndoIndex--;
|
||||
}
|
||||
|
@ -161,22 +161,22 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (UndoIndex == -1)
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
List<IMovieAction> batch = History[UndoIndex];
|
||||
List<IMovieAction> batch = _history[UndoIndex];
|
||||
for (int i = batch.Count - 1; i >= 0; i--)
|
||||
{
|
||||
batch[i].Undo(Movie);
|
||||
batch[i].Undo(_movie);
|
||||
}
|
||||
|
||||
UndoIndex--;
|
||||
|
||||
RecordingBatch = false;
|
||||
_recordingBatch = false;
|
||||
|
||||
if (batch.All(a => a.GetType() == typeof(MovieActionMarker)))
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
return PreviousUndoFrame;
|
||||
|
@ -188,30 +188,30 @@ namespace BizHawk.Client.Common
|
|||
/// <returns>Returns the frame which the movie needs to rewind to.</returns>
|
||||
public int Redo()
|
||||
{
|
||||
if (UndoIndex == History.Count - 1)
|
||||
if (UndoIndex == _history.Count - 1)
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
UndoIndex++;
|
||||
List<IMovieAction> batch = History[UndoIndex];
|
||||
List<IMovieAction> batch = _history[UndoIndex];
|
||||
foreach (IMovieAction b in batch)
|
||||
{
|
||||
b.Redo(Movie);
|
||||
b.Redo(_movie);
|
||||
}
|
||||
|
||||
RecordingBatch = false;
|
||||
_recordingBatch = false;
|
||||
|
||||
if (batch.All(a => a.GetType() == typeof(MovieActionMarker)))
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
return PreviousRedoFrame;
|
||||
}
|
||||
|
||||
public bool CanUndo => UndoIndex > -1;
|
||||
public bool CanRedo => UndoIndex < History.Count - 1;
|
||||
public bool CanRedo => UndoIndex < _history.Count - 1;
|
||||
|
||||
public string NextUndoStepName
|
||||
{
|
||||
|
@ -230,17 +230,17 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
if (UndoIndex == History.Count - 1)
|
||||
if (UndoIndex == _history.Count - 1)
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
if (History[UndoIndex + 1].Count == 0)
|
||||
if (_history[UndoIndex + 1].Count == 0)
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
return History[UndoIndex + 1].Min(a => a.FirstFrame);
|
||||
return _history[UndoIndex + 1].Min(a => a.FirstFrame);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,15 +250,15 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (UndoIndex == -1)
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
if (History[UndoIndex].Count == 0)
|
||||
if (_history[UndoIndex].Count == 0)
|
||||
{
|
||||
return Movie.InputLogLength;
|
||||
return _movie.InputLogLength;
|
||||
}
|
||||
|
||||
return History[UndoIndex].Min(a => a.FirstFrame);
|
||||
return _history[UndoIndex].Min(a => a.FirstFrame);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private bool AddMovieAction(string name)
|
||||
{
|
||||
if (UndoIndex + 1 != History.Count)
|
||||
if (UndoIndex + 1 != _history.Count)
|
||||
{
|
||||
TruncateLog(UndoIndex + 1);
|
||||
}
|
||||
|
@ -277,20 +277,20 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
bool ret = false;
|
||||
if (!RecordingBatch)
|
||||
if (!_recordingBatch)
|
||||
{
|
||||
ret = true;
|
||||
History.Add(new List<IMovieAction>(1));
|
||||
_history.Add(new List<IMovieAction>(1));
|
||||
Names.Add(name);
|
||||
_totalSteps += 1;
|
||||
|
||||
if (History.Count <= MaxSteps)
|
||||
if (_history.Count <= MaxSteps)
|
||||
{
|
||||
UndoIndex += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
History.RemoveAt(0);
|
||||
_history.RemoveAt(0);
|
||||
Names.RemoveAt(0);
|
||||
ret = false;
|
||||
}
|
||||
|
@ -312,8 +312,8 @@ namespace BizHawk.Client.Common
|
|||
if (IsRecording || force)
|
||||
{
|
||||
AddMovieAction(name);
|
||||
History.Last().Add(new MovieAction(first, last, Movie));
|
||||
_lastGeneral = History.Last().Count - 1;
|
||||
_history.Last().Add(new MovieAction(first, last, _movie));
|
||||
_lastGeneral = _history.Last().Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (IsRecording || force)
|
||||
{
|
||||
(History.Last()[_lastGeneral] as MovieAction).SetRedoLog(Movie);
|
||||
(_history.Last()[_lastGeneral] as MovieAction).SetRedoLog(_movie);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ namespace BizHawk.Client.Common
|
|||
if (IsRecording || force)
|
||||
{
|
||||
AddMovieAction(name);
|
||||
History.Last().Add(new MovieActionFrameEdit(frame, button, oldState, !oldState));
|
||||
_history.Last().Add(new MovieActionFrameEdit(frame, button, oldState, !oldState));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,11 +339,11 @@ namespace BizHawk.Client.Common
|
|||
if (IsRecording || force)
|
||||
{
|
||||
AddMovieAction(name);
|
||||
History.Last().Add(new MovieActionFrameEdit(frame, button, oldState, newState));
|
||||
_history.Last().Add(new MovieActionFrameEdit(frame, button, oldState, newState));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddMarkerChange(TasMovieMarker newMarker, int oldPosition = -1, string old_message = "", string name = "", bool force = false)
|
||||
public void AddMarkerChange(TasMovieMarker newMarker, int oldPosition = -1, string oldMessage = "", string name = "", bool force = false)
|
||||
{
|
||||
if (IsRecording || force)
|
||||
{
|
||||
|
@ -357,7 +357,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
AddMovieAction(name);
|
||||
History.Last().Add(new MovieActionMarker(newMarker, oldPosition, old_message));
|
||||
_history.Last().Add(new MovieActionMarker(newMarker, oldPosition, oldMessage));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ namespace BizHawk.Client.Common
|
|||
if (IsRecording || force)
|
||||
{
|
||||
AddMovieAction(name);
|
||||
History.Last().Add(new MovieActionBindInput(Movie, frame, isDelete));
|
||||
_history.Last().Add(new MovieActionBindInput(_movie, frame, isDelete));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ namespace BizHawk.Client.Common
|
|||
private readonly int _undoLength;
|
||||
private int _redoLength;
|
||||
|
||||
private int length => LastFrame - FirstFrame + 1;
|
||||
private int Length => LastFrame - FirstFrame + 1;
|
||||
|
||||
private readonly List<string> _oldLog;
|
||||
private List<string> _newLog;
|
||||
|
@ -402,7 +402,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
FirstFrame = firstFrame;
|
||||
LastFrame = lastFrame;
|
||||
_oldLog = new List<string>(length);
|
||||
_oldLog = new List<string>(Length);
|
||||
_undoLength = Math.Min(LastFrame + 1, movie.InputLogLength) - FirstFrame;
|
||||
|
||||
for (int i = 0; i < _undoLength; i++)
|
||||
|
@ -430,12 +430,12 @@ namespace BizHawk.Client.Common
|
|||
movie.ChangeLog.IsRecording = false;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
|
||||
if (_redoLength != length)
|
||||
if (_redoLength != Length)
|
||||
{
|
||||
movie.InsertEmptyFrame(FirstFrame, length - _redoLength, true);
|
||||
movie.InsertEmptyFrame(FirstFrame, Length - _redoLength, true);
|
||||
}
|
||||
|
||||
if (_undoLength != length)
|
||||
if (_undoLength != Length)
|
||||
{
|
||||
movie.RemoveFrames(FirstFrame, movie.InputLogLength - _undoLength, true);
|
||||
}
|
||||
|
@ -456,12 +456,12 @@ namespace BizHawk.Client.Common
|
|||
movie.ChangeLog.IsRecording = false;
|
||||
movie.BindMarkersToInput = _bindMarkers;
|
||||
|
||||
if (_undoLength != length)
|
||||
if (_undoLength != Length)
|
||||
{
|
||||
movie.InsertEmptyFrame(FirstFrame, length - _undoLength);
|
||||
movie.InsertEmptyFrame(FirstFrame, Length - _undoLength);
|
||||
}
|
||||
|
||||
if (_redoLength != length)
|
||||
if (_redoLength != Length)
|
||||
{
|
||||
movie.RemoveFrames(FirstFrame, movie.InputLogLength - _redoLength);
|
||||
}
|
||||
|
@ -484,18 +484,18 @@ namespace BizHawk.Client.Common
|
|||
private readonly string _oldMessage;
|
||||
private readonly string _newMessage;
|
||||
|
||||
public MovieActionMarker(TasMovieMarker marker, int oldPosition = -1, string old_message = "")
|
||||
public MovieActionMarker(TasMovieMarker marker, int oldPosition = -1, string oldMessage = "")
|
||||
{
|
||||
FirstFrame = oldPosition;
|
||||
if (marker == null)
|
||||
{
|
||||
LastFrame = -1;
|
||||
_oldMessage = old_message;
|
||||
_oldMessage = oldMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
LastFrame = marker.Frame;
|
||||
_oldMessage = old_message == "" ? marker.Message : old_message;
|
||||
_oldMessage = oldMessage == "" ? marker.Message : oldMessage;
|
||||
_newMessage = marker.Message;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public TasLagLog TasLagLog => _lagLog;
|
||||
|
||||
public IStringLog InputLog => _log;
|
||||
public IStringLog InputLog => Log;
|
||||
|
||||
public TasMovieMarkerList Markers { get; private set; }
|
||||
|
||||
|
@ -139,12 +139,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public override void SwitchToPlay()
|
||||
{
|
||||
_mode = Moviemode.Play;
|
||||
Mode = Moviemode.Play;
|
||||
}
|
||||
|
||||
public override void SwitchToRecord()
|
||||
{
|
||||
_mode = Moviemode.Record;
|
||||
Mode = Moviemode.Record;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -250,18 +250,18 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void DeleteLogBefore(int frame)
|
||||
{
|
||||
if (frame < _log.Count)
|
||||
if (frame < Log.Count)
|
||||
{
|
||||
_log.RemoveRange(0, frame);
|
||||
Log.RemoveRange(0, frame);
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyLog(IEnumerable<string> log)
|
||||
{
|
||||
_log.Clear();
|
||||
Log.Clear();
|
||||
foreach (var entry in log)
|
||||
{
|
||||
_log.Add(entry);
|
||||
Log.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,10 +275,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public IStringLog GetLogEntries()
|
||||
{
|
||||
return _log;
|
||||
return Log;
|
||||
}
|
||||
|
||||
private int? TimelineBranchFrame = null;
|
||||
private int? _timelineBranchFrame = null;
|
||||
|
||||
// TODO: this is 99% copy pasting of bad code
|
||||
public override bool ExtractInputLog(TextReader reader, out string errorMessage)
|
||||
|
@ -291,9 +291,9 @@ namespace BizHawk.Client.Common
|
|||
// We are in record mode so replace the movie log with the one from the savestate
|
||||
if (!Global.MovieSession.MultiTrack.IsActive)
|
||||
{
|
||||
TimelineBranchFrame = null;
|
||||
_timelineBranchFrame = null;
|
||||
|
||||
if (Global.Config.EnableBackupMovies && MakeBackup && _log.Count != 0)
|
||||
if (Global.Config.EnableBackupMovies && MakeBackup && Log.Count != 0)
|
||||
{
|
||||
SaveBackup();
|
||||
MakeBackup = false;
|
||||
|
@ -341,17 +341,17 @@ namespace BizHawk.Client.Common
|
|||
else if (line[0] == '|')
|
||||
{
|
||||
newLog.Add(line);
|
||||
if (!TimelineBranchFrame.HasValue && counter < _log.Count && line != _log[counter])
|
||||
if (!_timelineBranchFrame.HasValue && counter < Log.Count && line != Log[counter])
|
||||
{
|
||||
TimelineBranchFrame = counter;
|
||||
_timelineBranchFrame = counter;
|
||||
}
|
||||
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
_log.Clear();
|
||||
_log.AddRange(newLog);
|
||||
Log.Clear();
|
||||
Log.AddRange(newLog);
|
||||
}
|
||||
else // Multitrack mode
|
||||
{
|
||||
|
@ -410,21 +410,21 @@ namespace BizHawk.Client.Common
|
|||
|
||||
var stateFramei = stateFrame ?? 0;
|
||||
|
||||
if (stateFramei > 0 && stateFramei < _log.Count)
|
||||
if (stateFramei > 0 && stateFramei < Log.Count)
|
||||
{
|
||||
if (!Global.Config.VBAStyleMovieLoadState)
|
||||
{
|
||||
Truncate(stateFramei);
|
||||
}
|
||||
}
|
||||
else if (stateFramei > _log.Count) // Post movie savestate
|
||||
else if (stateFramei > Log.Count) // Post movie savestate
|
||||
{
|
||||
if (!Global.Config.VBAStyleMovieLoadState)
|
||||
{
|
||||
Truncate(_log.Count);
|
||||
Truncate(Log.Count);
|
||||
}
|
||||
|
||||
_mode = Moviemode.Finished;
|
||||
Mode = Moviemode.Finished;
|
||||
}
|
||||
|
||||
if (IsCountingRerecords)
|
||||
|
@ -432,10 +432,10 @@ namespace BizHawk.Client.Common
|
|||
Rerecords++;
|
||||
}
|
||||
|
||||
if (TimelineBranchFrame.HasValue)
|
||||
if (_timelineBranchFrame.HasValue)
|
||||
{
|
||||
_lagLog.RemoveFrom(TimelineBranchFrame.Value);
|
||||
TasStateManager.Invalidate(TimelineBranchFrame.Value);
|
||||
_lagLog.RemoveFrom(_timelineBranchFrame.Value);
|
||||
TasStateManager.Invalidate(_timelineBranchFrame.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -510,10 +510,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void LoadBranch(TasBranch branch)
|
||||
{
|
||||
int? divergentPoint = DivergentPoint(_log, branch.InputLog);
|
||||
int? divergentPoint = DivergentPoint(Log, branch.InputLog);
|
||||
|
||||
_log?.Dispose();
|
||||
_log = branch.InputLog.Clone();
|
||||
Log?.Dispose();
|
||||
Log = branch.InputLog.Clone();
|
||||
////_changes = true;
|
||||
|
||||
// if there are branch states, they will be loaded anyway
|
||||
|
|
|
@ -26,26 +26,26 @@ namespace BizHawk.Client.Common
|
|||
InvalidateCallback?.Invoke(index);
|
||||
}
|
||||
|
||||
private readonly List<StateManagerState> lowPriorityStates = new List<StateManagerState>();
|
||||
internal NDBDatabase ndbdatabase;
|
||||
private Guid guid = Guid.NewGuid();
|
||||
private SortedList<int, StateManagerState> States = new SortedList<int, StateManagerState>();
|
||||
private readonly List<StateManagerState> _lowPriorityStates = new List<StateManagerState>();
|
||||
internal NDBDatabase NdbDatabase { get; set; }
|
||||
private Guid _guid = Guid.NewGuid();
|
||||
private SortedList<int, StateManagerState> _states = new SortedList<int, StateManagerState>();
|
||||
|
||||
private string statePath
|
||||
private string StatePath
|
||||
{
|
||||
get
|
||||
{
|
||||
var basePath = PathManager.MakeAbsolutePath(Global.Config.PathEntries["Global", "TAStudio states"].Path, null);
|
||||
return Path.Combine(basePath, guid.ToString());
|
||||
return Path.Combine(basePath, _guid.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isMountedForWrite;
|
||||
private readonly TasMovie _movie;
|
||||
private ulong _expectedStateSize = 0;
|
||||
private ulong _expectedStateSize;
|
||||
|
||||
private readonly int _minFrequency = VersionInfo.DeveloperBuild ? 2 : 1;
|
||||
private const int _maxFrequency = 16;
|
||||
private const int MaxFrequency = 16;
|
||||
|
||||
private int StateFrequency
|
||||
{
|
||||
|
@ -58,18 +58,18 @@ namespace BizHawk.Client.Common
|
|||
return _minFrequency;
|
||||
}
|
||||
|
||||
if (freq > _maxFrequency)
|
||||
if (freq > MaxFrequency)
|
||||
{
|
||||
return _maxFrequency;
|
||||
return MaxFrequency;
|
||||
}
|
||||
|
||||
return freq;
|
||||
}
|
||||
}
|
||||
|
||||
private int maxStates => (int)(Settings.Cap / _expectedStateSize) + (int)((ulong)Settings.DiskCapacitymb * 1024 * 1024 / _expectedStateSize);
|
||||
private int MaxStates => (int)(Settings.Cap / _expectedStateSize) + (int)((ulong)Settings.DiskCapacitymb * 1024 * 1024 / _expectedStateSize);
|
||||
|
||||
private int _stateGap => 1 << Settings.StateGap;
|
||||
private int StateGap => 1 << Settings.StateGap;
|
||||
|
||||
public TasStateManager(TasMovie movie)
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
Settings = new TasStateManagerSettings(Global.Config.DefaultTasProjSettings);
|
||||
|
||||
accessed = new List<StateManagerState>();
|
||||
_accessed = new List<StateManagerState>();
|
||||
|
||||
if (_movie.StartsFromSavestate)
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ namespace BizHawk.Client.Common
|
|||
public void Dispose()
|
||||
{
|
||||
// States and BranchStates don't need cleaning because they would only contain an ndbdatabase entry which was demolished by the below
|
||||
ndbdatabase?.Dispose();
|
||||
NdbDatabase?.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -109,17 +109,17 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (_expectedStateSize > 0)
|
||||
{
|
||||
limit = maxStates;
|
||||
limit = MaxStates;
|
||||
}
|
||||
|
||||
States = new SortedList<int, StateManagerState>(limit);
|
||||
_states = new SortedList<int, StateManagerState>(limit);
|
||||
|
||||
if (_expectedStateSize > int.MaxValue)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
ndbdatabase = new NDBDatabase(statePath, Settings.DiskCapacitymb * 1024 * 1024, (int)_expectedStateSize);
|
||||
NdbDatabase = new NDBDatabase(StatePath, Settings.DiskCapacitymb * 1024 * 1024, (int)_expectedStateSize);
|
||||
}
|
||||
|
||||
public TasStateManagerSettings Settings { get; set; }
|
||||
|
@ -138,17 +138,17 @@ namespace BizHawk.Client.Common
|
|||
return new KeyValuePair<int, byte[]>(0, InitialState);
|
||||
}
|
||||
|
||||
if (States.ContainsKey(frame))
|
||||
if (_states.ContainsKey(frame))
|
||||
{
|
||||
StateAccessed(frame);
|
||||
return new KeyValuePair<int, byte[]>(frame, States[frame].State);
|
||||
return new KeyValuePair<int, byte[]>(frame, _states[frame].State);
|
||||
}
|
||||
|
||||
return new KeyValuePair<int, byte[]>(-1, new byte[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly List<StateManagerState> accessed;
|
||||
private readonly List<StateManagerState> _accessed;
|
||||
|
||||
public byte[] InitialState
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ namespace BizHawk.Client.Common
|
|||
return _movie.BinarySavestate;
|
||||
}
|
||||
|
||||
return States[0].State;
|
||||
return _states[0].State;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public void Capture(bool force = false)
|
||||
{
|
||||
bool shouldCapture = false;
|
||||
bool shouldCapture;
|
||||
|
||||
int frame = Global.Emulator.Frame;
|
||||
if (_movie.StartsFromSavestate && frame == 0) // Never capture frame 0 on savestate anchored movies since we have it anyway
|
||||
|
@ -215,8 +215,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
lastMemState++;
|
||||
}
|
||||
while (States[accessed[lastMemState].Frame] == null);
|
||||
MoveStateToDisk(accessed[lastMemState].Frame);
|
||||
while (_states[_accessed[lastMemState].Frame] == null);
|
||||
MoveStateToDisk(_accessed[lastMemState].Frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,9 +228,9 @@ namespace BizHawk.Client.Common
|
|||
// X is frame, Y is branch
|
||||
Point shouldRemove = new Point(-1, -1);
|
||||
|
||||
if (BranchStates.Any() && Settings.EraseBranchStatesFirst)
|
||||
if (_branchStates.Any() && Settings.EraseBranchStatesFirst)
|
||||
{
|
||||
var kvp = BranchStates.Count > 1 ? BranchStates.ElementAt(1) : BranchStates.ElementAt(0);
|
||||
var kvp = _branchStates.Count > 1 ? _branchStates.ElementAt(1) : _branchStates.ElementAt(0);
|
||||
shouldRemove.X = kvp.Key;
|
||||
shouldRemove.Y = kvp.Value.Keys[0];
|
||||
|
||||
|
@ -238,14 +238,14 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
int i = 0;
|
||||
int markerSkips = maxStates / 2;
|
||||
int markerSkips = MaxStates / 2;
|
||||
|
||||
// lowPrioritySates (e.g. states with only lag frames between them)
|
||||
do
|
||||
{
|
||||
if (lowPriorityStates.Count > i)
|
||||
if (_lowPriorityStates.Count > i)
|
||||
{
|
||||
shouldRemove = findState(lowPriorityStates[i]);
|
||||
shouldRemove = FindState(_lowPriorityStates[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -261,18 +261,18 @@ namespace BizHawk.Client.Common
|
|||
|
||||
i++;
|
||||
}
|
||||
while (StateIsMarker(shouldRemove.X, shouldRemove.Y) && markerSkips > -1 || shouldRemove.X == 0);
|
||||
while ((StateIsMarker(shouldRemove.X, shouldRemove.Y) && markerSkips > -1) || shouldRemove.X == 0);
|
||||
|
||||
// by last accessed
|
||||
markerSkips = maxStates / 2;
|
||||
markerSkips = MaxStates / 2;
|
||||
if (shouldRemove.X < 1)
|
||||
{
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
if (accessed.Count > i)
|
||||
if (_accessed.Count > i)
|
||||
{
|
||||
shouldRemove = findState(accessed[i]);
|
||||
shouldRemove = FindState(_accessed[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -288,20 +288,20 @@ namespace BizHawk.Client.Common
|
|||
|
||||
i++;
|
||||
}
|
||||
while (StateIsMarker(shouldRemove.X, shouldRemove.Y) && markerSkips > -1 || shouldRemove.X == 0);
|
||||
while ((StateIsMarker(shouldRemove.X, shouldRemove.Y) && markerSkips > -1) || shouldRemove.X == 0);
|
||||
}
|
||||
|
||||
if (shouldRemove.X < 1) // only found marker states above
|
||||
{
|
||||
if (BranchStates.Any() && !Settings.EraseBranchStatesFirst)
|
||||
if (_branchStates.Any() && !Settings.EraseBranchStatesFirst)
|
||||
{
|
||||
var kvp = BranchStates.Count > 1 ? BranchStates.ElementAt(1) : BranchStates.ElementAt(0);
|
||||
var kvp = _branchStates.Count > 1 ? _branchStates.ElementAt(1) : _branchStates.ElementAt(0);
|
||||
shouldRemove.X = kvp.Key;
|
||||
shouldRemove.Y = kvp.Value.Keys[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
StateManagerState s = States.Values[1];
|
||||
StateManagerState s = _states.Values[1];
|
||||
shouldRemove.X = s.Frame;
|
||||
shouldRemove.Y = -1;
|
||||
}
|
||||
|
@ -319,12 +319,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (branch == -1)
|
||||
{
|
||||
return _movie.Markers.IsMarker(States[frame].Frame + 1);
|
||||
return _movie.Markers.IsMarker(_states[frame].Frame + 1);
|
||||
}
|
||||
|
||||
if (_movie.GetBranch(_movie.BranchIndexByHash(branch)).Markers == null)
|
||||
{
|
||||
return _movie.Markers.IsMarker(States[frame].Frame + 1);
|
||||
return _movie.Markers.IsMarker(_states[frame].Frame + 1);
|
||||
}
|
||||
|
||||
return _movie.GetBranch(branch).Markers.Any(m => m.Frame + 1 == frame);
|
||||
|
@ -354,14 +354,14 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private void MoveStateToDisk(int index)
|
||||
{
|
||||
Used -= (ulong)States[index].Length;
|
||||
States[index].MoveToDisk();
|
||||
Used -= (ulong)_states[index].Length;
|
||||
_states[index].MoveToDisk();
|
||||
}
|
||||
|
||||
private void MoveStateToMemory(int index)
|
||||
{
|
||||
States[index].MoveToRAM();
|
||||
Used += (ulong)States[index].Length;
|
||||
_states[index].MoveToRAM();
|
||||
Used += (ulong)_states[index].Length;
|
||||
}
|
||||
|
||||
internal void SetState(int frame, byte[] state, bool skipRemoval = true)
|
||||
|
@ -371,27 +371,27 @@ namespace BizHawk.Client.Common
|
|||
MaybeRemoveStates(); // Remove before adding so this state won't be removed.
|
||||
}
|
||||
|
||||
if (States.ContainsKey(frame))
|
||||
if (_states.ContainsKey(frame))
|
||||
{
|
||||
if (stateHasDuplicate(frame, -1) != -2)
|
||||
if (StateHasDuplicate(frame, -1) != -2)
|
||||
{
|
||||
Used += (ulong)state.Length;
|
||||
}
|
||||
|
||||
States[frame].State = state;
|
||||
_states[frame].State = state;
|
||||
}
|
||||
else
|
||||
{
|
||||
Used += (ulong)state.Length;
|
||||
States.Add(frame, new StateManagerState(this, state, frame));
|
||||
_states.Add(frame, new StateManagerState(this, state, frame));
|
||||
}
|
||||
|
||||
StateAccessed(frame);
|
||||
|
||||
int i = States.IndexOfKey(frame);
|
||||
if (i > 0 && AllLag(States.Keys[i - 1], States.Keys[i]))
|
||||
int i = _states.IndexOfKey(frame);
|
||||
if (i > 0 && AllLag(_states.Keys[i - 1], _states.Keys[i]))
|
||||
{
|
||||
lowPriorityStates.Add(States[frame]);
|
||||
_lowPriorityStates.Add(_states[frame]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,49 +399,49 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
if (branch == -1)
|
||||
{
|
||||
accessed.Remove(States[frame]);
|
||||
_accessed.Remove(_states[frame]);
|
||||
}
|
||||
else if (accessed.Contains(BranchStates[frame][branch]) && !Settings.EraseBranchStatesFirst)
|
||||
else if (_accessed.Contains(_branchStates[frame][branch]) && !Settings.EraseBranchStatesFirst)
|
||||
{
|
||||
accessed.Remove(BranchStates[frame][branch]);
|
||||
_accessed.Remove(_branchStates[frame][branch]);
|
||||
}
|
||||
|
||||
StateManagerState state;
|
||||
bool hasDuplicate = stateHasDuplicate(frame, branch) != -2;
|
||||
bool hasDuplicate = StateHasDuplicate(frame, branch) != -2;
|
||||
if (branch == -1)
|
||||
{
|
||||
state = States[frame];
|
||||
if (States[frame].IsOnDisk)
|
||||
state = _states[frame];
|
||||
if (_states[frame].IsOnDisk)
|
||||
{
|
||||
States[frame].Dispose();
|
||||
_states[frame].Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
Used -= (ulong)States[frame].Length;
|
||||
Used -= (ulong)_states[frame].Length;
|
||||
}
|
||||
|
||||
States.RemoveAt(States.IndexOfKey(frame));
|
||||
_states.RemoveAt(_states.IndexOfKey(frame));
|
||||
}
|
||||
else
|
||||
{
|
||||
state = BranchStates[frame][branch];
|
||||
state = _branchStates[frame][branch];
|
||||
|
||||
if (BranchStates[frame][branch].IsOnDisk)
|
||||
if (_branchStates[frame][branch].IsOnDisk)
|
||||
{
|
||||
BranchStates[frame][branch].Dispose();
|
||||
_branchStates[frame][branch].Dispose();
|
||||
}
|
||||
|
||||
BranchStates[frame].RemoveAt(BranchStates[frame].IndexOfKey(branch));
|
||||
_branchStates[frame].RemoveAt(_branchStates[frame].IndexOfKey(branch));
|
||||
|
||||
if (BranchStates[frame].Count == 0)
|
||||
if (_branchStates[frame].Count == 0)
|
||||
{
|
||||
BranchStates.Remove(frame);
|
||||
_branchStates.Remove(frame);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasDuplicate)
|
||||
{
|
||||
lowPriorityStates.Remove(state);
|
||||
_lowPriorityStates.Remove(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,23 +452,23 @@ namespace BizHawk.Client.Common
|
|||
return;
|
||||
}
|
||||
|
||||
StateManagerState state = States[frame];
|
||||
bool removed = accessed.Remove(state);
|
||||
accessed.Add(state);
|
||||
StateManagerState state = _states[frame];
|
||||
bool removed = _accessed.Remove(state);
|
||||
_accessed.Add(state);
|
||||
|
||||
if (States[frame].IsOnDisk)
|
||||
if (_states[frame].IsOnDisk)
|
||||
{
|
||||
if (!States[accessed[0].Frame].IsOnDisk)
|
||||
if (!_states[_accessed[0].Frame].IsOnDisk)
|
||||
{
|
||||
MoveStateToDisk(accessed[0].Frame);
|
||||
MoveStateToDisk(_accessed[0].Frame);
|
||||
}
|
||||
|
||||
MoveStateToMemory(frame);
|
||||
}
|
||||
|
||||
if (!removed && accessed.Count > maxStates)
|
||||
if (!removed && _accessed.Count > MaxStates)
|
||||
{
|
||||
accessed.RemoveAt(0);
|
||||
_accessed.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -479,7 +479,7 @@ namespace BizHawk.Client.Common
|
|||
return true;
|
||||
}
|
||||
|
||||
return States.ContainsKey(frame);
|
||||
return _states.ContainsKey(frame);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -497,7 +497,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
List<KeyValuePair<int, StateManagerState>> statesToRemove =
|
||||
States.Where(s => s.Key >= frame).ToList();
|
||||
_states.Where(s => s.Key >= frame).ToList();
|
||||
|
||||
anyInvalidated = statesToRemove.Any();
|
||||
|
||||
|
@ -517,21 +517,21 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
States.Clear();
|
||||
accessed.Clear();
|
||||
_states.Clear();
|
||||
_accessed.Clear();
|
||||
Used = 0;
|
||||
ClearDiskStates();
|
||||
}
|
||||
|
||||
public void ClearStateHistory()
|
||||
{
|
||||
if (States.Any())
|
||||
if (_states.Any())
|
||||
{
|
||||
StateManagerState power = States.Values.FirstOrDefault(s => s.Frame == 0);
|
||||
StateManagerState power = _states.Values.First(s => s.Frame == 0);
|
||||
StateAccessed(power.Frame);
|
||||
|
||||
States.Clear();
|
||||
accessed.Clear();
|
||||
_states.Clear();
|
||||
_accessed.Clear();
|
||||
|
||||
SetState(0, power.State);
|
||||
Used = (ulong)power.State.Length;
|
||||
|
@ -542,7 +542,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private void ClearDiskStates()
|
||||
{
|
||||
ndbdatabase?.Clear();
|
||||
NdbDatabase?.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -564,9 +564,9 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
index++;
|
||||
}
|
||||
while (!accessed[index].IsOnDisk);
|
||||
while (!_accessed[index].IsOnDisk);
|
||||
|
||||
accessed[index].MoveToRAM();
|
||||
_accessed[index].MoveToRAM();
|
||||
}
|
||||
|
||||
if (Used > Settings.Cap)
|
||||
|
@ -582,23 +582,23 @@ namespace BizHawk.Client.Common
|
|||
|
||||
// respect state gap no matter how small the resulting size will be
|
||||
// still leave marker states
|
||||
for (int i = 1; i < States.Count; i++)
|
||||
for (int i = 1; i < _states.Count; i++)
|
||||
{
|
||||
if (_movie.Markers.IsMarker(States.ElementAt(i).Key + 1)
|
||||
|| States.ElementAt(i).Key % _stateGap == 0)
|
||||
if (_movie.Markers.IsMarker(_states.ElementAt(i).Key + 1)
|
||||
|| _states.ElementAt(i).Key % StateGap == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.Add(i);
|
||||
|
||||
if (States.ElementAt(i).Value.IsOnDisk)
|
||||
if (_states.ElementAt(i).Value.IsOnDisk)
|
||||
{
|
||||
saveUsed -= _expectedStateSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveUsed -= (ulong)States.ElementAt(i).Value.Length;
|
||||
saveUsed -= (ulong)_states.ElementAt(i).Value.Length;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,27 +610,27 @@ namespace BizHawk.Client.Common
|
|||
do
|
||||
{
|
||||
index++;
|
||||
if (index >= States.Count)
|
||||
if (index >= _states.Count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (_movie.Markers.IsMarker(States.ElementAt(index).Key + 1));
|
||||
while (_movie.Markers.IsMarker(_states.ElementAt(index).Key + 1));
|
||||
|
||||
if (index >= States.Count)
|
||||
if (index >= _states.Count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret.Add(index);
|
||||
|
||||
if (States.ElementAt(index).Value.IsOnDisk)
|
||||
if (_states.ElementAt(index).Value.IsOnDisk)
|
||||
{
|
||||
saveUsed -= _expectedStateSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveUsed -= (ulong)States.ElementAt(index).Value.Length;
|
||||
saveUsed -= (ulong)_states.ElementAt(index).Value.Length;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -644,13 +644,13 @@ namespace BizHawk.Client.Common
|
|||
ret.Add(index);
|
||||
}
|
||||
|
||||
if (States.ElementAt(index).Value.IsOnDisk)
|
||||
if (_states.ElementAt(index).Value.IsOnDisk)
|
||||
{
|
||||
saveUsed -= _expectedStateSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveUsed -= (ulong)States.ElementAt(index).Value.Length;
|
||||
saveUsed -= (ulong)_states.ElementAt(index).Value.Length;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -661,16 +661,16 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
List<int> noSave = ExcludeStates();
|
||||
|
||||
bw.Write(States.Count - noSave.Count);
|
||||
for (int i = 0; i < States.Count; i++)
|
||||
bw.Write(_states.Count - noSave.Count);
|
||||
for (int i = 0; i < _states.Count; i++)
|
||||
{
|
||||
if (noSave.Contains(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
StateAccessed(States.ElementAt(i).Key);
|
||||
KeyValuePair<int, StateManagerState> kvp = States.ElementAt(i);
|
||||
StateAccessed(_states.ElementAt(i).Key);
|
||||
KeyValuePair<int, StateManagerState> kvp = _states.ElementAt(i);
|
||||
bw.Write(kvp.Key);
|
||||
bw.Write(kvp.Value.Length);
|
||||
bw.Write(kvp.Value.State);
|
||||
|
@ -680,7 +680,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void Load(BinaryReader br)
|
||||
{
|
||||
States.Clear();
|
||||
_states.Clear();
|
||||
try
|
||||
{
|
||||
int nstates = br.ReadInt32();
|
||||
|
@ -704,8 +704,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void SaveBranchStates(BinaryWriter bw)
|
||||
{
|
||||
bw.Write(BranchStates.Count);
|
||||
foreach (var s in BranchStates)
|
||||
bw.Write(_branchStates.Count);
|
||||
foreach (var s in _branchStates)
|
||||
{
|
||||
bw.Write(s.Key);
|
||||
bw.Write(s.Value.Count);
|
||||
|
@ -722,7 +722,7 @@ namespace BizHawk.Client.Common
|
|||
try
|
||||
{
|
||||
int c = br.ReadInt32();
|
||||
BranchStates = new SortedList<int, SortedList<int, StateManagerState>>(c);
|
||||
_branchStates = new SortedList<int, SortedList<int, StateManagerState>>(c);
|
||||
while (c > 0)
|
||||
{
|
||||
int key = br.ReadInt32();
|
||||
|
@ -736,7 +736,7 @@ namespace BizHawk.Client.Common
|
|||
c2--;
|
||||
}
|
||||
|
||||
BranchStates.Add(key, list);
|
||||
_branchStates.Add(key, list);
|
||||
c--;
|
||||
}
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public KeyValuePair<int, byte[]> GetStateClosestToFrame(int frame)
|
||||
{
|
||||
var s = States.LastOrDefault(state => state.Key < frame);
|
||||
var s = _states.LastOrDefault(state => state.Key < frame);
|
||||
|
||||
return this[s.Key];
|
||||
}
|
||||
|
@ -785,37 +785,37 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
if (ndbdatabase == null)
|
||||
if (NdbDatabase == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (ulong)ndbdatabase.Consumed;
|
||||
return (ulong)NdbDatabase.Consumed;
|
||||
}
|
||||
}
|
||||
|
||||
public int StateCount => States.Count;
|
||||
public int StateCount => _states.Count;
|
||||
|
||||
public bool Any()
|
||||
{
|
||||
if (_movie.StartsFromSavestate)
|
||||
{
|
||||
return States.Count > 0;
|
||||
return _states.Count > 0;
|
||||
}
|
||||
|
||||
return States.Count > 1;
|
||||
return _states.Count > 1;
|
||||
}
|
||||
|
||||
public int LastKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (States.Count == 0)
|
||||
if (_states.Count == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return States.Last().Key;
|
||||
return _states.Last().Key;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -834,45 +834,45 @@ namespace BizHawk.Client.Common
|
|||
|
||||
#region Branches
|
||||
|
||||
private SortedList<int, SortedList<int, StateManagerState>> BranchStates = new SortedList<int, SortedList<int, StateManagerState>>();
|
||||
private SortedList<int, SortedList<int, StateManagerState>> _branchStates = new SortedList<int, SortedList<int, StateManagerState>>();
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the state at frame in the given branch (-1 for current) has any duplicates.
|
||||
/// </summary>
|
||||
/// <returns>Index of the branch (-1 for current) of the first match. If no match, returns -2.</returns>
|
||||
private int stateHasDuplicate(int frame, int branchHash)
|
||||
private int StateHasDuplicate(int frame, int branchHash)
|
||||
{
|
||||
StateManagerState stateToMatch;
|
||||
|
||||
// Get the state instance
|
||||
if (branchHash == -1)
|
||||
{
|
||||
stateToMatch = States[frame];
|
||||
stateToMatch = _states[frame];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BranchStates[frame].ContainsKey(branchHash))
|
||||
if (!_branchStates[frame].ContainsKey(branchHash))
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
stateToMatch = BranchStates[frame][branchHash];
|
||||
stateToMatch = _branchStates[frame][branchHash];
|
||||
|
||||
// Check the current branch for duplicate.
|
||||
if (States.ContainsKey(frame) && States[frame] == stateToMatch)
|
||||
if (_states.ContainsKey(frame) && _states[frame] == stateToMatch)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there are any branch states for the given frame.
|
||||
if (!BranchStates.ContainsKey(frame) || BranchStates[frame] == null || branchHash == -1)
|
||||
if (!_branchStates.ContainsKey(frame) || _branchStates[frame] == null || branchHash == -1)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
|
||||
// Loop through branch states for the given frame.
|
||||
SortedList<int, StateManagerState> stateList = BranchStates[frame];
|
||||
SortedList<int, StateManagerState> stateList = _branchStates[frame];
|
||||
for (int i = 0; i < stateList.Count; i++)
|
||||
{
|
||||
// Don't check the branch containing the state to match.
|
||||
|
@ -890,16 +890,16 @@ namespace BizHawk.Client.Common
|
|||
return -2; // No match.
|
||||
}
|
||||
|
||||
private Point findState(StateManagerState s)
|
||||
private Point FindState(StateManagerState s)
|
||||
{
|
||||
Point ret = new Point(0, -1);
|
||||
ret.X = s.Frame;
|
||||
if (!States.ContainsValue(s))
|
||||
if (!_states.ContainsValue(s))
|
||||
{
|
||||
if (BranchStates.ContainsKey(s.Frame))
|
||||
if (_branchStates.ContainsKey(s.Frame))
|
||||
{
|
||||
int index = BranchStates[s.Frame].Values.IndexOf(s);
|
||||
ret.Y = BranchStates[s.Frame].Keys.ElementAt(index);
|
||||
int index = _branchStates[s.Frame].Values.IndexOf(s);
|
||||
ret.Y = _branchStates[s.Frame].Keys.ElementAt(index);
|
||||
}
|
||||
|
||||
if (ret.Y == -1)
|
||||
|
@ -915,19 +915,19 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
int branchHash = _movie.BranchHashByIndex(_movie.BranchCount - 1);
|
||||
|
||||
foreach (KeyValuePair<int, StateManagerState> kvp in States)
|
||||
foreach (KeyValuePair<int, StateManagerState> kvp in _states)
|
||||
{
|
||||
if (!BranchStates.ContainsKey(kvp.Key))
|
||||
if (!_branchStates.ContainsKey(kvp.Key))
|
||||
{
|
||||
BranchStates.Add(kvp.Key, new SortedList<int, StateManagerState>());
|
||||
_branchStates.Add(kvp.Key, new SortedList<int, StateManagerState>());
|
||||
}
|
||||
|
||||
SortedList<int, StateManagerState> stateList = BranchStates[kvp.Key];
|
||||
SortedList<int, StateManagerState> stateList = _branchStates[kvp.Key];
|
||||
|
||||
if (stateList == null) // when does this happen?
|
||||
{
|
||||
stateList = new SortedList<int, StateManagerState>();
|
||||
BranchStates[kvp.Key] = stateList;
|
||||
_branchStates[kvp.Key] = stateList;
|
||||
}
|
||||
|
||||
// We aren't creating any new states, just adding a reference to an already-existing one; so Used doesn't need to be updated.
|
||||
|
@ -939,7 +939,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
int branchHash = _movie.BranchHashByIndex(index);
|
||||
|
||||
foreach (KeyValuePair<int, SortedList<int, StateManagerState>> kvp in BranchStates.ToList())
|
||||
foreach (KeyValuePair<int, SortedList<int, StateManagerState>> kvp in _branchStates.ToList())
|
||||
{
|
||||
SortedList<int, StateManagerState> stateList = kvp.Value;
|
||||
if (stateList == null)
|
||||
|
@ -960,7 +960,7 @@ namespace BizHawk.Client.Common
|
|||
stateList.Remove(branchHash);
|
||||
if (stateList.Count == 0)
|
||||
{
|
||||
BranchStates.Remove(kvp.Key);
|
||||
_branchStates.Remove(kvp.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -975,7 +975,7 @@ namespace BizHawk.Client.Common
|
|||
int branchHash = _movie.BranchHashByIndex(index);
|
||||
|
||||
// RemoveBranch
|
||||
foreach (KeyValuePair<int, SortedList<int, StateManagerState>> kvp in BranchStates.ToList())
|
||||
foreach (KeyValuePair<int, SortedList<int, StateManagerState>> kvp in _branchStates.ToList())
|
||||
{
|
||||
SortedList<int, StateManagerState> stateList = kvp.Value;
|
||||
if (stateList == null)
|
||||
|
@ -996,24 +996,24 @@ namespace BizHawk.Client.Common
|
|||
stateList.Remove(branchHash);
|
||||
if (stateList.Count == 0)
|
||||
{
|
||||
BranchStates.Remove(kvp.Key);
|
||||
_branchStates.Remove(kvp.Key);
|
||||
}
|
||||
}
|
||||
|
||||
// AddBranch
|
||||
foreach (KeyValuePair<int, StateManagerState> kvp in States)
|
||||
foreach (KeyValuePair<int, StateManagerState> kvp in _states)
|
||||
{
|
||||
if (!BranchStates.ContainsKey(kvp.Key))
|
||||
if (!_branchStates.ContainsKey(kvp.Key))
|
||||
{
|
||||
BranchStates.Add(kvp.Key, new SortedList<int, StateManagerState>());
|
||||
_branchStates.Add(kvp.Key, new SortedList<int, StateManagerState>());
|
||||
}
|
||||
|
||||
SortedList<int, StateManagerState> stateList = BranchStates[kvp.Key];
|
||||
SortedList<int, StateManagerState> stateList = _branchStates[kvp.Key];
|
||||
|
||||
if (stateList == null)
|
||||
{
|
||||
stateList = new SortedList<int, StateManagerState>();
|
||||
BranchStates[kvp.Key] = stateList;
|
||||
_branchStates[kvp.Key] = stateList;
|
||||
}
|
||||
|
||||
stateList.Add(branchHash, kvp.Value);
|
||||
|
@ -1031,9 +1031,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
////Invalidate(0); // Not a good way of doing it?
|
||||
|
||||
foreach (KeyValuePair<int, SortedList<int, StateManagerState>> kvp in BranchStates)
|
||||
foreach (KeyValuePair<int, SortedList<int, StateManagerState>> kvp in _branchStates)
|
||||
{
|
||||
if (kvp.Key == 0 && States.ContainsKey(0))
|
||||
if (kvp.Key == 0 && _states.ContainsKey(0))
|
||||
{
|
||||
continue; // TODO: It might be a better idea to just not put state 0 in BranchStates.
|
||||
}
|
||||
|
|
|
@ -253,10 +253,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (thisByteMatches || i == stateLength - 1)
|
||||
{
|
||||
const int maxHeaderSize = 10;
|
||||
const int MaxHeaderSize = 10;
|
||||
int length = i - changeSequenceStartOffset + (thisByteMatches ? 0 : 1);
|
||||
|
||||
if (index + length + maxHeaderSize >= stateLength)
|
||||
if (index + length + MaxHeaderSize >= stateLength)
|
||||
{
|
||||
// If the delta ends up being larger than the full state, capture the full state instead
|
||||
goto CaptureFullState;
|
||||
|
|
|
@ -285,15 +285,15 @@ namespace BizHawk.Client.Common
|
|||
public long EndExclusive => Index + Length;
|
||||
}
|
||||
|
||||
private static byte[] test_BufferManage(byte[] inbuf, ref long size, bool allocate)
|
||||
private static byte[] Test_BufferManage(byte[] inbuf, ref long size, bool allocate)
|
||||
{
|
||||
if (allocate)
|
||||
{
|
||||
// if we have an appropriate buffer free, return it
|
||||
if (test_rewindFellationBuf != null && test_rewindFellationBuf.LongLength == size)
|
||||
if (testRewindFellationBuf != null && testRewindFellationBuf.LongLength == size)
|
||||
{
|
||||
var ret = test_rewindFellationBuf;
|
||||
test_rewindFellationBuf = null;
|
||||
var ret = testRewindFellationBuf;
|
||||
testRewindFellationBuf = null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -301,15 +301,15 @@ namespace BizHawk.Client.Common
|
|||
return new byte[size];
|
||||
}
|
||||
|
||||
test_rewindFellationBuf = inbuf;
|
||||
testRewindFellationBuf = inbuf;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static byte[] test_rewindFellationBuf;
|
||||
private static byte[] testRewindFellationBuf;
|
||||
|
||||
private static void test(string[] args)
|
||||
private static void Test(string[] args)
|
||||
{
|
||||
var sbb = new StreamBlobDatabase(false, 1024, test_BufferManage);
|
||||
var sbb = new StreamBlobDatabase(false, 1024, Test_BufferManage);
|
||||
Random r = new Random(0);
|
||||
byte[] temp = new byte[1024];
|
||||
int trials = 0;
|
||||
|
|
|
@ -13,6 +13,17 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public class CheatCollection : ICollection<Cheat>
|
||||
{
|
||||
private const string NameColumn = "NamesColumn";
|
||||
private const string AddressColumn = "AddressColumn";
|
||||
private const string ValueColumn = "ValueColumn";
|
||||
private const string CompareColumn = "CompareColumn";
|
||||
private const string OnColumn = "OnColumn";
|
||||
private const string DomainColumn = "DomainColumn";
|
||||
private const string SizeColumn = "SizeColumn";
|
||||
private const string EndianColumn = "EndianColumn";
|
||||
private const string TypeColumn = "DisplayTypeColumn";
|
||||
private const string ComparisonType = "ComparisonTypeColumn";
|
||||
|
||||
private List<Cheat> _cheatList = new List<Cheat>();
|
||||
private string _currentFileName = "";
|
||||
private string _defaultFileName = "";
|
||||
|
@ -512,7 +523,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
switch (column)
|
||||
{
|
||||
case NAME:
|
||||
case NameColumn:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -529,7 +540,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
case ADDRESS:
|
||||
case AddressColumn:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -546,7 +557,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
case VALUE:
|
||||
case ValueColumn:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -565,7 +576,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
case COMPARE:
|
||||
case CompareColumn:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -584,7 +595,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
case ON:
|
||||
case OnColumn:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -603,7 +614,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
case DOMAIN:
|
||||
case DomainColumn:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -622,7 +633,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
case SIZE:
|
||||
case SizeColumn:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -641,7 +652,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
case ENDIAN:
|
||||
case EndianColumn:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -660,7 +671,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
case TYPE:
|
||||
case TypeColumn:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -679,7 +690,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
break;
|
||||
case COMPARISONTYPE:
|
||||
case ComparisonType:
|
||||
if (reverse)
|
||||
{
|
||||
_cheatList = _cheatList
|
||||
|
@ -721,16 +732,5 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public Cheat Cheat { get; private set; }
|
||||
}
|
||||
|
||||
private const string NAME = "NamesColumn";
|
||||
private const string ADDRESS = "AddressColumn";
|
||||
private const string VALUE = "ValueColumn";
|
||||
private const string COMPARE = "CompareColumn";
|
||||
private const string ON = "OnColumn";
|
||||
private const string DOMAIN = "DomainColumn";
|
||||
private const string SIZE = "SizeColumn";
|
||||
private const string ENDIAN = "EndianColumn";
|
||||
private const string TYPE = "DisplayTypeColumn";
|
||||
private const string COMPARISONTYPE = "ComparisonTypeColumn";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
using (var LCK = Gdi.LockGraphics(e.Graphics))
|
||||
using (_gdi.LockGraphics(e.Graphics))
|
||||
{
|
||||
Gdi.StartOffScreenBitmap(Width, Height);
|
||||
_gdi.StartOffScreenBitmap(Width, Height);
|
||||
|
||||
// White Background
|
||||
Gdi.SetBrush(Color.White);
|
||||
Gdi.SetSolidPen(Color.White);
|
||||
Gdi.FillRectangle(0, 0, Width, Height);
|
||||
_gdi.SetBrush(Color.White);
|
||||
_gdi.SetSolidPen(Color.White);
|
||||
_gdi.FillRectangle(0, 0, Width, Height);
|
||||
|
||||
// Lag frame calculations
|
||||
SetLagFramesArray();
|
||||
|
@ -26,22 +26,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (visibleColumns.Any())
|
||||
{
|
||||
|
||||
DrawColumnBg(e, visibleColumns);
|
||||
DrawColumnText(e, visibleColumns);
|
||||
}
|
||||
|
||||
//Background
|
||||
// Background
|
||||
DrawBg(e, visibleColumns);
|
||||
|
||||
//Foreground
|
||||
// Foreground
|
||||
DrawData(e, visibleColumns);
|
||||
|
||||
DrawColumnDrag(e);
|
||||
DrawCellDrag(e);
|
||||
|
||||
Gdi.CopyToScreen();
|
||||
Gdi.EndOffScreenBitmap();
|
||||
_gdi.CopyToScreen();
|
||||
_gdi.EndOffScreenBitmap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,48 +51,42 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DrawColumnDrag(PaintEventArgs e)
|
||||
{
|
||||
if (_columnDown != null && _currentX.HasValue && _currentY.HasValue && IsHoveringOnColumnCell)
|
||||
if (_columnDown != null && _columnDownMoved && _currentX.HasValue && _currentY.HasValue && IsHoveringOnColumnCell)
|
||||
{
|
||||
int x1 = _currentX.Value - (_columnDown.Width.Value / 2);
|
||||
int y1 = _currentY.Value - (CellHeight / 2);
|
||||
int x2 = x1 + _columnDown.Width.Value;
|
||||
int y2 = y1 + CellHeight;
|
||||
|
||||
Gdi.SetSolidPen(_backColor);
|
||||
Gdi.DrawRectangle(x1, y1, x2, y2);
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
Gdi.DrawString(_columnDown.Text, new Point(x1 + CellWidthPadding, y1 + CellHeightPadding));
|
||||
_gdi.SetSolidPen(_backColor);
|
||||
_gdi.DrawRectangle(x1, y1, x2, y2);
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
_gdi.DrawString(_columnDown.Text, new Point(x1 + CellWidthPadding, y1 + CellHeightPadding));
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCellDrag(PaintEventArgs e)
|
||||
{
|
||||
if (DraggingCell != null)
|
||||
if (_draggingCell != null)
|
||||
{
|
||||
var text = "";
|
||||
int offsetX = 0;
|
||||
int offsetY = 0;
|
||||
if (QueryItemText != null)
|
||||
{
|
||||
QueryItemText(DraggingCell.RowIndex.Value, DraggingCell.Column, out text, ref offsetX, ref offsetY);
|
||||
}
|
||||
QueryItemText?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, out text, ref offsetX, ref offsetY);
|
||||
|
||||
Color bgColor = _backColor;
|
||||
if (QueryItemBkColor != null)
|
||||
{
|
||||
QueryItemBkColor(DraggingCell.RowIndex.Value, DraggingCell.Column, ref bgColor);
|
||||
}
|
||||
QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor);
|
||||
|
||||
int x1 = _currentX.Value - (DraggingCell.Column.Width.Value / 2);
|
||||
int x1 = _currentX.Value - (_draggingCell.Column.Width.Value / 2);
|
||||
int y1 = _currentY.Value - (CellHeight / 2);
|
||||
int x2 = x1 + DraggingCell.Column.Width.Value;
|
||||
int x2 = x1 + _draggingCell.Column.Width.Value;
|
||||
int y2 = y1 + CellHeight;
|
||||
|
||||
|
||||
Gdi.SetBrush(bgColor);
|
||||
Gdi.FillRectangle(x1, y1, x2 - x1, y2 - y1);
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
Gdi.DrawString(text, new Point(x1 + CellWidthPadding + offsetX, y1 + CellHeightPadding + offsetY));
|
||||
_gdi.SetBrush(bgColor);
|
||||
_gdi.FillRectangle(x1, y1, x2 - x1, y2 - y1);
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
_gdi.DrawString(text, new Point(x1 + CellWidthPadding + offsetX, y1 + CellHeightPadding + offsetY));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,9 +94,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (HorizontalOrientation)
|
||||
{
|
||||
int start = -VBar.Value;
|
||||
int start = -_vBar.Value;
|
||||
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
|
||||
foreach (var column in visibleColumns)
|
||||
{
|
||||
|
@ -111,13 +104,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (IsHoveringOnColumnCell && column == CurrentCell.Column)
|
||||
{
|
||||
Gdi.PrepDrawString(NormalFont, SystemColors.HighlightText);
|
||||
Gdi.DrawString(column.Text, point);
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
_gdi.PrepDrawString(_normalFont, SystemColors.HighlightText);
|
||||
_gdi.DrawString(column.Text, point);
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gdi.DrawString(column.Text, point);
|
||||
_gdi.DrawString(column.Text, point);
|
||||
}
|
||||
|
||||
start += CellHeight;
|
||||
|
@ -125,21 +118,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
|
||||
foreach (var column in visibleColumns)
|
||||
{
|
||||
var point = new Point(column.Left.Value + 2 * CellWidthPadding - HBar.Value, CellHeightPadding); // TODO: fix this CellPadding issue (2 * CellPadding vs just CellPadding)
|
||||
var point = new Point(column.Left.Value + 2 * CellWidthPadding - _hBar.Value, CellHeightPadding); // TODO: fix this CellPadding issue (2 * CellPadding vs just CellPadding)
|
||||
|
||||
if (IsHoveringOnColumnCell && column == CurrentCell.Column)
|
||||
{
|
||||
Gdi.PrepDrawString(NormalFont, SystemColors.HighlightText);
|
||||
Gdi.DrawString(column.Text, point);
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
_gdi.PrepDrawString(_normalFont, SystemColors.HighlightText);
|
||||
_gdi.DrawString(column.Text, point);
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gdi.DrawString(column.Text, point);
|
||||
_gdi.DrawString(column.Text, point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,10 +147,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
int startRow = FirstVisibleRow;
|
||||
int range = Math.Min(LastVisibleRow, RowCount - 1) - startRow + 1;
|
||||
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
for (int i = 0, f = 0; f < range; i++, f++)
|
||||
{
|
||||
f += lagFrames[i];
|
||||
f += _lagFrames[i];
|
||||
int LastVisible = LastVisibleColumnIndex;
|
||||
for (int j = FirstVisibleColumn; j <= LastVisible; j++)
|
||||
{
|
||||
|
@ -167,16 +160,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
int bitmapOffsetX = 0;
|
||||
int bitmapOffsetY = 0;
|
||||
|
||||
if (QueryItemIcon != null)
|
||||
{
|
||||
QueryItemIcon(f + startRow, visibleColumns[j], ref image, ref bitmapOffsetX, ref bitmapOffsetY);
|
||||
}
|
||||
QueryItemIcon?.Invoke(f + startRow, visibleColumns[j], ref image, ref bitmapOffsetX, ref bitmapOffsetY);
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
x = RowsToPixels(i) + CellWidthPadding + bitmapOffsetX;
|
||||
y = (j * CellHeight) + (CellHeightPadding * 2) + bitmapOffsetY;
|
||||
Gdi.DrawBitmap(image, new Point(x, y), true);
|
||||
_gdi.DrawBitmap(image, new Point(x, y), true);
|
||||
}
|
||||
|
||||
string text;
|
||||
|
@ -185,34 +175,32 @@ namespace BizHawk.Client.EmuHawk
|
|||
QueryItemText(f + startRow, visibleColumns[j], out text, ref strOffsetX, ref strOffsetY);
|
||||
|
||||
// Center Text
|
||||
x = RowsToPixels(i) + (CellWidth - text.Length * _charSize.Width) / 2;
|
||||
y = (j * CellHeight) + CellHeightPadding - VBar.Value;
|
||||
x = RowsToPixels(i) + ((CellWidth - (text.Length * _charSize.Width)) / 2);
|
||||
y = (j * CellHeight) + CellHeightPadding - _vBar.Value;
|
||||
var point = new Point(x + strOffsetX, y + strOffsetY);
|
||||
|
||||
var rePrep = false;
|
||||
if(j==1)
|
||||
if (SelectedItems.Contains(new Cell { Column = visibleColumns[j], RowIndex = i + startRow }))
|
||||
if (j == 1)
|
||||
if (_selectedItems.Contains(new Cell { Column = visibleColumns[j], RowIndex = i + startRow }))
|
||||
{
|
||||
Gdi.PrepDrawString(RotatedFont, SystemColors.HighlightText);
|
||||
_gdi.PrepDrawString(_rotatedFont, SystemColors.HighlightText);
|
||||
rePrep = true;
|
||||
}
|
||||
else if (j == 1)
|
||||
{
|
||||
//1. not sure about this; 2. repreps may be excess, but if we render one column at a time, we do need to change back after rendering the header
|
||||
// 1. not sure about this; 2. repreps may be excess, but if we render one column at a time, we do need to change back after rendering the header
|
||||
rePrep = true;
|
||||
Gdi.PrepDrawString(RotatedFont, _foreColor);
|
||||
_gdi.PrepDrawString(_rotatedFont, _foreColor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
Gdi.DrawString(text, point);
|
||||
_gdi.DrawString(text, point);
|
||||
}
|
||||
|
||||
if (rePrep)
|
||||
{
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,11 +210,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
int startRow = FirstVisibleRow;
|
||||
int range = Math.Min(LastVisibleRow, RowCount - 1) - startRow + 1;
|
||||
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
int xPadding = CellWidthPadding + 1 - HBar.Value;
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
int xPadding = CellWidthPadding + 1 - _hBar.Value;
|
||||
for (int i = 0, f = 0; f < range; i++, f++) // Vertical
|
||||
{
|
||||
f += lagFrames[i];
|
||||
f += _lagFrames[i];
|
||||
int LastVisible = LastVisibleColumnIndex;
|
||||
for (int j = FirstVisibleColumn; j <= LastVisible; j++) // Horizontal
|
||||
{
|
||||
|
@ -241,33 +229,30 @@ namespace BizHawk.Client.EmuHawk
|
|||
int bitmapOffsetX = 0;
|
||||
int bitmapOffsetY = 0;
|
||||
|
||||
if (QueryItemIcon != null)
|
||||
{
|
||||
QueryItemIcon(f + startRow, visibleColumns[j], ref image, ref bitmapOffsetX, ref bitmapOffsetY);
|
||||
}
|
||||
QueryItemIcon?.Invoke(f + startRow, visibleColumns[j], ref image, ref bitmapOffsetX, ref bitmapOffsetY);
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
Gdi.DrawBitmap(image, new Point(point.X + bitmapOffsetX, point.Y + bitmapOffsetY + CellHeightPadding), true);
|
||||
_gdi.DrawBitmap(image, new Point(point.X + bitmapOffsetX, point.Y + bitmapOffsetY + CellHeightPadding), true);
|
||||
}
|
||||
|
||||
QueryItemText(f + startRow, visibleColumns[j], out text, ref strOffsetX, ref strOffsetY);
|
||||
|
||||
bool rePrep = false;
|
||||
if (SelectedItems.Contains(new Cell { Column = visibleColumns[j], RowIndex = f + startRow }))
|
||||
if (_selectedItems.Contains(new Cell { Column = visibleColumns[j], RowIndex = f + startRow }))
|
||||
{
|
||||
Gdi.PrepDrawString(NormalFont, SystemColors.HighlightText);
|
||||
_gdi.PrepDrawString(_normalFont, SystemColors.HighlightText);
|
||||
rePrep = true;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
Gdi.DrawString(text, new Point(point.X + strOffsetX, point.Y + strOffsetY));
|
||||
_gdi.DrawString(text, new Point(point.X + strOffsetX, point.Y + strOffsetY));
|
||||
}
|
||||
|
||||
if (rePrep)
|
||||
{
|
||||
Gdi.PrepDrawString(NormalFont, _foreColor);
|
||||
_gdi.PrepDrawString(_normalFont, _foreColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,25 +262,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DrawColumnBg(PaintEventArgs e, List<RollColumn> visibleColumns)
|
||||
{
|
||||
Gdi.SetBrush(SystemColors.ControlLight);
|
||||
Gdi.SetSolidPen(Color.Black);
|
||||
_gdi.SetBrush(SystemColors.ControlLight);
|
||||
_gdi.SetSolidPen(Color.Black);
|
||||
|
||||
if (HorizontalOrientation)
|
||||
{
|
||||
Gdi.FillRectangle(0, 0, ColumnWidth + 1, DrawHeight + 1);
|
||||
Gdi.Line(0, 0, 0, visibleColumns.Count * CellHeight + 1);
|
||||
Gdi.Line(ColumnWidth, 0, ColumnWidth, visibleColumns.Count * CellHeight + 1);
|
||||
_gdi.FillRectangle(0, 0, ColumnWidth + 1, DrawHeight + 1);
|
||||
_gdi.Line(0, 0, 0, visibleColumns.Count * CellHeight + 1);
|
||||
_gdi.Line(ColumnWidth, 0, ColumnWidth, visibleColumns.Count * CellHeight + 1);
|
||||
|
||||
int start = -VBar.Value;
|
||||
int start = -_vBar.Value;
|
||||
foreach (var column in visibleColumns)
|
||||
{
|
||||
Gdi.Line(1, start, ColumnWidth, start);
|
||||
_gdi.Line(1, start, ColumnWidth, start);
|
||||
start += CellHeight;
|
||||
}
|
||||
|
||||
if (visibleColumns.Any())
|
||||
{
|
||||
Gdi.Line(1, start, ColumnWidth, start);
|
||||
_gdi.Line(1, start, ColumnWidth, start);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -303,36 +288,36 @@ namespace BizHawk.Client.EmuHawk
|
|||
int bottomEdge = RowsToPixels(0);
|
||||
|
||||
// Gray column box and black line underneath
|
||||
Gdi.FillRectangle(0, 0, Width + 1, bottomEdge + 1);
|
||||
Gdi.Line(0, 0, TotalColWidth.Value + 1, 0);
|
||||
Gdi.Line(0, bottomEdge, TotalColWidth.Value + 1, bottomEdge);
|
||||
_gdi.FillRectangle(0, 0, Width + 1, bottomEdge + 1);
|
||||
_gdi.Line(0, 0, TotalColWidth.Value + 1, 0);
|
||||
_gdi.Line(0, bottomEdge, TotalColWidth.Value + 1, bottomEdge);
|
||||
|
||||
// Vertical black seperators
|
||||
for (int i = 0; i < visibleColumns.Count; i++)
|
||||
{
|
||||
int pos = visibleColumns[i].Left.Value - HBar.Value;
|
||||
Gdi.Line(pos, 0, pos, bottomEdge);
|
||||
int pos = visibleColumns[i].Left.Value - _hBar.Value;
|
||||
_gdi.Line(pos, 0, pos, bottomEdge);
|
||||
}
|
||||
|
||||
// Draw right most line
|
||||
if (visibleColumns.Any())
|
||||
{
|
||||
int right = TotalColWidth.Value - HBar.Value;
|
||||
Gdi.Line(right, 0, right, bottomEdge);
|
||||
int right = TotalColWidth.Value - _hBar.Value;
|
||||
_gdi.Line(right, 0, right, bottomEdge);
|
||||
}
|
||||
}
|
||||
|
||||
// Emphasis
|
||||
foreach (var column in visibleColumns.Where(c => c.Emphasis))
|
||||
{
|
||||
Gdi.SetBrush(SystemColors.ActiveBorder);
|
||||
_gdi.SetBrush(SystemColors.ActiveBorder);
|
||||
if (HorizontalOrientation)
|
||||
{
|
||||
Gdi.FillRectangle(1, visibleColumns.IndexOf(column) * CellHeight + 1, ColumnWidth - 1, ColumnHeight - 1);
|
||||
_gdi.FillRectangle(1, visibleColumns.IndexOf(column) * CellHeight + 1, ColumnWidth - 1, ColumnHeight - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Gdi.FillRectangle(column.Left.Value + 1 - HBar.Value, 1, column.Width.Value - 1, ColumnHeight - 1);
|
||||
_gdi.FillRectangle(column.Left.Value + 1 - _hBar.Value, 1, column.Width.Value - 1, ColumnHeight - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,41 +335,42 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (CurrentCell.Column.Emphasis)
|
||||
{
|
||||
Gdi.SetBrush(Add(SystemColors.Highlight, 0x00222222));
|
||||
_gdi.SetBrush(Add(SystemColors.Highlight, 0x00222222));
|
||||
}
|
||||
else
|
||||
{
|
||||
Gdi.SetBrush(SystemColors.Highlight);
|
||||
_gdi.SetBrush(SystemColors.Highlight);
|
||||
}
|
||||
|
||||
Gdi.FillRectangle(1, i * CellHeight + 1, ColumnWidth - 1, ColumnHeight - 1);
|
||||
_gdi.FillRectangle(1, i * CellHeight + 1, ColumnWidth - 1, ColumnHeight - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO multiple selected columns
|
||||
// TODO multiple selected columns
|
||||
for (int i = 0; i < visibleColumns.Count; i++)
|
||||
{
|
||||
if (visibleColumns[i] == CurrentCell.Column)
|
||||
{
|
||||
//Left of column is to the right of the viewable area or right of column is to the left of the viewable area
|
||||
if (visibleColumns[i].Left.Value - HBar.Value > Width || visibleColumns[i].Right.Value - HBar.Value < 0)
|
||||
// Left of column is to the right of the viewable area or right of column is to the left of the viewable area
|
||||
if (visibleColumns[i].Left.Value - _hBar.Value > Width || visibleColumns[i].Right.Value - _hBar.Value < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int left = visibleColumns[i].Left.Value - HBar.Value;
|
||||
int width = visibleColumns[i].Right.Value - HBar.Value - left;
|
||||
|
||||
int left = visibleColumns[i].Left.Value - _hBar.Value;
|
||||
int width = visibleColumns[i].Right.Value - _hBar.Value - left;
|
||||
|
||||
if (CurrentCell.Column.Emphasis)
|
||||
{
|
||||
Gdi.SetBrush(Add(SystemColors.Highlight, 0x00550000));
|
||||
_gdi.SetBrush(Add(SystemColors.Highlight, 0x00550000));
|
||||
}
|
||||
else
|
||||
{
|
||||
Gdi.SetBrush(SystemColors.Highlight);
|
||||
_gdi.SetBrush(SystemColors.Highlight);
|
||||
}
|
||||
|
||||
Gdi.FillRectangle(left + 1, 1, width - 1, ColumnHeight - 1);
|
||||
_gdi.FillRectangle(left + 1, 1, width - 1, ColumnHeight - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -395,7 +381,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// <summary>
|
||||
/// Draw Gridlines and background colors using QueryItemBkColor.
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
private void DrawBg(PaintEventArgs e, List<RollColumn> visibleColumns)
|
||||
{
|
||||
if (UseCustomBackground && QueryItemBkColor != null)
|
||||
|
@ -405,20 +390,20 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (GridLines)
|
||||
{
|
||||
Gdi.SetSolidPen(SystemColors.ControlLight);
|
||||
_gdi.SetSolidPen(SystemColors.ControlLight);
|
||||
if (HorizontalOrientation)
|
||||
{
|
||||
// Columns
|
||||
for (int i = 1; i < VisibleRows + 1; i++)
|
||||
{
|
||||
int x = RowsToPixels(i);
|
||||
Gdi.Line(x, 1, x, DrawHeight);
|
||||
_gdi.Line(x, 1, x, DrawHeight);
|
||||
}
|
||||
|
||||
// Rows
|
||||
for (int i = 0; i < visibleColumns.Count + 1; i++)
|
||||
{
|
||||
Gdi.Line(RowsToPixels(0) + 1, i * CellHeight - VBar.Value, DrawWidth, i * CellHeight - VBar.Value);
|
||||
_gdi.Line(RowsToPixels(0) + 1, i * CellHeight - _vBar.Value, DrawWidth, i * CellHeight - _vBar.Value);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -428,24 +413,24 @@ namespace BizHawk.Client.EmuHawk
|
|||
int? totalColWidth = TotalColWidth;
|
||||
foreach (var column in visibleColumns)
|
||||
{
|
||||
int x = column.Left.Value - HBar.Value;
|
||||
Gdi.Line(x, y, x, Height - 1);
|
||||
int x = column.Left.Value - _hBar.Value;
|
||||
_gdi.Line(x, y, x, Height - 1);
|
||||
}
|
||||
|
||||
if (visibleColumns.Any())
|
||||
{
|
||||
Gdi.Line(totalColWidth.Value - HBar.Value, y, totalColWidth.Value - HBar.Value, Height - 1);
|
||||
_gdi.Line(totalColWidth.Value - _hBar.Value, y, totalColWidth.Value - _hBar.Value, Height - 1);
|
||||
}
|
||||
|
||||
// Rows
|
||||
for (int i = 1; i < VisibleRows + 1; i++)
|
||||
{
|
||||
Gdi.Line(0, RowsToPixels(i), Width + 1, RowsToPixels(i));
|
||||
_gdi.Line(0, RowsToPixels(i), Width + 1, RowsToPixels(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectedItems.Any())
|
||||
if (_selectedItems.Any())
|
||||
{
|
||||
DoSelectionBG(e, visibleColumns);
|
||||
}
|
||||
|
@ -457,11 +442,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
Color rowColor = Color.White;
|
||||
int _lastVisibleRow = LastVisibleRow;
|
||||
int lastRow = -1;
|
||||
foreach (Cell cell in SelectedItems)
|
||||
foreach (Cell cell in _selectedItems)
|
||||
{
|
||||
if (cell.RowIndex > _lastVisibleRow || cell.RowIndex < FirstVisibleRow ||
|
||||
!VisibleColumns.Contains(cell.Column))
|
||||
if (cell.RowIndex > _lastVisibleRow || cell.RowIndex < FirstVisibleRow || !VisibleColumns.Contains(cell.Column))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Cell relativeCell = new Cell
|
||||
{
|
||||
|
@ -478,6 +464,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
Color cellColor = rowColor;
|
||||
QueryItemBkColor(cell.RowIndex.Value, cell.Column, ref cellColor);
|
||||
|
||||
// Alpha layering for cell before selection
|
||||
float alpha = (float)cellColor.A / 255;
|
||||
if (cellColor.A != 255 && cellColor.A != 0)
|
||||
|
@ -486,6 +473,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
rowColor.G - (int)((rowColor.G - cellColor.G) * alpha),
|
||||
rowColor.B - (int)((rowColor.B - cellColor.B) * alpha));
|
||||
}
|
||||
|
||||
// Alpha layering for selection
|
||||
alpha = 0.33f;
|
||||
cellColor = Color.FromArgb(cellColor.R - (int)((cellColor.R - SystemColors.Highlight.R) * alpha),
|
||||
|
@ -506,14 +494,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
x = RowsToPixels(cell.RowIndex.Value) + 1;
|
||||
w = CellWidth - 1;
|
||||
y = (CellHeight * visibleColumns.IndexOf(cell.Column)) + 1 - VBar.Value; // We can't draw without row and column, so assume they exist and fail catastrophically if they don't
|
||||
y = (CellHeight * visibleColumns.IndexOf(cell.Column)) + 1 - _vBar.Value; // We can't draw without row and column, so assume they exist and fail catastrophically if they don't
|
||||
h = CellHeight - 1;
|
||||
if (x < ColumnWidth) { return; }
|
||||
if (x < ColumnWidth)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
w = cell.Column.Width.Value - 1;
|
||||
x = cell.Column.Left.Value - HBar.Value + 1;
|
||||
x = cell.Column.Left.Value - _hBar.Value + 1;
|
||||
y = RowsToPixels(cell.RowIndex.Value) + 1; // We can't draw without row and column, so assume they exist and fail catastrophically if they don't
|
||||
h = CellHeight - 1;
|
||||
if (y < ColumnHeight)
|
||||
|
@ -527,8 +518,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
} // Don't draw if off screen.
|
||||
|
||||
Gdi.SetBrush(color);
|
||||
Gdi.FillRectangle(x, y, w, h);
|
||||
_gdi.SetBrush(color);
|
||||
_gdi.FillRectangle(x, y, w, h);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -545,13 +536,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
for (int i = 0, f = 0; f < range; i++, f++)
|
||||
{
|
||||
f += lagFrames[i];
|
||||
f += _lagFrames[i];
|
||||
|
||||
Color rowColor = Color.White;
|
||||
if (QueryRowBkColor != null)
|
||||
{
|
||||
QueryRowBkColor(f + startIndex, ref rowColor);
|
||||
}
|
||||
QueryRowBkColor?.Invoke(f + startIndex, ref rowColor);
|
||||
|
||||
for (int j = firstVisibleColumn; j <= lastVisible; j++)
|
||||
{
|
||||
|
@ -561,7 +549,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
itemColor = rowColor;
|
||||
}
|
||||
|
||||
else if (itemColor.A != 255 && itemColor.A != 0)
|
||||
{
|
||||
float alpha = (float)itemColor.A / 255;
|
||||
|
@ -586,13 +573,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
for (int i = 0, f = 0; f < range; i++, f++) // Vertical
|
||||
{
|
||||
f += lagFrames[i];
|
||||
f += _lagFrames[i];
|
||||
|
||||
Color rowColor = Color.White;
|
||||
if (QueryRowBkColor != null)
|
||||
{
|
||||
QueryRowBkColor(f + startIndex, ref rowColor);
|
||||
}
|
||||
QueryRowBkColor?.Invoke(f + startIndex, ref rowColor);
|
||||
|
||||
for (int j = FirstVisibleColumn; j <= lastVisible; j++) // Horizontal
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -44,10 +44,6 @@ namespace BizHawk.Client.EmuHawk.CoreExtensions
|
|||
{
|
||||
return Properties.Resources.emu7800;
|
||||
}
|
||||
else if (core is GBA)
|
||||
{
|
||||
return Properties.Resources.meteor;
|
||||
}
|
||||
else if (core is GPGX)
|
||||
{
|
||||
return Properties.Resources.genplus;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using BizHawk.Client.Common;
|
||||
using BizHawk.Bizware.BizwareGL;
|
||||
using BizHawk.Bizware.BizwareGL;
|
||||
|
||||
// ReSharper disable StyleCop.SA1401
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public static class GlobalWin
|
||||
|
@ -13,15 +13,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// </summary>
|
||||
public static IGL GL;
|
||||
|
||||
public static GLManager.ContextRef CR_GL;
|
||||
|
||||
/// <summary>
|
||||
/// The IGL_TK to be used for specifically opengl operations (accessing textures from opengl-based cores)
|
||||
/// </summary>
|
||||
public static Bizware.BizwareGL.Drivers.OpenTK.IGL_TK IGL_GL;
|
||||
|
||||
public static Sound Sound;
|
||||
public static OSDManager OSD = new OSDManager();
|
||||
public static readonly OSDManager OSD = new OSDManager();
|
||||
public static DisplayManager DisplayManager;
|
||||
public static GLManager GLManager;
|
||||
|
||||
|
|
|
@ -191,6 +191,7 @@
|
|||
this.CorebsnesAccuracyMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Coresnes9xMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.gBAWithMGBAToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.Atari7800WithEmu7800MenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem16 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.allowGameDBCoreOverridesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator();
|
||||
|
@ -1228,7 +1229,7 @@
|
|||
this.EmulationSubMenu.Name = "EmulationSubMenu";
|
||||
this.EmulationSubMenu.Size = new System.Drawing.Size(65, 17);
|
||||
this.EmulationSubMenu.Text = "&Emulation";
|
||||
this.EmulationSubMenu.DropDownOpened += new System.EventHandler(this.emulationToolStripMenuItem_DropDownOpened);
|
||||
this.EmulationSubMenu.DropDownOpened += new System.EventHandler(this.EmulationMenuItem_DropDownOpened);
|
||||
//
|
||||
// PauseMenuItem
|
||||
//
|
||||
|
@ -1360,7 +1361,7 @@
|
|||
this.DisplayFPSMenuItem.Name = "DisplayFPSMenuItem";
|
||||
this.DisplayFPSMenuItem.Size = new System.Drawing.Size(187, 22);
|
||||
this.DisplayFPSMenuItem.Text = "Display FPS";
|
||||
this.DisplayFPSMenuItem.Click += new System.EventHandler(this.DisplayFPSMenuItem_Click);
|
||||
this.DisplayFPSMenuItem.Click += new System.EventHandler(this.DisplayFpsMenuItem_Click);
|
||||
//
|
||||
// DisplayFrameCounterMenuItem
|
||||
//
|
||||
|
@ -1619,7 +1620,7 @@
|
|||
this.miUnthrottled.Name = "miUnthrottled";
|
||||
this.miUnthrottled.Size = new System.Drawing.Size(181, 22);
|
||||
this.miUnthrottled.Text = "Unthrottled";
|
||||
this.miUnthrottled.Click += new System.EventHandler(this.miUnthrottled_Click);
|
||||
this.miUnthrottled.Click += new System.EventHandler(this.UnthrottledMenuItem_Click);
|
||||
//
|
||||
// MinimizeSkippingMenuItem
|
||||
//
|
||||
|
@ -1800,6 +1801,7 @@
|
|||
this.NesInQuickNESMenuItem,
|
||||
this.CoreSNESSubMenu,
|
||||
this.gBAWithMGBAToolStripMenuItem,
|
||||
this.Atari7800WithEmu7800MenuItem,
|
||||
this.toolStripMenuItem16,
|
||||
this.allowGameDBCoreOverridesToolStripMenuItem,
|
||||
this.toolStripSeparator8,
|
||||
|
@ -1815,7 +1817,7 @@
|
|||
this.GBInSGBMenuItem.Name = "GBInSGBMenuItem";
|
||||
this.GBInSGBMenuItem.Size = new System.Drawing.Size(223, 22);
|
||||
this.GBInSGBMenuItem.Text = "GB in SGB";
|
||||
this.GBInSGBMenuItem.Click += new System.EventHandler(this.GBInSGBMenuItem_Click);
|
||||
this.GBInSGBMenuItem.Click += new System.EventHandler(this.GbInSgbMenuItem_Click);
|
||||
//
|
||||
// NesInQuickNESMenuItem
|
||||
//
|
||||
|
@ -1862,14 +1864,21 @@
|
|||
this.Coresnes9xMenuItem.Name = "Coresnes9xMenuItem";
|
||||
this.Coresnes9xMenuItem.Size = new System.Drawing.Size(166, 22);
|
||||
this.Coresnes9xMenuItem.Text = "Snes9x";
|
||||
this.Coresnes9xMenuItem.Click += new System.EventHandler(this.Coresnes9xMenuItem_Click);
|
||||
this.Coresnes9xMenuItem.Click += new System.EventHandler(this.CoreSnes9xMenuItem_Click);
|
||||
//
|
||||
// gBAWithMGBAToolStripMenuItem
|
||||
//
|
||||
this.gBAWithMGBAToolStripMenuItem.Name = "gBAWithMGBAToolStripMenuItem";
|
||||
this.gBAWithMGBAToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
|
||||
this.gBAWithMGBAToolStripMenuItem.Text = "GBA with mGBA";
|
||||
this.gBAWithMGBAToolStripMenuItem.Click += new System.EventHandler(this.gBAWithMGBAToolStripMenuItem_Click);
|
||||
this.gBAWithMGBAToolStripMenuItem.Click += new System.EventHandler(this.GbaWithmGBAMenuItem_Click);
|
||||
//
|
||||
// Atari7800WithEmu7800MenuItem
|
||||
//
|
||||
this.Atari7800WithEmu7800MenuItem.Name = "Atari7800WithEmu7800MenuItem";
|
||||
this.Atari7800WithEmu7800MenuItem.Size = new System.Drawing.Size(223, 22);
|
||||
this.Atari7800WithEmu7800MenuItem.Text = "Atari 7800 with Emu7800";
|
||||
this.Atari7800WithEmu7800MenuItem.Click += new System.EventHandler(this.Atari7800WithEmu7800MenuItem_Click);
|
||||
//
|
||||
// toolStripMenuItem16
|
||||
//
|
||||
|
@ -1881,7 +1890,7 @@
|
|||
this.allowGameDBCoreOverridesToolStripMenuItem.Name = "allowGameDBCoreOverridesToolStripMenuItem";
|
||||
this.allowGameDBCoreOverridesToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
|
||||
this.allowGameDBCoreOverridesToolStripMenuItem.Text = "Follow GameDB Core Overrides";
|
||||
this.allowGameDBCoreOverridesToolStripMenuItem.Click += new System.EventHandler(this.allowGameDBCoreOverridesToolStripMenuItem_Click);
|
||||
this.allowGameDBCoreOverridesToolStripMenuItem.Click += new System.EventHandler(this.AllowGameDBCoreOverridesToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator8
|
||||
//
|
||||
|
@ -1901,7 +1910,7 @@
|
|||
this.setLibretroCoreToolStripMenuItem.Name = "setLibretroCoreToolStripMenuItem";
|
||||
this.setLibretroCoreToolStripMenuItem.Size = new System.Drawing.Size(223, 22);
|
||||
this.setLibretroCoreToolStripMenuItem.Text = "Set Libretro Core";
|
||||
this.setLibretroCoreToolStripMenuItem.Click += new System.EventHandler(this.setLibretroCoreToolStripMenuItem_Click);
|
||||
this.setLibretroCoreToolStripMenuItem.Click += new System.EventHandler(this.SetLibretroCoreMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator10
|
||||
//
|
||||
|
@ -2085,7 +2094,7 @@
|
|||
this.gameSharkConverterToolStripMenuItem.Name = "gameSharkConverterToolStripMenuItem";
|
||||
this.gameSharkConverterToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
|
||||
this.gameSharkConverterToolStripMenuItem.Text = "Cheat Code Converter";
|
||||
this.gameSharkConverterToolStripMenuItem.Click += new System.EventHandler(this.gameSharkConverterToolStripMenuItem_Click);
|
||||
this.gameSharkConverterToolStripMenuItem.Click += new System.EventHandler(this.CheatCodeConverterMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator29
|
||||
//
|
||||
|
@ -2098,7 +2107,7 @@
|
|||
this.MultiDiskBundlerFileMenuItem.Name = "MultiDiskBundlerFileMenuItem";
|
||||
this.MultiDiskBundlerFileMenuItem.Size = new System.Drawing.Size(183, 22);
|
||||
this.MultiDiskBundlerFileMenuItem.Text = "Multi-disk Bundler";
|
||||
this.MultiDiskBundlerFileMenuItem.Click += new System.EventHandler(this.CreateMultigameFileMenuItem_Click);
|
||||
this.MultiDiskBundlerFileMenuItem.Click += new System.EventHandler(this.MultidiskBundlerMenuItem_Click);
|
||||
//
|
||||
// externalToolToolStripMenuItem
|
||||
//
|
||||
|
@ -2121,7 +2130,7 @@
|
|||
this.batchRunnerToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
|
||||
this.batchRunnerToolStripMenuItem.Text = "Batch Runner";
|
||||
this.batchRunnerToolStripMenuItem.Visible = false;
|
||||
this.batchRunnerToolStripMenuItem.Click += new System.EventHandler(this.batchRunnerToolStripMenuItem_Click);
|
||||
this.batchRunnerToolStripMenuItem.Click += new System.EventHandler(this.BatchRunnerToolStripMenuItem_Click);
|
||||
//
|
||||
// ExperimentalToolsSubMenu
|
||||
//
|
||||
|
@ -2138,6 +2147,7 @@
|
|||
this.AutoHawkMenuItem.Name = "AutoHawkMenuItem";
|
||||
this.AutoHawkMenuItem.Size = new System.Drawing.Size(148, 22);
|
||||
this.AutoHawkMenuItem.Text = "AutoHawk";
|
||||
this.AutoHawkMenuItem.Click += new System.EventHandler(this.AutoHawkMenuItem_Click);
|
||||
//
|
||||
// NewHexEditorMenuItem
|
||||
//
|
||||
|
@ -2178,21 +2188,21 @@
|
|||
this.coreToolStripMenuItem.Name = "coreToolStripMenuItem";
|
||||
this.coreToolStripMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.coreToolStripMenuItem.Text = "&Core";
|
||||
this.coreToolStripMenuItem.DropDownOpened += new System.EventHandler(this.coreToolStripMenuItem_DropDownOpened);
|
||||
this.coreToolStripMenuItem.DropDownOpened += new System.EventHandler(this.CoreToolStripMenuItem_DropDownOpened);
|
||||
//
|
||||
// quickNESToolStripMenuItem
|
||||
//
|
||||
this.quickNESToolStripMenuItem.Name = "quickNESToolStripMenuItem";
|
||||
this.quickNESToolStripMenuItem.Size = new System.Drawing.Size(118, 22);
|
||||
this.quickNESToolStripMenuItem.Text = "&QuickNes";
|
||||
this.quickNESToolStripMenuItem.Click += new System.EventHandler(this.quickNESToolStripMenuItem_Click);
|
||||
this.quickNESToolStripMenuItem.Click += new System.EventHandler(this.QuickNesToolStripMenuItem_Click);
|
||||
//
|
||||
// nesHawkToolStripMenuItem
|
||||
//
|
||||
this.nesHawkToolStripMenuItem.Name = "nesHawkToolStripMenuItem";
|
||||
this.nesHawkToolStripMenuItem.Size = new System.Drawing.Size(118, 22);
|
||||
this.nesHawkToolStripMenuItem.Text = "&NesHawk";
|
||||
this.nesHawkToolStripMenuItem.Click += new System.EventHandler(this.nesHawkToolStripMenuItem_Click);
|
||||
this.nesHawkToolStripMenuItem.Click += new System.EventHandler(this.NesHawkToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator34
|
||||
//
|
||||
|
@ -2204,7 +2214,7 @@
|
|||
this.NESPPUViewerMenuItem.Name = "NESPPUViewerMenuItem";
|
||||
this.NESPPUViewerMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.NESPPUViewerMenuItem.Text = "&PPU Viewer";
|
||||
this.NESPPUViewerMenuItem.Click += new System.EventHandler(this.NESPPUViewerMenuItem_Click);
|
||||
this.NESPPUViewerMenuItem.Click += new System.EventHandler(this.NesPPUViewerMenuItem_Click);
|
||||
//
|
||||
// NESNametableViewerMenuItem
|
||||
//
|
||||
|
@ -2225,7 +2235,7 @@
|
|||
this.musicRipperToolStripMenuItem.Name = "musicRipperToolStripMenuItem";
|
||||
this.musicRipperToolStripMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.musicRipperToolStripMenuItem.Text = "Music Ripper";
|
||||
this.musicRipperToolStripMenuItem.Click += new System.EventHandler(this.musicRipperToolStripMenuItem_Click);
|
||||
this.musicRipperToolStripMenuItem.Click += new System.EventHandler(this.MusicRipperMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator17
|
||||
//
|
||||
|
@ -2261,7 +2271,7 @@
|
|||
this.VSSettingsMenuItem.Name = "VSSettingsMenuItem";
|
||||
this.VSSettingsMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.VSSettingsMenuItem.Text = "VS Settings...";
|
||||
this.VSSettingsMenuItem.Click += new System.EventHandler(this.VSSettingsMenuItem_Click);
|
||||
this.VSSettingsMenuItem.Click += new System.EventHandler(this.VsSettingsMenuItem_Click);
|
||||
//
|
||||
// MovieSettingsMenuItem
|
||||
//
|
||||
|
@ -2306,28 +2316,28 @@
|
|||
this.VSInsertCoinP1MenuItem.Name = "VSInsertCoinP1MenuItem";
|
||||
this.VSInsertCoinP1MenuItem.Size = new System.Drawing.Size(143, 22);
|
||||
this.VSInsertCoinP1MenuItem.Text = "Insert Coin P1";
|
||||
this.VSInsertCoinP1MenuItem.Click += new System.EventHandler(this.VSInsertCoinP1MenuItem_Click);
|
||||
this.VSInsertCoinP1MenuItem.Click += new System.EventHandler(this.VsInsertCoinP1MenuItem_Click);
|
||||
//
|
||||
// VSInsertCoinP2MenuItem
|
||||
//
|
||||
this.VSInsertCoinP2MenuItem.Name = "VSInsertCoinP2MenuItem";
|
||||
this.VSInsertCoinP2MenuItem.Size = new System.Drawing.Size(143, 22);
|
||||
this.VSInsertCoinP2MenuItem.Text = "Insert Coin P2";
|
||||
this.VSInsertCoinP2MenuItem.Click += new System.EventHandler(this.VSInsertCoinP2MenuItem_Click);
|
||||
this.VSInsertCoinP2MenuItem.Click += new System.EventHandler(this.VsInsertCoinP2MenuItem_Click);
|
||||
//
|
||||
// VSServiceSwitchMenuItem
|
||||
//
|
||||
this.VSServiceSwitchMenuItem.Name = "VSServiceSwitchMenuItem";
|
||||
this.VSServiceSwitchMenuItem.Size = new System.Drawing.Size(143, 22);
|
||||
this.VSServiceSwitchMenuItem.Text = "Service Switch";
|
||||
this.VSServiceSwitchMenuItem.Click += new System.EventHandler(this.VSServiceSwitchMenuItem_Click);
|
||||
this.VSServiceSwitchMenuItem.Click += new System.EventHandler(this.VsServiceSwitchMenuItem_Click);
|
||||
//
|
||||
// barcodeReaderToolStripMenuItem
|
||||
//
|
||||
this.barcodeReaderToolStripMenuItem.Name = "barcodeReaderToolStripMenuItem";
|
||||
this.barcodeReaderToolStripMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.barcodeReaderToolStripMenuItem.Text = "Barcode Reader";
|
||||
this.barcodeReaderToolStripMenuItem.Click += new System.EventHandler(this.barcodeReaderToolStripMenuItem_Click);
|
||||
this.barcodeReaderToolStripMenuItem.Click += new System.EventHandler(this.BarcodeReaderMenuItem_Click);
|
||||
//
|
||||
// PCESubMenu
|
||||
//
|
||||
|
@ -2361,7 +2371,7 @@
|
|||
this.PCEGraphicsSettingsMenuItem.Name = "PCEGraphicsSettingsMenuItem";
|
||||
this.PCEGraphicsSettingsMenuItem.Size = new System.Drawing.Size(240, 22);
|
||||
this.PCEGraphicsSettingsMenuItem.Text = "Graphics Settings";
|
||||
this.PCEGraphicsSettingsMenuItem.Click += new System.EventHandler(this.PCEGraphicsSettingsMenuItem_Click);
|
||||
this.PCEGraphicsSettingsMenuItem.Click += new System.EventHandler(this.PceGraphicsSettingsMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator32
|
||||
//
|
||||
|
@ -2373,7 +2383,7 @@
|
|||
this.PCEBGViewerMenuItem.Name = "PCEBGViewerMenuItem";
|
||||
this.PCEBGViewerMenuItem.Size = new System.Drawing.Size(240, 22);
|
||||
this.PCEBGViewerMenuItem.Text = "&BG Viewer";
|
||||
this.PCEBGViewerMenuItem.Click += new System.EventHandler(this.PCEBGViewerMenuItem_Click);
|
||||
this.PCEBGViewerMenuItem.Click += new System.EventHandler(this.PceBgViewerMenuItem_Click);
|
||||
//
|
||||
// PCEtileViewerToolStripMenuItem
|
||||
//
|
||||
|
@ -2387,7 +2397,7 @@
|
|||
this.PceSoundDebuggerToolStripMenuItem.Name = "PceSoundDebuggerToolStripMenuItem";
|
||||
this.PceSoundDebuggerToolStripMenuItem.Size = new System.Drawing.Size(240, 22);
|
||||
this.PceSoundDebuggerToolStripMenuItem.Text = "&Sound Debugger";
|
||||
this.PceSoundDebuggerToolStripMenuItem.Click += new System.EventHandler(this.PceSoundDebuggerToolStripMenuItem_Click);
|
||||
this.PceSoundDebuggerToolStripMenuItem.Click += new System.EventHandler(this.PceSoundDebuggerMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator25
|
||||
//
|
||||
|
@ -2511,14 +2521,14 @@
|
|||
this.SMSenableBIOSToolStripMenuItem.Name = "SMSenableBIOSToolStripMenuItem";
|
||||
this.SMSenableBIOSToolStripMenuItem.Size = new System.Drawing.Size(221, 22);
|
||||
this.SMSenableBIOSToolStripMenuItem.Text = "Enable BIOS";
|
||||
this.SMSenableBIOSToolStripMenuItem.Click += new System.EventHandler(this.SMS_BIOS_Click);
|
||||
this.SMSenableBIOSToolStripMenuItem.Click += new System.EventHandler(this.SmsBiosMenuItem_Click);
|
||||
//
|
||||
// SMSEnableFMChipMenuItem
|
||||
//
|
||||
this.SMSEnableFMChipMenuItem.Name = "SMSEnableFMChipMenuItem";
|
||||
this.SMSEnableFMChipMenuItem.Size = new System.Drawing.Size(221, 22);
|
||||
this.SMSEnableFMChipMenuItem.Text = "&Enable FM Chip";
|
||||
this.SMSEnableFMChipMenuItem.Click += new System.EventHandler(this.SMSEnableFMChipMenuItem_Click);
|
||||
this.SMSEnableFMChipMenuItem.Click += new System.EventHandler(this.SmsEnableFmChipMenuItem_Click);
|
||||
//
|
||||
// SMSOverclockMenuItem
|
||||
//
|
||||
|
@ -2651,7 +2661,6 @@
|
|||
this.AtariSubMenu.Name = "AtariSubMenu";
|
||||
this.AtariSubMenu.Size = new System.Drawing.Size(42, 17);
|
||||
this.AtariSubMenu.Text = "&Atari";
|
||||
this.AtariSubMenu.DropDownOpened += new System.EventHandler(this.AtariSubMenu_DropDownOpened);
|
||||
//
|
||||
// AtariSettingsToolStripMenuItem
|
||||
//
|
||||
|
@ -2685,7 +2694,7 @@
|
|||
this.LoadGBInSGBMenuItem.Name = "LoadGBInSGBMenuItem";
|
||||
this.LoadGBInSGBMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.LoadGBInSGBMenuItem.Text = "Load GB in SGB";
|
||||
this.LoadGBInSGBMenuItem.Click += new System.EventHandler(this.LoadGBInSGBMenuItem_Click);
|
||||
this.LoadGBInSGBMenuItem.Click += new System.EventHandler(this.LoadGbInSgbMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator28
|
||||
//
|
||||
|
@ -2697,7 +2706,7 @@
|
|||
this.GBGPUViewerMenuItem.Name = "GBGPUViewerMenuItem";
|
||||
this.GBGPUViewerMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.GBGPUViewerMenuItem.Text = "GPU Viewer";
|
||||
this.GBGPUViewerMenuItem.Click += new System.EventHandler(this.GBGPUViewerMenuItem_Click);
|
||||
this.GBGPUViewerMenuItem.Click += new System.EventHandler(this.GbGpuViewerMenuItem_Click);
|
||||
//
|
||||
// GBGameGenieMenuItem
|
||||
//
|
||||
|
@ -2732,14 +2741,14 @@
|
|||
this.GBAmGBAMenuItem.Name = "GBAmGBAMenuItem";
|
||||
this.GBAmGBAMenuItem.Size = new System.Drawing.Size(120, 22);
|
||||
this.GBAmGBAMenuItem.Text = "mGBA";
|
||||
this.GBAmGBAMenuItem.Click += new System.EventHandler(this.GBAmGBAMenuItem_Click);
|
||||
this.GBAmGBAMenuItem.Click += new System.EventHandler(this.UsemGBAMenuItem_Click);
|
||||
//
|
||||
// GBAVBANextMenuItem
|
||||
//
|
||||
this.GBAVBANextMenuItem.Name = "GBAVBANextMenuItem";
|
||||
this.GBAVBANextMenuItem.Size = new System.Drawing.Size(120, 22);
|
||||
this.GBAVBANextMenuItem.Text = "&VBA-Next";
|
||||
this.GBAVBANextMenuItem.Click += new System.EventHandler(this.GBAVBANextMenuItem_Click);
|
||||
this.GBAVBANextMenuItem.Click += new System.EventHandler(this.UseVbaNextMenuItem_Click);
|
||||
//
|
||||
// GBAcoresettingsToolStripMenuItem1
|
||||
//
|
||||
|
@ -2914,7 +2923,7 @@
|
|||
this.SnesGBInSGBMenuItem.Name = "SnesGBInSGBMenuItem";
|
||||
this.SnesGBInSGBMenuItem.Size = new System.Drawing.Size(217, 22);
|
||||
this.SnesGBInSGBMenuItem.Text = "Load GB in SGB";
|
||||
this.SnesGBInSGBMenuItem.Click += new System.EventHandler(this.SnesGBInSGBMenuItem_Click);
|
||||
this.SnesGBInSGBMenuItem.Click += new System.EventHandler(this.SnesGbInSgbMenuItem_Click);
|
||||
//
|
||||
// SnesGameGenieMenuItem
|
||||
//
|
||||
|
@ -3045,7 +3054,7 @@
|
|||
this.DGBsettingsToolStripMenuItem.Name = "DGBsettingsToolStripMenuItem";
|
||||
this.DGBsettingsToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
|
||||
this.DGBsettingsToolStripMenuItem.Text = "Settings...";
|
||||
this.DGBsettingsToolStripMenuItem.Click += new System.EventHandler(this.DGBsettingsToolStripMenuItem_Click);
|
||||
this.DGBsettingsToolStripMenuItem.Click += new System.EventHandler(this.DgbSettingsMenuItem_Click);
|
||||
//
|
||||
// GenesisSubMenu
|
||||
//
|
||||
|
@ -3070,7 +3079,7 @@
|
|||
this.GenesisGameGenieECDC.Name = "GenesisGameGenieECDC";
|
||||
this.GenesisGameGenieECDC.Size = new System.Drawing.Size(217, 22);
|
||||
this.GenesisGameGenieECDC.Text = "&Game Genie Encoder/Decoder";
|
||||
this.GenesisGameGenieECDC.Click += new System.EventHandler(this.GenesisGameGenieECDC_Click);
|
||||
this.GenesisGameGenieECDC.Click += new System.EventHandler(this.GenesisGameGenieEcDc_Click);
|
||||
//
|
||||
// toolStripSeparator26
|
||||
//
|
||||
|
@ -3128,7 +3137,7 @@
|
|||
this.settingsToolStripMenuItem1.Name = "settingsToolStripMenuItem1";
|
||||
this.settingsToolStripMenuItem1.Size = new System.Drawing.Size(125, 22);
|
||||
this.settingsToolStripMenuItem1.Text = "&Settings...";
|
||||
this.settingsToolStripMenuItem1.Click += new System.EventHandler(this.settingsToolStripMenuItem1_Click_1);
|
||||
this.settingsToolStripMenuItem1.Click += new System.EventHandler(this.AppleIISettingsMenuItem_Click);
|
||||
//
|
||||
// C64SubMenu
|
||||
//
|
||||
|
@ -3168,6 +3177,7 @@
|
|||
this.IntvSubMenu.Name = "IntvSubMenu";
|
||||
this.IntvSubMenu.Size = new System.Drawing.Size(39, 17);
|
||||
this.IntvSubMenu.Text = "&Intv";
|
||||
this.IntvSubMenu.DropDownOpened += new System.EventHandler(this.IntvSubMenu_DropDownOpened);
|
||||
//
|
||||
// IntVControllerSettingsMenuItem
|
||||
//
|
||||
|
@ -3188,7 +3198,7 @@
|
|||
// preferencesToolStripMenuItem
|
||||
//
|
||||
this.preferencesToolStripMenuItem.Name = "preferencesToolStripMenuItem";
|
||||
this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(144, 22);
|
||||
this.preferencesToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.preferencesToolStripMenuItem.Text = "Preferences...";
|
||||
this.preferencesToolStripMenuItem.Click += new System.EventHandler(this.preferencesToolStripMenuItem_Click);
|
||||
//
|
||||
|
@ -3203,7 +3213,7 @@
|
|||
// preferencesToolStripMenuItem1
|
||||
//
|
||||
this.preferencesToolStripMenuItem1.Name = "preferencesToolStripMenuItem1";
|
||||
this.preferencesToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
|
||||
this.preferencesToolStripMenuItem1.Size = new System.Drawing.Size(144, 22);
|
||||
this.preferencesToolStripMenuItem1.Text = "Preferences...";
|
||||
this.preferencesToolStripMenuItem1.Click += new System.EventHandler(this.preferencesToolStripMenuItem1_Click);
|
||||
//
|
||||
|
@ -3825,7 +3835,7 @@
|
|||
this.GBInSGBContextMenuItem.Name = "GBInSGBContextMenuItem";
|
||||
this.GBInSGBContextMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||
this.GBInSGBContextMenuItem.Text = "GB in SGB";
|
||||
this.GBInSGBContextMenuItem.Click += new System.EventHandler(this.GBInSGBMenuItem_Click);
|
||||
this.GBInSGBContextMenuItem.Click += new System.EventHandler(this.GbInSgbMenuItem_Click);
|
||||
//
|
||||
// NesInQuickNESContextMenuItem
|
||||
//
|
||||
|
@ -3876,7 +3886,7 @@
|
|||
this.ClearSRAMContextMenuItem.Name = "ClearSRAMContextMenuItem";
|
||||
this.ClearSRAMContextMenuItem.Size = new System.Drawing.Size(201, 22);
|
||||
this.ClearSRAMContextMenuItem.Text = "Close and Clear SRAM";
|
||||
this.ClearSRAMContextMenuItem.Click += new System.EventHandler(this.ClearSRAMContextMenuItem_Click);
|
||||
this.ClearSRAMContextMenuItem.Click += new System.EventHandler(this.ClearSramContextMenuItem_Click);
|
||||
//
|
||||
// ShowMenuContextMenuSeparator
|
||||
//
|
||||
|
@ -3894,7 +3904,7 @@
|
|||
//
|
||||
this.timerMouseIdle.Enabled = true;
|
||||
this.timerMouseIdle.Interval = 2000;
|
||||
this.timerMouseIdle.Tick += new System.EventHandler(this.timerMouseIdle_Tick);
|
||||
this.timerMouseIdle.Tick += new System.EventHandler(this.TimerMouseIdle_Tick);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
|
@ -4343,6 +4353,7 @@
|
|||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator35;
|
||||
private System.Windows.Forms.ToolStripMenuItem C64DisksSubMenu;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator36;
|
||||
private System.Windows.Forms.ToolStripMenuItem Atari7800WithEmu7800MenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem sNESToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem preferencesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem virtualBoyToolStripMenuItem;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -43,9 +43,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
case "Screen Raw to Clipboard":
|
||||
// Ctrl+C clash. any tool that has such acc must check this.
|
||||
// maybe check if mainform has focus instead?
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
if (GlobalWin.Tools.Get<TAStudio>().ContainsFocus)
|
||||
break;
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>() && GlobalWin.Tools.Get<TAStudio>().ContainsFocus)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TakeScreenshotToClipboard();
|
||||
break;
|
||||
case "Screen Client to Clipboard":
|
||||
|
@ -67,7 +69,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
FlushSaveRAM();
|
||||
break;
|
||||
case "Display FPS":
|
||||
ToggleFPS();
|
||||
ToggleFps();
|
||||
break;
|
||||
case "Frame Counter":
|
||||
ToggleFrameCounter();
|
||||
|
@ -77,6 +79,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
ToggleLagCounter();
|
||||
}
|
||||
|
||||
break;
|
||||
case "Input Display":
|
||||
ToggleInputDisplay();
|
||||
|
@ -341,9 +344,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
type = " (on)";
|
||||
}
|
||||
|
||||
Global.CheatList.ToList().ForEach(x => x.Toggle());
|
||||
GlobalWin.OSD.AddMessage("Cheats toggled" + type);
|
||||
}
|
||||
|
||||
break;
|
||||
case "TAStudio":
|
||||
GlobalWin.Tools.Load<TAStudio>();
|
||||
|
@ -358,45 +363,93 @@ namespace BizHawk.Client.EmuHawk
|
|||
// RAM Search
|
||||
case "Do Search":
|
||||
if (GlobalWin.Tools.IsLoaded<RamSearch>())
|
||||
{
|
||||
GlobalWin.Tools.RamSearch.DoSearch();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "New Search":
|
||||
if (GlobalWin.Tools.IsLoaded<RamSearch>())
|
||||
{
|
||||
GlobalWin.Tools.RamSearch.NewSearch();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Previous Compare To":
|
||||
if (GlobalWin.Tools.IsLoaded<RamSearch>())
|
||||
{
|
||||
GlobalWin.Tools.RamSearch.NextCompareTo(reverse: true);
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Next Compare To":
|
||||
if (GlobalWin.Tools.IsLoaded<RamSearch>())
|
||||
{
|
||||
GlobalWin.Tools.RamSearch.NextCompareTo();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Previous Operator":
|
||||
if (GlobalWin.Tools.IsLoaded<RamSearch>())
|
||||
{
|
||||
GlobalWin.Tools.RamSearch.NextOperator(reverse: true);
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Next Operator":
|
||||
if (GlobalWin.Tools.IsLoaded<RamSearch>())
|
||||
{
|
||||
GlobalWin.Tools.RamSearch.NextOperator();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
//TAStudio
|
||||
// TAStudio
|
||||
case "Add Branch":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.AddBranchExternal();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Delete Branch":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.RemoveBranchExtrenal();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Show Cursor":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
|
@ -404,72 +457,154 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin.Tools.TAStudio.SetVisibleIndex();
|
||||
GlobalWin.Tools.TAStudio.RefreshDialog();
|
||||
}
|
||||
else return false;
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Toggle Follow Cursor":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.TasPlaybackBox.FollowCursor ^= true;
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Toggle Auto-Restore":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.TasPlaybackBox.AutoRestore ^= true;
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Toggle Turbo Seek":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.TasPlaybackBox.TurboSeek ^= true;
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Clear Frames":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.ClearFramesExternal();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Insert Frame":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.InsertFrameExternal();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Delete Frames":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.DeleteFramesExternal();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Clone Frames":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.CloneFramesExternal();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Analog Increment":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.AnalogIncrementByOne();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Analog Decrement":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.AnalogDecrementByOne();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Analog Incr. by 10":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.AnalogIncrementByTen();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Analog Decr. by 10":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.AnalogDecrementByTen();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Analog Maximum":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.AnalogMax();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
case "Analog Minimum":
|
||||
if (GlobalWin.Tools.IsLoaded<TAStudio>())
|
||||
{
|
||||
GlobalWin.Tools.TAStudio.AnalogMin();
|
||||
else return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// SNES
|
||||
|
@ -506,10 +641,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(null, Global.Config.Analog_LargeChange);
|
||||
break;
|
||||
case "Y Down Small":
|
||||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(null, -(Global.Config.Analog_SmallChange));
|
||||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(null, -Global.Config.Analog_SmallChange);
|
||||
break;
|
||||
case "Y Down Large":
|
||||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(null, -(Global.Config.Analog_LargeChange));
|
||||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(null, -Global.Config.Analog_LargeChange);
|
||||
break;
|
||||
case "X Up Small":
|
||||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(Global.Config.Analog_SmallChange, null);
|
||||
|
@ -518,10 +653,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(Global.Config.Analog_LargeChange, null);
|
||||
break;
|
||||
case "X Down Small":
|
||||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(-(Global.Config.Analog_SmallChange), null);
|
||||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(-Global.Config.Analog_SmallChange, null);
|
||||
break;
|
||||
case "X Down Large":
|
||||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(-(Global.Config.Analog_LargeChange), null);
|
||||
GlobalWin.Tools.VirtualPad.BumpAnalogValue(-Global.Config.Analog_LargeChange, null);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -121,7 +121,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
BizHawk.Client.Common.StringLogUtil.DefaultToDisk = Global.Config.MoviesOnDisk;
|
||||
BizHawk.Client.Common.StringLogUtil.DefaultToAWE = Global.Config.MoviesInAWE;
|
||||
|
||||
//super hacky! this needs to be done first. still not worth the trouble to make this system fully proper
|
||||
// super hacky! this needs to be done first. still not worth the trouble to make this system fully proper
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
var arg = args[i].ToLower();
|
||||
|
@ -131,13 +131,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
//create IGL context. we do this whether or not the user has selected OpenGL, so that we can run opengl-based emulator cores
|
||||
// create IGL context. we do this whether or not the user has selected OpenGL, so that we can run opengl-based emulator cores
|
||||
GlobalWin.IGL_GL = new Bizware.BizwareGL.Drivers.OpenTK.IGL_TK(2, 0, false);
|
||||
|
||||
//setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method
|
||||
// setup the GL context manager, needed for coping with multiple opengl cores vs opengl display method
|
||||
GLManager.CreateInstance(GlobalWin.IGL_GL);
|
||||
GlobalWin.GLManager = GLManager.Instance;
|
||||
GlobalWin.CR_GL = GlobalWin.GLManager.GetContextForIGL(GlobalWin.GL);
|
||||
|
||||
//now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen
|
||||
REDO_DISPMETHOD:
|
||||
|
@ -153,7 +152,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var e2 = new Exception("Initialization of Direct3d 9 Display Method failed; falling back to GDI+", ex);
|
||||
new ExceptionBox(e2).ShowDialog();
|
||||
//fallback
|
||||
|
||||
// fallback
|
||||
Global.Config.DispMethod = Config.EDispMethod.GdiPlus;
|
||||
goto REDO_DISPMETHOD;
|
||||
}
|
||||
|
@ -161,17 +161,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
else
|
||||
{
|
||||
GlobalWin.GL = GlobalWin.IGL_GL;
|
||||
//check the opengl version and dont even try to boot this crap up if its too old
|
||||
|
||||
// check the opengl version and dont even try to boot this crap up if its too old
|
||||
int version = GlobalWin.IGL_GL.Version;
|
||||
if (version < 200)
|
||||
{
|
||||
//fallback
|
||||
// fallback
|
||||
Global.Config.DispMethod = Config.EDispMethod.GdiPlus;
|
||||
goto REDO_DISPMETHOD;
|
||||
}
|
||||
}
|
||||
|
||||
//try creating a GUI Renderer. If that doesn't succeed. we fallback
|
||||
// try creating a GUI Renderer. If that doesn't succeed. we fallback
|
||||
try
|
||||
{
|
||||
using (GlobalWin.GL.CreateRenderer()) { }
|
||||
|
|
|
@ -900,16 +900,6 @@ namespace BizHawk.Client.EmuHawk.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap meteor {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("meteor", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
|
|
@ -1041,9 +1041,6 @@
|
|||
<data name="ts_v_piano_04_green_blue" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\images\tastudio\ts_v_piano_04_green_blue.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="meteor" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\images\meteor.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="HotKeys" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\images\HotKeys.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 820 B |
|
@ -1,10 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
@ -21,7 +15,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
AddressMask = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
public AddBreakpointDialog(BreakpointOperation op, uint address, uint mask, MemoryCallbackType type):this(op)
|
||||
public AddBreakpointDialog(BreakpointOperation op, uint address, uint mask, MemoryCallbackType type)
|
||||
: this(op)
|
||||
{
|
||||
AddressMaskBox.SetHexProperties(0xFFFFFFFF);
|
||||
Address = address;
|
||||
|
@ -37,6 +32,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return _operation;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
switch (value)
|
||||
|
@ -51,6 +47,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Text = "Edit Breakpoint";
|
||||
break;
|
||||
}
|
||||
|
||||
_operation = value;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +60,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
ExecuteRadio.Enabled = false;
|
||||
|
||||
}
|
||||
|
||||
public MemoryCallbackType BreakType
|
||||
|
@ -124,6 +120,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return AddressBox.GetMax();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
AddressBox.SetHexProperties(value);
|
||||
|
@ -145,13 +142,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void AddBreakpointDialog_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public enum BreakpointOperation
|
||||
{
|
||||
Add, Edit, Duplicate
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
using BizHawk.Emulation.Common;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -34,6 +33,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
breakpoint.ReadOnly = false;
|
||||
breakpoint.Active = false;
|
||||
}
|
||||
|
||||
return base.Remove(b);
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
removeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return removeCount;
|
||||
}
|
||||
}
|
||||
|
@ -106,11 +107,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
ReadOnly = readOnly;
|
||||
}
|
||||
|
||||
public Action Callback { get; set; }
|
||||
public Action Callback { get; }
|
||||
public uint? Address { get; set; }
|
||||
public uint? AddressMask { get; set; }
|
||||
public MemoryCallbackType Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Name { get; }
|
||||
|
||||
internal bool ReadOnly { get; set; }
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace BizHawk.Client.EmuHawk.tools.Debugger
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
partial class BreakpointControl
|
||||
{
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common.NumberExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk.tools.Debugger
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class BreakpointControl : UserControl
|
||||
{
|
||||
|
@ -21,7 +16,8 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
public IMemoryCallbackSystem MCS { get; set; }
|
||||
public GenericDebugger ParentDebugger { get; set; }
|
||||
public IMemoryDomains MemoryDomains { get; set; }
|
||||
private readonly BreakpointList Breakpoints = new BreakpointList();
|
||||
|
||||
private readonly BreakpointList _breakpoints = new BreakpointList();
|
||||
|
||||
public BreakpointControl()
|
||||
{
|
||||
|
@ -29,7 +25,7 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
BreakpointView.QueryItemText += BreakPointView_QueryItemText;
|
||||
BreakpointView.QueryItemBkColor += BreakPointView_QueryItemBkColor;
|
||||
BreakpointView.VirtualMode = true;
|
||||
Breakpoints.Callback = BreakpointCallback;
|
||||
_breakpoints.Callback = BreakpointCallback;
|
||||
}
|
||||
|
||||
private void BreakpointControl_Load(object sender, EventArgs e)
|
||||
|
@ -43,24 +39,24 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
switch (column)
|
||||
{
|
||||
case 0:
|
||||
text = string.Format("{0:X}", Breakpoints[index].Address);
|
||||
text = $"{_breakpoints[index].Address:X}";
|
||||
break;
|
||||
case 1:
|
||||
text = string.Format("{0:X}", Breakpoints[index].AddressMask);
|
||||
text = $"{_breakpoints[index].AddressMask:X}";
|
||||
break;
|
||||
case 2:
|
||||
text = Breakpoints[index].Type.ToString();
|
||||
text = _breakpoints[index].Type.ToString();
|
||||
break;
|
||||
case 3:
|
||||
text = Breakpoints[index].Name;
|
||||
text = _breakpoints[index].Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void BreakPointView_QueryItemBkColor(int index, int column, ref Color color)
|
||||
{
|
||||
color = Breakpoints[index].ReadOnly ? SystemColors.Control
|
||||
: Breakpoints[index].Active ? Color.LightCyan
|
||||
color = _breakpoints[index].ReadOnly ? SystemColors.Control
|
||||
: _breakpoints[index].Active ? Color.LightCyan
|
||||
: Color.White;
|
||||
}
|
||||
|
||||
|
@ -75,11 +71,11 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
{
|
||||
BreakpointCallback();
|
||||
|
||||
var seekBreakpoint = Breakpoints.FirstOrDefault(x => x.Name.StartsWith(SeekName));
|
||||
var seekBreakpoint = _breakpoints.FirstOrDefault(x => x.Name.StartsWith(SeekName));
|
||||
|
||||
if (seekBreakpoint != null)
|
||||
{
|
||||
Breakpoints.Remove(seekBreakpoint);
|
||||
_breakpoints.Remove(seekBreakpoint);
|
||||
UpdateValues();
|
||||
}
|
||||
|
||||
|
@ -94,30 +90,26 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
{
|
||||
CheckForNewBreakpoints();
|
||||
|
||||
BreakpointView.ItemCount = Breakpoints.Count;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Did any breakpoints get added from other sources such as lua?
|
||||
/// </summary>
|
||||
// Did any breakpoints get added from other sources such as lua?
|
||||
private void CheckForNewBreakpoints()
|
||||
{
|
||||
|
||||
if (MCS != null)
|
||||
{
|
||||
foreach (var callback in MCS)
|
||||
{
|
||||
if (!Breakpoints.Any(b =>
|
||||
if (!_breakpoints.Any(b =>
|
||||
b.Type == callback.Type &&
|
||||
b.Address == callback.Address &&
|
||||
b.AddressMask == callback.AddressMask &&
|
||||
b.Name == callback.Name &&
|
||||
b.Callback == callback.Callback
|
||||
))
|
||||
b.Callback == callback.Callback))
|
||||
{
|
||||
Breakpoints.Add(new Breakpoint(Core, callback));
|
||||
_breakpoints.Add(new Breakpoint(Core, callback));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,32 +121,32 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
{
|
||||
foreach (var callback in MCS)
|
||||
{
|
||||
Breakpoints.Add(new Breakpoint(Core, callback));
|
||||
_breakpoints.Add(new Breakpoint(Core, callback));
|
||||
}
|
||||
|
||||
BreakpointView.ItemCount = Breakpoints.Count;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
BreakpointView.Refresh();
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Enabled = false;
|
||||
Enabled = false;
|
||||
ParentDebugger.DisableBreakpointBox();
|
||||
}
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
Breakpoints.Clear();
|
||||
_breakpoints.Clear();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
||||
public void AddBreakpoint(uint address, uint mask, MemoryCallbackType type)
|
||||
{
|
||||
Breakpoints.Add(Core, address, mask, type);
|
||||
_breakpoints.Add(Core, address, mask, type);
|
||||
|
||||
BreakpointView.ItemCount = Breakpoints.Count;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
@ -165,10 +157,10 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
|
||||
if (b.ShowHawkDialog() == DialogResult.OK)
|
||||
{
|
||||
Breakpoints.Add(Core, b.Address, b.AddressMask, b.BreakType);
|
||||
_breakpoints.Add(Core, b.Address, b.AddressMask, b.BreakType);
|
||||
}
|
||||
|
||||
BreakpointView.ItemCount = Breakpoints.Count;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
@ -177,29 +169,26 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
|
||||
public void AddSeekBreakpoint(uint pcVal, int pcBitSize)
|
||||
{
|
||||
var Name = SeekName + pcVal.ToHexString(pcBitSize / 4);
|
||||
Breakpoints.Add(new Breakpoint(Name, true, Core, SeekCallback, pcVal, 0xFFFFFFFF, MemoryCallbackType.Execute));
|
||||
var name = SeekName + pcVal.ToHexString(pcBitSize / 4);
|
||||
_breakpoints.Add(new Breakpoint(name, true, Core, SeekCallback, pcVal, 0xFFFFFFFF, MemoryCallbackType.Execute));
|
||||
}
|
||||
|
||||
public void RemoveCurrentSeek()
|
||||
{
|
||||
var seekBreakpoint = Breakpoints.FirstOrDefault(x => x.Name.StartsWith(SeekName));
|
||||
var seekBreakpoint = _breakpoints.FirstOrDefault(x => x.Name.StartsWith(SeekName));
|
||||
|
||||
if (seekBreakpoint != null)
|
||||
{
|
||||
Breakpoints.Remove(seekBreakpoint);
|
||||
_breakpoints.Remove(seekBreakpoint);
|
||||
UpdateValues();
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<int> SelectedIndices
|
||||
{
|
||||
get { return BreakpointView.SelectedIndices.Cast<int>(); }
|
||||
}
|
||||
private IEnumerable<int> SelectedIndices => BreakpointView.SelectedIndices.Cast<int>();
|
||||
|
||||
private IEnumerable<Breakpoint> SelectedItems
|
||||
private IEnumerable<Breakpoint> SelectedItems
|
||||
{
|
||||
get { return SelectedIndices.Select(index => Breakpoints[index]); }
|
||||
get { return SelectedIndices.Select(index => _breakpoints[index]); }
|
||||
}
|
||||
|
||||
private IEnumerable<Breakpoint> EditableItems
|
||||
|
@ -216,10 +205,10 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
Breakpoints.Remove(item);
|
||||
_breakpoints.Remove(item);
|
||||
}
|
||||
|
||||
BreakpointView.ItemCount = Breakpoints.Count;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
@ -254,7 +243,7 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
item.Active ^= true;
|
||||
}
|
||||
|
||||
BreakpointView.ItemCount = Breakpoints.Count;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
@ -271,7 +260,7 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
|
||||
private void UpdateStatsLabel()
|
||||
{
|
||||
BreakpointStatsLabel.Text = string.Format("{0} Total / {1} Active", Breakpoints.Count(), Breakpoints.Count(x => x.Active));
|
||||
BreakpointStatsLabel.Text = $"{_breakpoints.Count} Total / {_breakpoints.Count(b => b.Active)} Active";
|
||||
}
|
||||
|
||||
private void ToggleButton_Click(object sender, EventArgs e)
|
||||
|
@ -281,7 +270,7 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
item.Active ^= true;
|
||||
}
|
||||
|
||||
BreakpointView.ItemCount = Breakpoints.Count;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
||||
|
@ -295,11 +284,11 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
|
||||
if (b.ShowHawkDialog() == DialogResult.OK)
|
||||
{
|
||||
Breakpoints.Add(new Breakpoint(Core, breakpoint.Callback, b.Address, b.AddressMask, b.BreakType, breakpoint.Active));
|
||||
_breakpoints.Add(new Breakpoint(Core, breakpoint.Callback, b.Address, b.AddressMask, b.BreakType, breakpoint.Active));
|
||||
}
|
||||
}
|
||||
|
||||
BreakpointView.ItemCount = Breakpoints.Count;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
@ -321,7 +310,7 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
BreakpointView.ItemCount = Breakpoints.Count;
|
||||
BreakpointView.ItemCount = _breakpoints.Count;
|
||||
UpdateBreakpointRemoveButton();
|
||||
UpdateStatsLabel();
|
||||
}
|
||||
|
@ -358,7 +347,7 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger
|
|||
return b;
|
||||
}
|
||||
|
||||
public enum BreakpointOperation
|
||||
private enum BreakpointOperation
|
||||
{
|
||||
Add, Edit, Duplicate
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
this.RegistersGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.RegisterPanel = new BizHawk.Client.EmuHawk.RegisterBoxControl();
|
||||
this.BreakpointsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.BreakPointControl1 = new BizHawk.Client.EmuHawk.tools.Debugger.BreakpointControl();
|
||||
this.BreakPointControl1 = new BizHawk.Client.EmuHawk.BreakpointControl();
|
||||
this.DisassemblerBox = new System.Windows.Forms.GroupBox();
|
||||
this.ToPCBtn = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
|
@ -409,7 +409,7 @@
|
|||
private System.Windows.Forms.GroupBox RegistersGroupBox;
|
||||
private RegisterBoxControl RegisterPanel;
|
||||
private System.Windows.Forms.GroupBox BreakpointsGroupBox;
|
||||
private tools.Debugger.BreakpointControl BreakPointControl1;
|
||||
private BreakpointControl BreakPointControl1;
|
||||
private System.Windows.Forms.GroupBox DisassemblerBox;
|
||||
private VirtualListView DisassemblerView;
|
||||
private System.Windows.Forms.ColumnHeader Address;
|
||||
|
|
|
@ -9,37 +9,31 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class GenericDebugger
|
||||
{
|
||||
private readonly List<DisasmOp> DisassemblyLines = new List<DisasmOp>();
|
||||
int PCRegisterSize = 4;
|
||||
uint currentDisassemblerAddress = 0;
|
||||
private readonly List<DisasmOp> _disassemblyLines = new List<DisasmOp>();
|
||||
private int _pcRegisterSize = 4;
|
||||
private uint _currentDisassemblerAddress;
|
||||
|
||||
private class DisasmOp
|
||||
{
|
||||
public DisasmOp(uint address, int s, string m)
|
||||
public DisasmOp(uint address, int size, string mnemonic)
|
||||
{
|
||||
Address = address;
|
||||
Size = s;
|
||||
Mnemonic = m;
|
||||
Size = size;
|
||||
Mnemonic = mnemonic;
|
||||
}
|
||||
|
||||
public uint Address { get; private set; }
|
||||
public int Size { get; private set; }
|
||||
public string Mnemonic { get; private set; }
|
||||
public uint Address { get; }
|
||||
public int Size { get; }
|
||||
public string Mnemonic { get; }
|
||||
}
|
||||
|
||||
private long BusMaxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return MemoryDomains.SystemBus.Size;
|
||||
}
|
||||
}
|
||||
private long BusMaxValue => MemoryDomains.SystemBus.Size;
|
||||
|
||||
public void UpdatePC()
|
||||
private void UpdatePC()
|
||||
{
|
||||
if (CanDisassemble)
|
||||
{
|
||||
currentDisassemblerAddress = (uint)PCRegister.Value;
|
||||
_currentDisassemblerAddress = (uint)PCRegister.Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,15 +50,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void Disassemble()
|
||||
{
|
||||
int line_count = DisassemblerView.NumberOfVisibleRows;
|
||||
int lineCount = DisassemblerView.NumberOfVisibleRows;
|
||||
|
||||
DisassemblyLines.Clear();
|
||||
uint a = currentDisassemblerAddress;
|
||||
for (int i = 0; i <= line_count; ++i)
|
||||
_disassemblyLines.Clear();
|
||||
uint a = _currentDisassemblerAddress;
|
||||
for (int i = 0; i <= lineCount; ++i)
|
||||
{
|
||||
int advance;
|
||||
string line = Disassembler.Disassemble(MemoryDomains.SystemBus, a, out advance);
|
||||
DisassemblyLines.Add(new DisasmOp(a, advance, line));
|
||||
_disassemblyLines.Add(new DisasmOp(a, advance, line));
|
||||
a += (uint)advance;
|
||||
if (a > BusMaxValue)
|
||||
{
|
||||
|
@ -77,24 +71,24 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
text = "";
|
||||
|
||||
if (index < DisassemblyLines.Count)
|
||||
if (index < _disassemblyLines.Count)
|
||||
{
|
||||
if (column == 0)
|
||||
{
|
||||
text = string.Format("{0:X" + PCRegisterSize + "}", DisassemblyLines[index].Address);
|
||||
text = string.Format("{0:X" + _pcRegisterSize + "}", _disassemblyLines[index].Address);
|
||||
}
|
||||
else if (column == 1)
|
||||
{
|
||||
text = DisassemblyLines[index].Mnemonic;
|
||||
text = _disassemblyLines[index].Mnemonic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DisassemblerView_QueryItemBkColor(int index, int column, ref Color color)
|
||||
{
|
||||
if (DisassemblyLines.Any() && index < DisassemblyLines.Count)
|
||||
if (_disassemblyLines.Any() && index < _disassemblyLines.Count)
|
||||
{
|
||||
if (DisassemblyLines[index].Address == currentDisassemblerAddress)
|
||||
if (_disassemblyLines[index].Address == _currentDisassemblerAddress)
|
||||
{
|
||||
color = Color.LightCyan;
|
||||
}
|
||||
|
@ -103,15 +97,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DecrementCurrentAddress()
|
||||
{
|
||||
uint newaddress = currentDisassemblerAddress;
|
||||
uint newaddress = _currentDisassemblerAddress;
|
||||
while (true)
|
||||
{
|
||||
int bytestoadvance;
|
||||
Disassembler.Disassemble(MemoryDomains.SystemBus, newaddress, out bytestoadvance);
|
||||
if (newaddress + bytestoadvance == currentDisassemblerAddress)
|
||||
if (newaddress + bytestoadvance == _currentDisassemblerAddress)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
newaddress--;
|
||||
|
||||
if (newaddress < 0)
|
||||
|
@ -121,22 +116,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
// Just in case
|
||||
if (currentDisassemblerAddress - newaddress > 5)
|
||||
if (_currentDisassemblerAddress - newaddress > 5)
|
||||
{
|
||||
newaddress = currentDisassemblerAddress - 1;
|
||||
newaddress = _currentDisassemblerAddress - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
currentDisassemblerAddress = newaddress;
|
||||
_currentDisassemblerAddress = newaddress;
|
||||
}
|
||||
|
||||
private void IncrementCurrentAddress()
|
||||
{
|
||||
currentDisassemblerAddress += (uint)DisassemblyLines.First().Size;
|
||||
if (currentDisassemblerAddress >= BusMaxValue)
|
||||
_currentDisassemblerAddress += (uint)_disassemblyLines.First().Size;
|
||||
if (_currentDisassemblerAddress >= BusMaxValue)
|
||||
{
|
||||
currentDisassemblerAddress = (uint)(BusMaxValue - 1);
|
||||
_currentDisassemblerAddress = (uint)(BusMaxValue - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,12 +183,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
var blob = new StringBuilder();
|
||||
foreach (int index in indices)
|
||||
{
|
||||
if (blob.Length != 0) blob.AppendLine();
|
||||
if (blob.Length != 0)
|
||||
{
|
||||
blob.AppendLine();
|
||||
}
|
||||
|
||||
blob.Append(string.Format("{0:X" + PCRegisterSize + "}", DisassemblyLines[index].Address))
|
||||
blob.Append(string.Format("{0:X" + _pcRegisterSize + "}", _disassemblyLines[index].Address))
|
||||
.Append(" ")
|
||||
.Append(DisassemblyLines[index].Mnemonic);
|
||||
.Append(_disassemblyLines[index].Mnemonic);
|
||||
}
|
||||
|
||||
Clipboard.SetDataObject(blob.ToString());
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +200,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void OnPauseChanged(object sender, MainForm.PauseChangedEventArgs e)
|
||||
{
|
||||
if (e.Paused)
|
||||
{
|
||||
FullUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private void DisassemblerContextMenu_Opening(object sender, EventArgs e)
|
||||
|
@ -215,7 +216,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (indices.Count > 0)
|
||||
{
|
||||
var line = DisassemblyLines[indices[0]];
|
||||
var line = _disassemblyLines[indices[0]];
|
||||
BreakPointControl1.AddBreakpoint(line.Address, 0xFFFFFFFF, Emulation.Common.MemoryCallbackType.Execute);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -27,12 +22,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void GenericDebugger_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void EngageDebugger()
|
||||
{
|
||||
DisassemblyLines.Clear();
|
||||
_disassemblyLines.Clear();
|
||||
GlobalWin.MainForm.OnPauseChanged += OnPauseChanged;
|
||||
CancelSeekBtn.Enabled = false;
|
||||
if (CanDisassemble)
|
||||
|
@ -74,7 +68,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
});
|
||||
}
|
||||
|
||||
PCRegisterSize = Debuggable.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName].BitSize / 4;
|
||||
_pcRegisterSize = Debuggable.GetCpuFlagsAndRegisters()[Disassembler.PCRegisterName].BitSize / 4;
|
||||
SetDisassemblerItemCount();
|
||||
UpdateDisassembler();
|
||||
}
|
||||
|
@ -187,7 +181,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DebugSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void RunBtn_Click(object sender, EventArgs e)
|
||||
|
@ -231,23 +224,24 @@ namespace BizHawk.Client.EmuHawk
|
|||
StepIntoMenuItem_Click(null, null);
|
||||
return true;
|
||||
}
|
||||
else if (keyData == (Keys.F11 | Keys.Shift))
|
||||
|
||||
if (keyData == (Keys.F11 | Keys.Shift))
|
||||
{
|
||||
StepOutMenuItem_Click(null, null);
|
||||
return true;
|
||||
}
|
||||
else if (keyData == Keys.F10)
|
||||
|
||||
if (keyData == Keys.F10)
|
||||
{
|
||||
StepOverMenuItem_Click(null, null);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
|
||||
private Control _currentToolTipControl = null;
|
||||
|
||||
private void GenericDebugger_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
var control = GetChildAtPoint(e.Location);
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -30,7 +26,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RegisterBoxControl_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void NewUpdate(ToolFormUpdateType type) { }
|
||||
|
@ -63,7 +58,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (_canSetCpuRegisters)
|
||||
{
|
||||
|
||||
Controls
|
||||
.OfType<TextBox>()
|
||||
.ToList()
|
||||
|
@ -192,7 +186,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -230,10 +223,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var c = new CheckBox
|
||||
{
|
||||
Appearance = System.Windows.Forms.Appearance.Button,
|
||||
Appearance = Appearance.Button,
|
||||
Name = flag.Key,
|
||||
Text = flag.Key.Replace("Flag", "").Trim(), // Hack
|
||||
Checked = flag.Value.Value == 1 ? true : false,
|
||||
Checked = flag.Value.Value == 1,
|
||||
Location = new Point(UIHelper.ScaleX(40), y),
|
||||
Dock = DockStyle.Left,
|
||||
Size = new Size(UIHelper.ScaleX(23), UIHelper.ScaleY(23)),
|
||||
|
|
|
@ -1489,7 +1489,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
UpdateValues();
|
||||
}
|
||||
}
|
||||
|
||||
private bool _lastSearchWasText = false;
|
||||
private void SearchTypeChanged(bool isText)
|
||||
{
|
||||
_lastSearchWasText = isText;
|
||||
}
|
||||
|
||||
private void FindMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
@ -1499,7 +1505,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
_hexFind = new HexFind
|
||||
{
|
||||
InitialLocation = PointToScreen(AddressesLabel.Location),
|
||||
InitialValue = _findStr
|
||||
InitialValue = _findStr,
|
||||
SearchTypeChangedCallback = SearchTypeChanged,
|
||||
InitialText = _lastSearchWasText
|
||||
};
|
||||
|
||||
_hexFind.Show();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
@ -14,7 +13,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
ChangeCasing();
|
||||
}
|
||||
|
||||
// Hacky values to remember the Hex vs Text radio selection across searches
|
||||
public Action<bool> SearchTypeChangedCallback { get; set; }
|
||||
public bool InitialText { get; set; }
|
||||
|
||||
public Point InitialLocation { get; set; }
|
||||
|
||||
|
||||
public string InitialValue
|
||||
{
|
||||
|
@ -29,8 +33,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
Location = InitialLocation;
|
||||
}
|
||||
|
||||
if (InitialText)
|
||||
{
|
||||
TextRadio.Select();
|
||||
}
|
||||
|
||||
FindBox.Focus();
|
||||
FindBox.Select();
|
||||
|
||||
}
|
||||
|
||||
private string GetFindBoxChars()
|
||||
|
@ -44,14 +54,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return FindBox.Text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var bytes = GlobalWin.Tools.HexEditor.ConvertTextToBytes(FindBox.Text);
|
||||
|
||||
var bytestring = new StringBuilder();
|
||||
foreach (var b in bytes)
|
||||
{
|
||||
bytestring.Append(string.Format("{0:X2}", b));
|
||||
bytestring.Append($"{b:X2}");
|
||||
}
|
||||
|
||||
return bytestring.ToString();
|
||||
|
@ -77,7 +86,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (HexRadio.Checked)
|
||||
{
|
||||
|
||||
FindBox = new HexTextBox
|
||||
{
|
||||
CharacterCasing = CharacterCasing.Upper,
|
||||
|
@ -103,11 +111,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void HexRadio_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ChangeCasing();
|
||||
SearchTypeChangedCallback?.Invoke(false);
|
||||
}
|
||||
|
||||
private void TextRadio_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ChangeCasing();
|
||||
SearchTypeChangedCallback?.Invoke(true);
|
||||
}
|
||||
|
||||
private void FindBox_KeyDown(object sender, KeyEventArgs e)
|
||||
|
|
|
@ -8,17 +8,16 @@ using BizHawk.Common;
|
|||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[Description("A library for manipulating the EmuHawk client UI")]
|
||||
public sealed class EmuHawkLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
[RequiredService]
|
||||
public IEmulator Emulator { get; set; }
|
||||
private IEmulator Emulator { get; set; }
|
||||
|
||||
[RequiredService]
|
||||
public IVideoProvider VideoProvider { get; set; }
|
||||
private IVideoProvider VideoProvider { get; set; }
|
||||
|
||||
private readonly Dictionary<int, string> _filterMappings = new Dictionary<int, string>
|
||||
{
|
||||
|
@ -35,30 +34,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
public EmuHawkLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
public override string Name { get { return "client"; } }
|
||||
public override string Name => "client";
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"exit",
|
||||
"Closes the emulator"
|
||||
)]
|
||||
[LuaMethodAttributes("exit", "Closes the emulator")]
|
||||
public void CloseEmulator()
|
||||
{
|
||||
GlobalWin.MainForm.CloseEmulator();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"exitCode",
|
||||
"Closes the emulator and returns the provided code"
|
||||
)]
|
||||
[LuaMethodAttributes("exitCode", "Closes the emulator and returns the provided code")]
|
||||
public void CloseEmulatorWithCode(int exitCode)
|
||||
{
|
||||
GlobalWin.MainForm.CloseEmulator(exitCode);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"borderheight",
|
||||
"Gets the current height in pixels of the letter/pillarbox area (top side only) around the emu display surface, excluding the gameExtraPadding you've set. This function (the whole lot of them) should be renamed or refactored since the padding areas have got more complex."
|
||||
)]
|
||||
"borderheight", "Gets the current height in pixels of the letter/pillarbox area (top side only) around the emu display surface, excluding the gameExtraPadding you've set. This function (the whole lot of them) should be renamed or refactored since the padding areas have got more complex.")]
|
||||
public static int BorderHeight()
|
||||
{
|
||||
var point = new System.Drawing.Point(0, 0);
|
||||
|
@ -66,9 +57,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"borderwidth",
|
||||
"Gets the current width in pixels of the letter/pillarbox area (left side only) around the emu display surface, excluding the gameExtraPadding you've set. This function (the whole lot of them) should be renamed or refactored since the padding areas have got more complex."
|
||||
)]
|
||||
"borderwidth", "Gets the current width in pixels of the letter/pillarbox area (left side only) around the emu display surface, excluding the gameExtraPadding you've set. This function (the whole lot of them) should be renamed or refactored since the padding areas have got more complex.")]
|
||||
public static int BorderWidth()
|
||||
{
|
||||
var point = new System.Drawing.Point(0, 0);
|
||||
|
@ -76,57 +65,38 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"bufferheight",
|
||||
"Gets the visible height of the emu display surface (the core video output). This excludes the gameExtraPadding you've set."
|
||||
)]
|
||||
"bufferheight", "Gets the visible height of the emu display surface (the core video output). This excludes the gameExtraPadding you've set.")]
|
||||
public int BufferHeight()
|
||||
{
|
||||
return VideoProvider.BufferHeight;
|
||||
//memento of original behaviour from scepheo's commit -- why?
|
||||
//var point = new System.Drawing.Point(0, height);
|
||||
//return GlobalWin.DisplayManager.TransformPoint(point).Y - BorderHeight();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"bufferwidth",
|
||||
"Gets the visible width of the emu display surface (the core video output). This excludes the gameExtraPadding you've set."
|
||||
)]
|
||||
"bufferwidth", "Gets the visible width of the emu display surface (the core video output). This excludes the gameExtraPadding you've set.")]
|
||||
public int BufferWidth()
|
||||
{
|
||||
return VideoProvider.BufferWidth;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"clearautohold",
|
||||
"Clears all autohold keys"
|
||||
)]
|
||||
[LuaMethodAttributes("clearautohold", "Clears all autohold keys")]
|
||||
public void ClearAutohold()
|
||||
{
|
||||
GlobalWin.MainForm.ClearHolds();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"closerom",
|
||||
"Closes the loaded Rom"
|
||||
)]
|
||||
[LuaMethodAttributes("closerom", "Closes the loaded Rom")]
|
||||
public static void CloseRom()
|
||||
{
|
||||
GlobalWin.MainForm.CloseRom();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"enablerewind",
|
||||
"Sets whether or not the rewind feature is enabled"
|
||||
)]
|
||||
[LuaMethodAttributes("enablerewind", "Sets whether or not the rewind feature is enabled")]
|
||||
public void EnableRewind(bool enabled)
|
||||
{
|
||||
GlobalWin.MainForm.EnableRewind(enabled);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"frameskip",
|
||||
"Sets the frame skip value of the client UI"
|
||||
)]
|
||||
[LuaMethodAttributes("frameskip", "Sets the frame skip value of the client UI")]
|
||||
public void FrameSkip(int numFrames)
|
||||
{
|
||||
if (numFrames > 0)
|
||||
|
@ -140,186 +110,125 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"gettargetscanlineintensity",
|
||||
"Gets the current scanline intensity setting, used for the scanline display filter"
|
||||
)]
|
||||
[LuaMethodAttributes("gettargetscanlineintensity", "Gets the current scanline intensity setting, used for the scanline display filter")]
|
||||
public static int GetTargetScanlineIntensity()
|
||||
{
|
||||
return Global.Config.TargetScanlineFilterIntensity;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"getwindowsize",
|
||||
"Gets the main window's size Possible values are 1, 2, 3, 4, 5, and 10"
|
||||
)]
|
||||
[LuaMethodAttributes("getwindowsize", "Gets the main window's size Possible values are 1, 2, 3, 4, 5, and 10")]
|
||||
public int GetWindowSize()
|
||||
{
|
||||
return Global.Config.TargetZoomFactors[Emulator.SystemId];
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"SetGameExtraPadding",
|
||||
"Sets the extra padding added to the 'emu' surface so that you can draw HUD elements in predictable placements"
|
||||
)]
|
||||
[LuaMethodAttributes("SetGameExtraPadding", "Sets the extra padding added to the 'emu' surface so that you can draw HUD elements in predictable placements")]
|
||||
public static void SetGameExtraPadding(int left, int top, int right, int bottom)
|
||||
{
|
||||
GlobalWin.DisplayManager.GameExtraPadding = new System.Windows.Forms.Padding(left, top, right, bottom);
|
||||
GlobalWin.MainForm.FrameBufferResized();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"SetSoundOn",
|
||||
"Sets the state of the Sound On toggle"
|
||||
)]
|
||||
[LuaMethodAttributes("SetSoundOn", "Sets the state of the Sound On toggle")]
|
||||
public static void SetSoundOn(bool enable)
|
||||
{
|
||||
Global.Config.SoundEnabled = enable;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"GetSoundOn",
|
||||
"Gets the state of the Sound On toggle"
|
||||
)]
|
||||
[LuaMethodAttributes("GetSoundOn", "Gets the state of the Sound On toggle")]
|
||||
public static bool GetSoundOn()
|
||||
{
|
||||
return Global.Config.SoundEnabled;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"SetClientExtraPadding",
|
||||
"Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements"
|
||||
)]
|
||||
[LuaMethodAttributes("SetClientExtraPadding", "Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements")]
|
||||
public static void SetClientExtraPadding(int left, int top, int right, int bottom)
|
||||
{
|
||||
GlobalWin.DisplayManager.ClientExtraPadding = new System.Windows.Forms.Padding(left, top, right, bottom);
|
||||
GlobalWin.MainForm.FrameBufferResized();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"ispaused",
|
||||
"Returns true if emulator is paused, otherwise, false"
|
||||
)]
|
||||
[LuaMethodAttributes("ispaused", "Returns true if emulator is paused, otherwise, false")]
|
||||
public static bool IsPaused()
|
||||
{
|
||||
return GlobalWin.MainForm.EmulatorPaused;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"opencheats",
|
||||
"opens the Cheats dialog"
|
||||
)]
|
||||
[LuaMethodAttributes("opencheats", "opens the Cheats dialog")]
|
||||
public static void OpenCheats()
|
||||
{
|
||||
GlobalWin.Tools.Load<Cheats>();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"openhexeditor",
|
||||
"opens the Hex Editor dialog"
|
||||
)]
|
||||
[LuaMethodAttributes("openhexeditor", "opens the Hex Editor dialog")]
|
||||
public static void OpenHexEditor()
|
||||
{
|
||||
GlobalWin.Tools.Load<HexEditor>();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"openramwatch",
|
||||
"opens the RAM Watch dialog"
|
||||
)]
|
||||
[LuaMethodAttributes("openramwatch", "opens the RAM Watch dialog")]
|
||||
public static void OpenRamWatch()
|
||||
{
|
||||
GlobalWin.Tools.LoadRamWatch(loadDialog: true);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"openramsearch",
|
||||
"opens the RAM Search dialog"
|
||||
)]
|
||||
[LuaMethodAttributes("openramsearch", "opens the RAM Search dialog")]
|
||||
public static void OpenRamSearch()
|
||||
{
|
||||
GlobalWin.Tools.Load<RamSearch>();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"openrom",
|
||||
"opens the Open ROM dialog"
|
||||
)]
|
||||
[LuaMethodAttributes("openrom", "opens the Open ROM dialog")]
|
||||
public static void OpenRom(string path)
|
||||
{
|
||||
GlobalWin.MainForm.LoadRom(path, new MainForm.LoadRomArgs() { OpenAdvanced = new OpenAdvanced_OpenRom() });
|
||||
GlobalWin.MainForm.LoadRom(path, new MainForm.LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom() });
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"opentasstudio",
|
||||
"opens the TAStudio dialog"
|
||||
)]
|
||||
[LuaMethodAttributes("opentasstudio", "opens the TAStudio dialog")]
|
||||
public static void OpenTasStudio()
|
||||
{
|
||||
GlobalWin.Tools.Load<TAStudio>();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"opentoolbox",
|
||||
"opens the Toolbox Dialog"
|
||||
)]
|
||||
[LuaMethodAttributes("opentoolbox", "opens the Toolbox Dialog")]
|
||||
public static void OpenToolBox()
|
||||
{
|
||||
GlobalWin.Tools.Load<ToolBox>();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"opentracelogger",
|
||||
"opens the tracelogger if it is available for the given core"
|
||||
)]
|
||||
[LuaMethodAttributes("opentracelogger", "opens the tracelogger if it is available for the given core")]
|
||||
public static void OpenTraceLogger()
|
||||
{
|
||||
GlobalWin.Tools.Load<TraceLogger>();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"pause",
|
||||
"Pauses the emulator"
|
||||
)]
|
||||
[LuaMethodAttributes("pause", "Pauses the emulator")]
|
||||
public static void Pause()
|
||||
{
|
||||
GlobalWin.MainForm.PauseEmulator();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"pause_av",
|
||||
"If currently capturing Audio/Video, this will suspend the record. Frames will not be captured into the AV until client.unpause_av() is called"
|
||||
)]
|
||||
[LuaMethodAttributes("pause_av", "If currently capturing Audio/Video, this will suspend the record. Frames will not be captured into the AV until client.unpause_av() is called")]
|
||||
public static void PauseAv()
|
||||
{
|
||||
GlobalWin.MainForm.PauseAVI = true;
|
||||
GlobalWin.MainForm.PauseAvi = true;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"reboot_core",
|
||||
"Reboots the currently loaded core"
|
||||
)]
|
||||
[LuaMethodAttributes("reboot_core", "Reboots the currently loaded core")]
|
||||
public static void RebootCore()
|
||||
{
|
||||
//pretty hacky.. we dont want a lua script to be able to restart itself by rebooting the core
|
||||
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).IsRebootingCore = true;
|
||||
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).LuaImp.IsRebootingCore = true;
|
||||
GlobalWin.MainForm.RebootCore();
|
||||
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).IsRebootingCore = false;
|
||||
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).LuaImp.IsRebootingCore = false;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"screenheight",
|
||||
"Gets the current height in pixels of the emulator's drawing area"
|
||||
)]
|
||||
[LuaMethodAttributes("screenheight", "Gets the current height in pixels of the emulator's drawing area")]
|
||||
public static int ScreenHeight()
|
||||
{
|
||||
return GlobalWin.MainForm.PresentationPanel.NativeSize.Height;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"screenshot",
|
||||
"if a parameter is passed it will function as the Screenshot As menu item of EmuHawk, else it will function as the Screenshot menu item"
|
||||
)]
|
||||
[LuaMethodAttributes("screenshot", "if a parameter is passed it will function as the Screenshot As menu item of EmuHawk, else it will function as the Screenshot menu item")]
|
||||
public static void Screenshot(string path = null)
|
||||
{
|
||||
if (path == null)
|
||||
|
@ -332,46 +241,31 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"screenshottoclipboard",
|
||||
"Performs the same function as EmuHawk's Screenshot To Clipboard menu item"
|
||||
)]
|
||||
[LuaMethodAttributes("screenshottoclipboard", "Performs the same function as EmuHawk's Screenshot To Clipboard menu item")]
|
||||
public static void ScreenshotToClipboard()
|
||||
{
|
||||
GlobalWin.MainForm.TakeScreenshotToClipboard();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"settargetscanlineintensity",
|
||||
"Sets the current scanline intensity setting, used for the scanline display filter"
|
||||
)]
|
||||
[LuaMethodAttributes("settargetscanlineintensity", "Sets the current scanline intensity setting, used for the scanline display filter")]
|
||||
public static void SetTargetScanlineIntensity(int val)
|
||||
{
|
||||
Global.Config.TargetScanlineFilterIntensity = val;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setscreenshotosd",
|
||||
"Sets the screenshot Capture OSD property of the client"
|
||||
)]
|
||||
[LuaMethodAttributes("setscreenshotosd", "Sets the screenshot Capture OSD property of the client")]
|
||||
public static void SetScreenshotOSD(bool value)
|
||||
{
|
||||
Global.Config.Screenshot_CaptureOSD = value;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"screenwidth",
|
||||
"Gets the current width in pixels of the emulator's drawing area"
|
||||
)]
|
||||
[LuaMethodAttributes("screenwidth", "Gets the current width in pixels of the emulator's drawing area")]
|
||||
public static int ScreenWidth()
|
||||
{
|
||||
return GlobalWin.MainForm.PresentationPanel.NativeSize.Width;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setwindowsize",
|
||||
"Sets the main window's size to the give value. Accepted values are 1, 2, 3, 4, 5, and 10"
|
||||
)]
|
||||
[LuaMethodAttributes("setwindowsize", "Sets the main window's size to the give value. Accepted values are 1, 2, 3, 4, 5, and 10")]
|
||||
public void SetWindowSize(int size)
|
||||
{
|
||||
if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10)
|
||||
|
@ -386,10 +280,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"speedmode",
|
||||
"Sets the speed of the emulator (in terms of percent)"
|
||||
)]
|
||||
[LuaMethodAttributes("speedmode", "Sets the speed of the emulator (in terms of percent)")]
|
||||
public void SpeedMode(int percent)
|
||||
{
|
||||
if (percent > 0 && percent < 6400)
|
||||
|
@ -402,75 +293,51 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"togglepause",
|
||||
"Toggles the current pause state"
|
||||
)]
|
||||
[LuaMethodAttributes("togglepause", "Toggles the current pause state")]
|
||||
public static void TogglePause()
|
||||
{
|
||||
GlobalWin.MainForm.TogglePause();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"transformPointX",
|
||||
"Transforms an x-coordinate in emulator space to an x-coordinate in client space"
|
||||
)]
|
||||
[LuaMethodAttributes("transformPointX", "Transforms an x-coordinate in emulator space to an x-coordinate in client space")]
|
||||
public static int TransformPointX(int x)
|
||||
{
|
||||
var point = new System.Drawing.Point(x, 0);
|
||||
return GlobalWin.DisplayManager.TransformPoint(point).X;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"transformPointY",
|
||||
"Transforms an y-coordinate in emulator space to an y-coordinate in client space"
|
||||
)]
|
||||
[LuaMethodAttributes("transformPointY", "Transforms an y-coordinate in emulator space to an y-coordinate in client space")]
|
||||
public static int TransformPointY(int y)
|
||||
{
|
||||
var point = new System.Drawing.Point(0, y);
|
||||
return GlobalWin.DisplayManager.TransformPoint(point).Y;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"unpause",
|
||||
"Unpauses the emulator"
|
||||
)]
|
||||
[LuaMethodAttributes("unpause", "Unpauses the emulator")]
|
||||
public static void Unpause()
|
||||
{
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"unpause_av",
|
||||
"If currently capturing Audio/Video this resumes capturing"
|
||||
)]
|
||||
[LuaMethodAttributes("unpause_av", "If currently capturing Audio/Video this resumes capturing")]
|
||||
public static void UnpauseAv()
|
||||
{
|
||||
GlobalWin.MainForm.PauseAVI = false;
|
||||
GlobalWin.MainForm.PauseAvi = false;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"xpos",
|
||||
"Returns the x value of the screen position where the client currently sits"
|
||||
)]
|
||||
[LuaMethodAttributes("xpos", "Returns the x value of the screen position where the client currently sits")]
|
||||
public static int Xpos()
|
||||
{
|
||||
return GlobalWin.MainForm.DesktopLocation.X;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"ypos",
|
||||
"Returns the y value of the screen position where the client currently sits"
|
||||
)]
|
||||
[LuaMethodAttributes("ypos", "Returns the y value of the screen position where the client currently sits")]
|
||||
public static int Ypos()
|
||||
{
|
||||
return GlobalWin.MainForm.DesktopLocation.Y;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"getavailabletools",
|
||||
"Returns a list of the tools currently open"
|
||||
)]
|
||||
[LuaMethodAttributes("getavailabletools", "Returns a list of the tools currently open")]
|
||||
public LuaTable GetAvailableTools()
|
||||
{
|
||||
var t = Lua.NewTable();
|
||||
|
@ -484,9 +351,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"gettool",
|
||||
"Returns an object that represents a tool of the given name (not case sensitive). If the tool is not open, it will be loaded if available. Use gettools to get a list of names"
|
||||
)]
|
||||
"gettool", "Returns an object that represents a tool of the given name (not case sensitive). If the tool is not open, it will be loaded if available. Use gettools to get a list of names")]
|
||||
public LuaTable GetTool(string name)
|
||||
{
|
||||
var toolType = ReflectionUtil.GetTypeByName(name)
|
||||
|
@ -509,9 +374,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"createinstance",
|
||||
"returns a default instance of the given type of object if it exists (not case sensitive). Note: This will only work on objects which have a parameterless constructor. If no suitable type is found, or the type does not have a parameterless constructor, then nil is returned"
|
||||
)]
|
||||
"createinstance", "returns a default instance of the given type of object if it exists (not case sensitive). Note: This will only work on objects which have a parameterless constructor. If no suitable type is found, or the type does not have a parameterless constructor, then nil is returned")]
|
||||
public LuaTable CreateInstance(string name)
|
||||
{
|
||||
var possibleTypes = ReflectionUtil.GetTypeByName(name);
|
||||
|
@ -525,19 +388,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
return null;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"displaymessages",
|
||||
"sets whether or not on screen messages will display"
|
||||
)]
|
||||
[LuaMethodAttributes("displaymessages", "sets whether or not on screen messages will display")]
|
||||
public void DisplayMessages(bool value)
|
||||
{
|
||||
Global.Config.DisplayMessages = value;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"saveram",
|
||||
"flushes save ram to disk"
|
||||
)]
|
||||
[LuaMethodAttributes("saveram", "flushes save ram to disk")]
|
||||
public void SaveRam()
|
||||
{
|
||||
GlobalWin.MainForm.FlushSaveRAM();
|
||||
|
|
|
@ -16,21 +16,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
public ConsoleLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
public override string Name { get { return "console"; } }
|
||||
public override string Name => "console";
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"clear",
|
||||
"clears the output box of the Lua Console window"
|
||||
)]
|
||||
[LuaMethodAttributes("clear", "clears the output box of the Lua Console window")]
|
||||
public static void Clear()
|
||||
{
|
||||
GlobalWin.Tools.LuaConsole.ClearOutputWindow();
|
||||
if (GlobalWin.Tools.Has<LuaConsole>())
|
||||
{
|
||||
GlobalWin.Tools.LuaConsole.ClearOutputWindow();
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"getluafunctionslist",
|
||||
"returns a list of implemented functions"
|
||||
)]
|
||||
[LuaMethodAttributes("getluafunctionslist", "returns a list of implemented functions")]
|
||||
public static string GetLuaFunctionsList()
|
||||
{
|
||||
var list = new StringBuilder();
|
||||
|
@ -42,34 +39,34 @@ namespace BizHawk.Client.EmuHawk
|
|||
return list.ToString();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"log",
|
||||
"Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable"
|
||||
)]
|
||||
[LuaMethodAttributes("log", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
|
||||
public static void Log(params object[] outputs)
|
||||
{
|
||||
LogWithSeparator("\t", "\n", outputs);
|
||||
if (GlobalWin.Tools.Has<LuaConsole>())
|
||||
{
|
||||
LogWithSeparator("\t", "\n", outputs);
|
||||
}
|
||||
}
|
||||
|
||||
//// Single param version is used by logOutputCallback of some libraries.
|
||||
public static void LogOutput(object output)
|
||||
{
|
||||
Log(output);
|
||||
if (GlobalWin.Tools.Has<LuaConsole>())
|
||||
{
|
||||
Log(output);
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"writeline",
|
||||
"Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable"
|
||||
)]
|
||||
[LuaMethodAttributes("writeline", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
|
||||
public static void WriteLine(params object[] outputs)
|
||||
{
|
||||
LogWithSeparator("\n", "\n", outputs);
|
||||
if (GlobalWin.Tools.Has<LuaConsole>())
|
||||
{
|
||||
LogWithSeparator("\n", "\n", outputs);
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"write",
|
||||
"Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable"
|
||||
)]
|
||||
[LuaMethodAttributes("write", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
|
||||
public static void Write(params object[] outputs)
|
||||
{
|
||||
LogWithSeparator("", "", outputs);
|
||||
|
@ -78,11 +75,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
// Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable
|
||||
private static void LogWithSeparator(string separator, string terminator, params object[] outputs)
|
||||
{
|
||||
if (!GlobalWin.Tools.Has<LuaConsole>())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (outputs == null)
|
||||
{
|
||||
GlobalWin.Tools.LuaConsole.WriteToOutputWindow("(no return)" + terminator);
|
||||
return;
|
||||
}
|
||||
|
||||
for (var outIndex = 0; outIndex < outputs.Length; outIndex++)
|
||||
{
|
||||
var output = outputs[outIndex];
|
||||
|
@ -135,6 +138,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
GlobalWin.Tools.LuaConsole.WriteToOutputWindow(terminator);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
: base(lua, logOutputCallback) { }
|
||||
|
||||
// TODO: replace references to ConsoleLuaLibrary.Log with a callback that is passed in
|
||||
public override string Name { get { return "forms"; } }
|
||||
public override string Name => "forms";
|
||||
|
||||
#region Forms Library Helpers
|
||||
|
||||
|
@ -61,10 +61,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
#endregion
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"addclick",
|
||||
"adds the given lua function as a click event to the given control"
|
||||
)]
|
||||
[LuaMethodAttributes("addclick", "adds the given lua function as a click event to the given control")]
|
||||
public void AddClick(int handle, LuaFunction clickEvent)
|
||||
{
|
||||
var ptr = new IntPtr(handle);
|
||||
|
@ -81,9 +78,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"button",
|
||||
"Creates a button control on the given form. The caption property will be the text value on the button. clickEvent is the name of a Lua function that will be invoked when the button is clicked. x, and y are the optional location parameters for the position of the button within the given form. The function returns the handle of the created button. Width and Height are optional, if not specified they will be a default size"
|
||||
)]
|
||||
"button", "Creates a button control on the given form. The caption property will be the text value on the button. clickEvent is the name of a Lua function that will be invoked when the button is clicked. x, and y are the optional location parameters for the position of the button within the given form. The function returns the handle of the created button. Width and Height are optional, if not specified they will be a default size")]
|
||||
public int Button(
|
||||
int formHandle,
|
||||
string caption,
|
||||
|
@ -118,9 +113,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"checkbox",
|
||||
"Creates a checkbox control on the given form. The caption property will be the text of the checkbox. x and y are the optional location parameters for the position of the checkbox within the form"
|
||||
)]
|
||||
"checkbox", "Creates a checkbox control on the given form. The caption property will be the text of the checkbox. x and y are the optional location parameters for the position of the checkbox within the form")]
|
||||
public int Checkbox(int formHandle, string caption, int? x = null, int? y = null)
|
||||
{
|
||||
var form = GetForm(formHandle);
|
||||
|
@ -141,10 +134,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return (int)checkbox.Handle;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"clearclicks",
|
||||
"Removes all click events from the given widget at the specified handle"
|
||||
)]
|
||||
[LuaMethodAttributes("clearclicks", "Removes all click events from the given widget at the specified handle")]
|
||||
public void ClearClicks(int handle)
|
||||
{
|
||||
var ptr = new IntPtr(handle);
|
||||
|
@ -164,10 +154,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"destroy",
|
||||
"Closes and removes a Lua created form with the specified handle. If a dialog was found and removed true is returned, else false"
|
||||
)]
|
||||
[LuaMethodAttributes("destroy", "Closes and removes a Lua created form with the specified handle. If a dialog was found and removed true is returned, else false")]
|
||||
public bool Destroy(int handle)
|
||||
{
|
||||
var ptr = new IntPtr(handle);
|
||||
|
@ -184,10 +171,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return false;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"destroyall",
|
||||
"Closes and removes all Lua created dialogs"
|
||||
)]
|
||||
[LuaMethodAttributes("destroyall", "Closes and removes all Lua created dialogs")]
|
||||
public void DestroyAll()
|
||||
{
|
||||
for (var i = _luaForms.Count - 1; i >= 0; i--)
|
||||
|
@ -197,9 +181,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"dropdown",
|
||||
"Creates a dropdown (with a ComboBoxStyle of DropDownList) control on the given form. Dropdown items are passed via a lua table. Only the values will be pulled for the dropdown items, the keys are irrelevant. Items will be sorted alphabetically. x and y are the optional location parameters, and width and height are the optional size parameters."
|
||||
)]
|
||||
"dropdown", "Creates a dropdown (with a ComboBoxStyle of DropDownList) control on the given form. Dropdown items are passed via a lua table. Only the values will be pulled for the dropdown items, the keys are irrelevant. Items will be sorted alphabetically. x and y are the optional location parameters, and width and height are the optional size parameters.")]
|
||||
public int Dropdown(
|
||||
int formHandle,
|
||||
LuaTable items,
|
||||
|
@ -233,10 +215,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return (int)dropdown.Handle;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"getproperty",
|
||||
"returns a string representation of the value of a property of the widget at the given handle"
|
||||
)]
|
||||
[LuaMethodAttributes("getproperty", "returns a string representation of the value of a property of the widget at the given handle")]
|
||||
public string GetProperty(int handle, string property)
|
||||
{
|
||||
try
|
||||
|
@ -266,10 +245,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return "";
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"gettext",
|
||||
"Returns the text property of a given form or control"
|
||||
)]
|
||||
[LuaMethodAttributes("gettext", "Returns the text property of a given form or control")]
|
||||
public string GetText(int handle)
|
||||
{
|
||||
try
|
||||
|
@ -304,10 +280,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return "";
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"ischecked",
|
||||
"Returns the given checkbox's checked property"
|
||||
)]
|
||||
[LuaMethodAttributes("ischecked", "Returns the given checkbox's checked property")]
|
||||
public bool IsChecked(int handle)
|
||||
{
|
||||
var ptr = new IntPtr(handle);
|
||||
|
@ -336,9 +309,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"label",
|
||||
"Creates a label control on the given form. The caption property is the text of the label. x, and y are the optional location parameters for the position of the label within the given form. The function returns the handle of the created label. Width and Height are optional, if not specified they will be a default size."
|
||||
)]
|
||||
"label", "Creates a label control on the given form. The caption property is the text of the label. x, and y are the optional location parameters for the position of the label within the given form. The function returns the handle of the created label. Width and Height are optional, if not specified they will be a default size.")]
|
||||
public int Label(
|
||||
int formHandle,
|
||||
string caption,
|
||||
|
@ -377,9 +348,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"newform",
|
||||
"creates a new default dialog, if both width and height are specified it will create a dialog of the specified size. If title is specified it will be the caption of the dialog, else the dialog caption will be 'Lua Dialog'. The function will return an int representing the handle of the dialog created."
|
||||
)]
|
||||
"newform", "creates a new default dialog, if both width and height are specified it will create a dialog of the specified size. If title is specified it will be the caption of the dialog, else the dialog caption will be 'Lua Dialog'. The function will return an int representing the handle of the dialog created.")]
|
||||
public int NewForm(int? width = null, int? height = null, string title = null, LuaFunction onClose = null)
|
||||
{
|
||||
var form = new LuaWinform(CurrentThread);
|
||||
|
@ -414,9 +383,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"openfile",
|
||||
"Creates a standard openfile dialog with optional parameters for the filename, directory, and filter. The return value is the directory that the user picked. If they chose to cancel, it will return an empty string"
|
||||
)]
|
||||
"openfile", "Creates a standard openfile dialog with optional parameters for the filename, directory, and filter. The return value is the directory that the user picked. If they chose to cancel, it will return an empty string")]
|
||||
public string OpenFile(string fileName = null, string initialDirectory = null, string filter = "All files (*.*)|*.*")
|
||||
{
|
||||
// filterext format ex: "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*"
|
||||
|
@ -445,24 +412,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
return "";
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setdropdownitems",
|
||||
"Sets the items for a given dropdown box"
|
||||
)]
|
||||
public void SetDropdownItems(
|
||||
int handle,
|
||||
LuaTable items)
|
||||
[LuaMethodAttributes("setdropdownitems", "Sets the items for a given dropdown box")]
|
||||
public void SetDropdownItems(int handle, LuaTable items)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
var ptr = new IntPtr(handle);
|
||||
foreach (var form in _luaForms) {
|
||||
if (form.Handle == ptr) {
|
||||
foreach (var form in _luaForms)
|
||||
{
|
||||
if (form.Handle == ptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (Control control in form.Controls) {
|
||||
if (control.Handle == ptr) {
|
||||
if (control is LuaDropDown) {
|
||||
foreach (Control control in form.Controls)
|
||||
{
|
||||
if (control.Handle == ptr)
|
||||
{
|
||||
if (control is LuaDropDown)
|
||||
{
|
||||
var dropdownItems = items.Values.Cast<string>().ToList();
|
||||
dropdownItems.Sort();
|
||||
(control as LuaDropDown).SetItems(dropdownItems);
|
||||
|
@ -472,15 +440,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ConsoleLuaLibrary.Log(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setlocation",
|
||||
"Sets the location of a control or form by passing in the handle of the created object"
|
||||
)]
|
||||
[LuaMethodAttributes("setlocation", "Sets the location of a control or form by passing in the handle of the created object")]
|
||||
public void SetLocation(int handle, int x, int y)
|
||||
{
|
||||
var ptr = new IntPtr(handle);
|
||||
|
@ -503,10 +470,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setproperty",
|
||||
"Attempts to set the given property of the widget with the given value. Note: not all properties will be able to be represented for the control to accept"
|
||||
)]
|
||||
[LuaMethodAttributes("setproperty", "Attempts to set the given property of the widget with the given value. Note: not all properties will be able to be represented for the control to accept")]
|
||||
public void SetProperty(int handle, string property, object value)
|
||||
{
|
||||
var ptr = new IntPtr(handle);
|
||||
|
@ -519,16 +483,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
value = Enum.Parse(form.GetType().GetProperty(property).PropertyType, value.ToString(), true);
|
||||
}
|
||||
|
||||
if (pt == typeof(Color))
|
||||
{
|
||||
//relying on exceptions for error handling here
|
||||
// relying on exceptions for error handling here
|
||||
var sval = (string)value;
|
||||
if (sval[0] != '#') throw new Exception("Invalid #aarrggbb color");
|
||||
if (sval.Length != 9) throw new Exception("Invalid #aarrggbb color");
|
||||
if (sval[0] != '#')
|
||||
{
|
||||
throw new Exception("Invalid #aarrggbb color");
|
||||
}
|
||||
|
||||
if (sval.Length != 9)
|
||||
{
|
||||
throw new Exception("Invalid #aarrggbb color");
|
||||
}
|
||||
|
||||
value = Color.FromArgb(int.Parse(sval.Substring(1),System.Globalization.NumberStyles.HexNumber));
|
||||
}
|
||||
form
|
||||
.GetType()
|
||||
|
||||
form.GetType()
|
||||
.GetProperty(property)
|
||||
.SetValue(form, Convert.ChangeType(value, form.GetType().GetProperty(property).PropertyType), null);
|
||||
}
|
||||
|
@ -542,8 +515,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
value = Enum.Parse(control.GetType().GetProperty(property).PropertyType, value.ToString(), true);
|
||||
}
|
||||
control
|
||||
.GetType()
|
||||
|
||||
control.GetType()
|
||||
.GetProperty(property)
|
||||
.SetValue(control, Convert.ChangeType(value, control.GetType().GetProperty(property).PropertyType), null);
|
||||
}
|
||||
|
@ -552,19 +525,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"createcolor",
|
||||
"Creates a color object useful with setproperty"
|
||||
)]
|
||||
[LuaMethodAttributes("createcolor", "Creates a color object useful with setproperty")]
|
||||
public Color CreateColor(int r, int g, int b, int a)
|
||||
{
|
||||
return Color.FromArgb(a, r, g, b);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setsize",
|
||||
"TODO"
|
||||
)]
|
||||
[LuaMethodAttributes("setsize", "TODO")]
|
||||
public void SetSize(int handle, int width, int height)
|
||||
{
|
||||
var ptr = new IntPtr(handle);
|
||||
|
@ -587,10 +554,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"settext",
|
||||
"Sets the text property of a control or form by passing in the handle of the created object"
|
||||
)]
|
||||
[LuaMethodAttributes("settext", "Sets the text property of a control or form by passing in the handle of the created object")]
|
||||
public void Settext(int handle, string caption)
|
||||
{
|
||||
var ptr = new IntPtr(handle);
|
||||
|
@ -614,9 +578,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"textbox",
|
||||
"Creates a textbox control on the given form. The caption property will be the initial value of the textbox (default is empty). Width and Height are option, if not specified they will be a default size of 100, 20. Type is an optional property to restrict the textbox input. The available options are HEX, SIGNED, and UNSIGNED. Passing it null or any other value will set it to no restriction. x, and y are the optional location parameters for the position of the textbox within the given form. The function returns the handle of the created textbox. If true, the multiline will enable the standard winform multi-line property. If true, the fixedWidth options will create a fixed width font. Scrollbars is an optional property to specify which scrollbars to display. The available options are Vertical, Horizontal, Both, and None. Scrollbars are only shown on a multiline textbox"
|
||||
)]
|
||||
"textbox", "Creates a textbox control on the given form. The caption property will be the initial value of the textbox (default is empty). Width and Height are option, if not specified they will be a default size of 100, 20. Type is an optional property to restrict the textbox input. The available options are HEX, SIGNED, and UNSIGNED. Passing it null or any other value will set it to no restriction. x, and y are the optional location parameters for the position of the textbox within the given form. The function returns the handle of the created textbox. If true, the multiline will enable the standard winform multi-line property. If true, the fixedWidth options will create a fixed width font. Scrollbars is an optional property to specify which scrollbars to display. The available options are Vertical, Horizontal, Both, and None. Scrollbars are only shown on a multiline textbox")]
|
||||
public int Textbox(
|
||||
int formHandle,
|
||||
string caption = null,
|
||||
|
@ -662,6 +624,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetText(textbox, caption);
|
||||
|
||||
if (x.HasValue && y.HasValue)
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public sealed class GuiLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
[RequiredService]
|
||||
public IEmulator Emulator { get; set; }
|
||||
private IEmulator Emulator { get; set; }
|
||||
|
||||
public GuiLuaLibrary(Lua lua)
|
||||
: base(lua) { }
|
||||
|
@ -21,12 +21,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
public GuiLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
private Color DefaultForeground = Color.White;
|
||||
private Color? DefaultBackground = null;
|
||||
private Color? DefaultTextBackground = Color.FromArgb(128, 0, 0, 0);
|
||||
private int DefaultPixelFont = 1; // gens
|
||||
private Color _defaultForeground = Color.White;
|
||||
private Color? _defaultBackground;
|
||||
private Color? _defaultTextBackground = Color.FromArgb(128, 0, 0, 0);
|
||||
private int _defaultPixelFont = 1; // gens
|
||||
|
||||
public override string Name { get { return "gui"; } }
|
||||
public override string Name => "gui";
|
||||
|
||||
#region Gui API
|
||||
|
||||
|
@ -43,24 +43,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public bool SurfaceIsNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return _luaSurface == null;
|
||||
}
|
||||
}
|
||||
public bool SurfaceIsNull => _luaSurface == null;
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"DrawNew",
|
||||
"Changes drawing target to the specified lua surface name. This may clobber any previous drawing to this surface (pass false if you don't want it to)"
|
||||
)]
|
||||
public void DrawNew(string name, bool? clear=true)
|
||||
"DrawNew", "Changes drawing target to the specified lua surface name. This may clobber any previous drawing to this surface (pass false if you don't want it to)")]
|
||||
public void DrawNew(string name, bool? clear = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
DrawFinish();
|
||||
_luaSurface = GlobalWin.DisplayManager.LockLuaSurface(name,clear??true);
|
||||
_luaSurface = GlobalWin.DisplayManager.LockLuaSurface(name, clear ?? true);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
|
@ -68,25 +60,23 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"DrawFinish",
|
||||
"Finishes drawing to the current lua surface and causes it to get displayed."
|
||||
)]
|
||||
[LuaMethodAttributes("DrawFinish", "Finishes drawing to the current lua surface and causes it to get displayed.")]
|
||||
public void DrawFinish()
|
||||
{
|
||||
if(_luaSurface != null)
|
||||
if (_luaSurface != null)
|
||||
{
|
||||
GlobalWin.DisplayManager.UnlockLuaSurface(_luaSurface);
|
||||
}
|
||||
|
||||
_luaSurface = null;
|
||||
}
|
||||
|
||||
public bool HasLuaSurface
|
||||
{
|
||||
get { return _luaSurface != null; }
|
||||
}
|
||||
public bool HasLuaSurface => _luaSurface != null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
private readonly Dictionary<string, Image> _imageCache = new Dictionary<string, Image>();
|
||||
|
||||
private readonly Dictionary<Color, SolidBrush> _solidBrushes = new Dictionary<Color, SolidBrush>();
|
||||
private readonly Dictionary<Color, Pen> _pens = new Dictionary<Color, Pen>();
|
||||
|
@ -122,7 +112,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var g = _luaSurface == null ? Graphics.FromImage(_nullGraphicsBitmap) : _luaSurface.GetGraphics();
|
||||
|
||||
//we don't like CoreComm, right? Someone should find a different way to do this then.
|
||||
// we don't like CoreComm, right? Someone should find a different way to do this then.
|
||||
var tx = Emulator.CoreComm.ScreenLogicalOffsetX;
|
||||
var ty = Emulator.CoreComm.ScreenLogicalOffsetY;
|
||||
if (tx != 0 || ty != 0)
|
||||
|
@ -137,89 +127,64 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
#endregion
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"addmessage",
|
||||
"Adds a message to the OSD's message area"
|
||||
)]
|
||||
[LuaMethodAttributes("addmessage", "Adds a message to the OSD's message area")]
|
||||
public void AddMessage(string message)
|
||||
{
|
||||
GlobalWin.OSD.AddMessage(message);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"clearGraphics",
|
||||
"clears all lua drawn graphics from the screen"
|
||||
)]
|
||||
[LuaMethodAttributes("clearGraphics", "clears all lua drawn graphics from the screen")]
|
||||
public void ClearGraphics()
|
||||
{
|
||||
_luaSurface.Clear();
|
||||
DrawFinish();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"cleartext",
|
||||
"clears all text created by gui.text()"
|
||||
)]
|
||||
[LuaMethodAttributes("cleartext", "clears all text created by gui.text()")]
|
||||
public static void ClearText()
|
||||
{
|
||||
GlobalWin.OSD.ClearGUIText();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"defaultForeground",
|
||||
"Sets the default foreground color to use in drawing methods, white by default"
|
||||
)]
|
||||
[LuaMethodAttributes("defaultForeground", "Sets the default foreground color to use in drawing methods, white by default")]
|
||||
public void SetDefaultForegroundColor(Color color)
|
||||
{
|
||||
DefaultForeground = color;
|
||||
_defaultForeground = color;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"defaultBackground",
|
||||
"Sets the default background color to use in drawing methods, transparent by default"
|
||||
)]
|
||||
[LuaMethodAttributes("defaultBackground", "Sets the default background color to use in drawing methods, transparent by default")]
|
||||
public void SetDefaultBackgroundColor(Color color)
|
||||
{
|
||||
DefaultBackground = color;
|
||||
_defaultBackground = color;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"defaultTextBackground",
|
||||
"Sets the default backgroiund color to use in text drawing methods, half-transparent black by default"
|
||||
)]
|
||||
[LuaMethodAttributes("defaultTextBackground", "Sets the default backgroiund color to use in text drawing methods, half-transparent black by default")]
|
||||
public void SetDefaultTextBackground(Color color)
|
||||
{
|
||||
DefaultTextBackground = color;
|
||||
_defaultTextBackground = color;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"defaultPixelFont",
|
||||
"Sets the default font to use in gui.pixelText(). Two font families are available, \"fceux\" and \"gens\" (or \"0\" and \"1\" respectively), \"gens\" is used by default"
|
||||
)]
|
||||
"defaultPixelFont", "Sets the default font to use in gui.pixelText(). Two font families are available, \"fceux\" and \"gens\" (or \"0\" and \"1\" respectively), \"gens\" is used by default")]
|
||||
public void SetDefaultTextBackground(string fontfamily)
|
||||
{
|
||||
switch (fontfamily)
|
||||
{
|
||||
case "fceux":
|
||||
case "0":
|
||||
DefaultPixelFont = 0;
|
||||
_defaultPixelFont = 0;
|
||||
break;
|
||||
case "gens":
|
||||
case "1":
|
||||
DefaultPixelFont = 1;
|
||||
_defaultPixelFont = 1;
|
||||
break;
|
||||
default:
|
||||
Log(string.Format("Unable to find font family: {0}", fontfamily));
|
||||
Log($"Unable to find font family: {fontfamily}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawBezier",
|
||||
"Draws a Bezier curve using the table of coordinates provided in the given color"
|
||||
)]
|
||||
[LuaMethodAttributes("drawBezier", "Draws a Bezier curve using the table of coordinates provided in the given color")]
|
||||
public void DrawBezier(LuaTable points, Color color)
|
||||
{
|
||||
using (var g = GetGraphics())
|
||||
|
@ -249,9 +214,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawBox",
|
||||
"Draws a rectangle on screen from x1/y1 to x2/y2. Same as drawRectangle except it receives two points intead of a point and width/height"
|
||||
)]
|
||||
"drawBox", "Draws a rectangle on screen from x1/y1 to x2/y2. Same as drawRectangle except it receives two points intead of a point and width/height")]
|
||||
public void DrawBox(int x, int y, int x2, int y2, Color? line = null, Color? background = null)
|
||||
{
|
||||
using (var g = GetGraphics())
|
||||
|
@ -278,9 +241,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
y -= y2;
|
||||
}
|
||||
|
||||
g.DrawRectangle(GetPen(line ?? DefaultForeground), x, y, x2, y2);
|
||||
g.DrawRectangle(GetPen(line ?? _defaultForeground), x, y, x2, y2);
|
||||
|
||||
var bg = background ?? DefaultBackground;
|
||||
var bg = background ?? _defaultBackground;
|
||||
if (bg.HasValue)
|
||||
{
|
||||
g.FillRectangle(GetBrush(bg.Value), x + 1, y + 1, x2 - 1, y2 - 1);
|
||||
|
@ -295,23 +258,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawEllipse",
|
||||
"Draws an ellipse at the given coordinates and the given width and height. Line is the color of the ellipse. Background is the optional fill color"
|
||||
)]
|
||||
"drawEllipse", "Draws an ellipse at the given coordinates and the given width and height. Line is the color of the ellipse. Background is the optional fill color")]
|
||||
public void DrawEllipse(int x, int y, int width, int height, Color? line = null, Color? background = null)
|
||||
{
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
try
|
||||
{
|
||||
var bg = background ?? DefaultBackground;
|
||||
var bg = background ?? _defaultBackground;
|
||||
if (bg.HasValue)
|
||||
{
|
||||
var brush = GetBrush(bg.Value);
|
||||
g.FillEllipse(brush, x, y, width, height);
|
||||
}
|
||||
|
||||
g.DrawEllipse(GetPen(line ?? DefaultForeground), x, y, width, height);
|
||||
g.DrawEllipse(GetPen(line ?? _defaultForeground), x, y, width, height);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -322,9 +283,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawIcon",
|
||||
"draws an Icon (.ico) file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly"
|
||||
)]
|
||||
"drawIcon", "draws an Icon (.ico) file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly")]
|
||||
public void DrawIcon(string path, int x, int y, int? width = null, int? height = null)
|
||||
{
|
||||
using (var g = GetGraphics())
|
||||
|
@ -350,13 +309,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, Image> ImageCache = new Dictionary<string, Image>();
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawImage",
|
||||
"draws an image file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly"
|
||||
)]
|
||||
public void DrawImage(string path, int x, int y, int? width = null, int? height = null)
|
||||
"drawImage", "draws an image file from the given path at the given coordinate. width and height are optional. If specified, it will resize the image accordingly")]
|
||||
public void DrawImage(string path, int x, int y, int? width = null, int? height = null, bool cache = true)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
|
@ -367,14 +322,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
using (var g = GetGraphics())
|
||||
{
|
||||
Image img;
|
||||
if (ImageCache.ContainsKey(path))
|
||||
if (_imageCache.ContainsKey(path))
|
||||
{
|
||||
img = ImageCache[path];
|
||||
img = _imageCache[path];
|
||||
}
|
||||
else
|
||||
{
|
||||
img = Image.FromFile(path);
|
||||
ImageCache.Add(path, img);
|
||||
if (cache)
|
||||
{
|
||||
_imageCache.Add(path, img);
|
||||
}
|
||||
}
|
||||
|
||||
g.DrawImage(img, x, y, width ?? img.Width, height ?? img.Height);
|
||||
|
@ -382,9 +340,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawImageRegion",
|
||||
"draws a given region of an image file from the given path at the given coordinate, and optionally with the given size"
|
||||
)]
|
||||
"clearImageCache", "clears the image cache that is built up by using gui.drawImage, also releases the file handle for cached images")]
|
||||
public void ClearImageCache()
|
||||
{
|
||||
foreach (var image in _imageCache)
|
||||
{
|
||||
image.Value.Dispose();
|
||||
}
|
||||
|
||||
_imageCache.Clear();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawImageRegion", "draws a given region of an image file from the given path at the given coordinate, and optionally with the given size")]
|
||||
public void DrawImageRegion(string path, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int? dest_width = null, int? dest_height = null)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
|
@ -396,50 +364,40 @@ namespace BizHawk.Client.EmuHawk
|
|||
using (var g = GetGraphics())
|
||||
{
|
||||
Image img;
|
||||
if (ImageCache.ContainsKey(path))
|
||||
if (_imageCache.ContainsKey(path))
|
||||
{
|
||||
img = ImageCache[path];
|
||||
img = _imageCache[path];
|
||||
}
|
||||
else
|
||||
{
|
||||
img = Image.FromFile(path);
|
||||
ImageCache.Add(path, img);
|
||||
_imageCache.Add(path, img);
|
||||
}
|
||||
|
||||
var dest_rect = new Rectangle(dest_x, dest_y, (dest_width ?? source_width), (dest_height ?? source_height));
|
||||
var destRect = new Rectangle(dest_x, dest_y, dest_width ?? source_width, dest_height ?? source_height);
|
||||
|
||||
g.DrawImage(img, dest_rect, source_x, source_y, source_width, source_height, GraphicsUnit.Pixel);
|
||||
g.DrawImage(img, destRect, source_x, source_y, source_width, source_height, GraphicsUnit.Pixel);
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawLine",
|
||||
"Draws a line from the first coordinate pair to the 2nd. Color is optional (if not specified it will be drawn black)"
|
||||
)]
|
||||
"drawLine", "Draws a line from the first coordinate pair to the 2nd. Color is optional (if not specified it will be drawn black)")]
|
||||
public void DrawLine(int x1, int y1, int x2, int y2, Color? color = null)
|
||||
{
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
g.DrawLine(GetPen(color ?? DefaultForeground), x1, y1, x2, y2);
|
||||
g.DrawLine(GetPen(color ?? _defaultForeground), x1, y1, x2, y2);
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawAxis",
|
||||
"Draws an axis of the specified size at the coordinate pair.)"
|
||||
)]
|
||||
|
||||
[LuaMethodAttributes("drawAxis", "Draws an axis of the specified size at the coordinate pair.)")]
|
||||
public void DrawAxis(int x, int y, int size, Color? color = null)
|
||||
{
|
||||
DrawLine(x + size, y, x - size, y, color);
|
||||
DrawLine(x, y + size, x, y - size, color);
|
||||
}
|
||||
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawPie",
|
||||
"draws a Pie shape at the given coordinates and the given width and height"
|
||||
)]
|
||||
[LuaMethodAttributes("drawPie", "draws a Pie shape at the given coordinates and the given width and height")]
|
||||
public void DrawPie(
|
||||
int x,
|
||||
int y,
|
||||
|
@ -452,29 +410,26 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
var bg = background ?? DefaultBackground;
|
||||
var bg = background ?? _defaultBackground;
|
||||
if (bg.HasValue)
|
||||
{
|
||||
var brush = GetBrush(bg.Value);
|
||||
g.FillPie(brush, x, y, width, height, startangle, sweepangle);
|
||||
}
|
||||
|
||||
g.DrawPie(GetPen(line ?? DefaultForeground), x + 1, y + 1, width - 1, height - 1, startangle, sweepangle);
|
||||
|
||||
g.DrawPie(GetPen(line ?? _defaultForeground), x + 1, y + 1, width - 1, height - 1, startangle, sweepangle);
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawPixel",
|
||||
"Draws a single pixel at the given coordinates in the given color. Color is optional (if not specified it will be drawn black)"
|
||||
)]
|
||||
"drawPixel", "Draws a single pixel at the given coordinates in the given color. Color is optional (if not specified it will be drawn black)")]
|
||||
public void DrawPixel(int x, int y, Color? color = null)
|
||||
{
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
try
|
||||
{
|
||||
g.DrawLine(GetPen(color ?? DefaultForeground), x, y, x + 0.1F, y);
|
||||
g.DrawLine(GetPen(color ?? _defaultForeground), x, y, x + 0.1F, y);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -484,9 +439,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawPolygon",
|
||||
"Draws a polygon using the table of coordinates specified in points. This should be a table of tables(each of size 2). Line is the color of the polygon. Background is the optional fill color"
|
||||
)]
|
||||
"drawPolygon", "Draws a polygon using the table of coordinates specified in points. This should be a table of tables(each of size 2). Line is the color of the polygon. Background is the optional fill color")]
|
||||
public void DrawPolygon(LuaTable points, Color? line = null, Color? background = null)
|
||||
{
|
||||
using (var g = GetGraphics())
|
||||
|
@ -501,8 +454,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
i++;
|
||||
}
|
||||
|
||||
g.DrawPolygon(GetPen(line ?? DefaultForeground), pointsArr);
|
||||
var bg = background ?? DefaultBackground;
|
||||
g.DrawPolygon(GetPen(line ?? _defaultForeground), pointsArr);
|
||||
var bg = background ?? _defaultBackground;
|
||||
if (bg.HasValue)
|
||||
{
|
||||
g.FillPolygon(GetBrush(bg.Value), pointsArr);
|
||||
|
@ -516,15 +469,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawRectangle",
|
||||
"Draws a rectangle at the given coordinate and the given width and height. Line is the color of the box. Background is the optional fill color"
|
||||
)]
|
||||
"drawRectangle", "Draws a rectangle at the given coordinate and the given width and height. Line is the color of the box. Background is the optional fill color")]
|
||||
public void DrawRectangle(int x, int y, int width, int height, Color? line = null, Color? background = null)
|
||||
{
|
||||
using (var g = GetGraphics())
|
||||
{
|
||||
g.DrawRectangle(GetPen(line ?? DefaultForeground), x, y, width, height);
|
||||
var bg = background ?? DefaultBackground;
|
||||
g.DrawRectangle(GetPen(line ?? _defaultForeground), x, y, width, height);
|
||||
var bg = background ?? _defaultBackground;
|
||||
if (bg.HasValue)
|
||||
{
|
||||
g.FillRectangle(GetBrush(bg.Value), x + 1, y + 1, width - 1, height - 1);
|
||||
|
@ -532,10 +483,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawString",
|
||||
"Alias of gui.drawText()"
|
||||
)]
|
||||
[LuaMethodAttributes("drawString", "Alias of gui.drawText()")]
|
||||
public void DrawString(
|
||||
int x,
|
||||
int y,
|
||||
|
@ -552,9 +500,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"drawText",
|
||||
"Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. A fontfamily can be specified and is monospace generic if none is specified (font family options are the same as the .NET FontFamily class). The fontsize default is 12. The default font style is regular. Font style options are regular, bold, italic, strikethrough, underline. Horizontal alignment options are left (default), center, or right. Vertical alignment options are bottom (default), middle, or top. Alignment options specify which ends of the text will be drawn at the x and y coordinates."
|
||||
)]
|
||||
"drawText", "Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. A fontfamily can be specified and is monospace generic if none is specified (font family options are the same as the .NET FontFamily class). The fontsize default is 12. The default font style is regular. Font style options are regular, bold, italic, strikethrough, underline. Horizontal alignment options are left (default), center, or right. Vertical alignment options are bottom (default), middle, or top. Alignment options specify which ends of the text will be drawn at the x and y coordinates.")]
|
||||
public void DrawText(
|
||||
int x,
|
||||
int y,
|
||||
|
@ -602,7 +548,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
// The text isn't written out using GenericTypographic, so measuring it using GenericTypographic seemed to make it worse.
|
||||
// And writing it out with GenericTypographic just made it uglier. :p
|
||||
StringFormat f = new StringFormat(StringFormat.GenericDefault);
|
||||
var f = new StringFormat(StringFormat.GenericDefault);
|
||||
var font = new Font(family, fontsize ?? 12, fstyle, GraphicsUnit.Pixel);
|
||||
Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize();
|
||||
if (horizalign != null)
|
||||
|
@ -620,6 +566,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vertalign != null)
|
||||
{
|
||||
switch (vertalign.ToLower())
|
||||
|
@ -635,10 +582,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle rect = new Rectangle(new Point(x, y), sizeOfText);
|
||||
g.FillRectangle(GetBrush(backcolor ?? DefaultTextBackground.Value), rect);
|
||||
g.FillRectangle(GetBrush(backcolor ?? _defaultTextBackground.Value), rect);
|
||||
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
g.DrawString(message, font, GetBrush(forecolor ?? DefaultForeground), x, y);
|
||||
g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -649,8 +597,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodAttributes(
|
||||
"pixelText",
|
||||
"Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. Two font families are available, \"fceux\" and \"gens\" (or \"0\" and \"1\" respectively), both are monospace and have the same size as in the emulaors they've been taken from. If no font family is specified, it uses \"gens\" font, unless that's overridden via gui.defaultPixelFont()"
|
||||
)]
|
||||
"Draws the given message in the emulator screen space (like all draw functions) at the given x,y coordinates and the given color. The default color is white. Two font families are available, \"fceux\" and \"gens\" (or \"0\" and \"1\" respectively), both are monospace and have the same size as in the emulaors they've been taken from. If no font family is specified, it uses \"gens\" font, unless that's overridden via gui.defaultPixelFont()")]
|
||||
public void DrawText(
|
||||
int x,
|
||||
int y,
|
||||
|
@ -666,7 +613,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var index = 0;
|
||||
if (string.IsNullOrEmpty(fontfamily))
|
||||
{
|
||||
index = DefaultPixelFont;
|
||||
index = _defaultPixelFont;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -681,20 +628,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
index = 1;
|
||||
break;
|
||||
default:
|
||||
Log(string.Format("Unable to find font family: {0}", fontfamily));
|
||||
Log($"Unable to find font family: {fontfamily}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
StringFormat f = new StringFormat(StringFormat.GenericTypographic)
|
||||
|
||||
var f = new StringFormat(StringFormat.GenericTypographic)
|
||||
{
|
||||
FormatFlags = StringFormatFlags.MeasureTrailingSpaces
|
||||
};
|
||||
var font = new Font(GlobalWin.DisplayManager.CustomFonts.Families[index], 8, FontStyle.Regular, GraphicsUnit.Pixel);
|
||||
Size sizeOfText = g.MeasureString(message, font, 0, f).ToSize();
|
||||
Rectangle rect = new Rectangle(new Point(x, y), sizeOfText + new Size(1, 0));
|
||||
g.FillRectangle(GetBrush(backcolor ?? DefaultTextBackground.Value), rect);
|
||||
var rect = new Rectangle(new Point(x, y), sizeOfText + new Size(1, 0));
|
||||
g.FillRectangle(GetBrush(backcolor ?? _defaultTextBackground.Value), rect);
|
||||
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
g.DrawString(message, font, GetBrush(forecolor ?? DefaultForeground), x, y);
|
||||
g.DrawString(message, font, GetBrush(forecolor ?? _defaultForeground), x, y);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -704,9 +652,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"text",
|
||||
"Displays the given text on the screen at the given coordinates. Optional Foreground color. The optional anchor flag anchors the text to one of the four corners. Anchor flag parameters: topleft, topright, bottomleft, bottomright"
|
||||
)]
|
||||
"text", "Displays the given text on the screen at the given coordinates. Optional Foreground color. The optional anchor flag anchors the text to one of the four corners. Anchor flag parameters: topleft, topright, bottomleft, bottomright")]
|
||||
public void Text(
|
||||
int x,
|
||||
int y,
|
||||
|
@ -747,10 +693,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
GlobalWin.OSD.AddGUIText(message, x, y, Color.Black, forecolor ?? Color.White, a);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"createcanvas",
|
||||
"Creates a canvas of the given size."
|
||||
)]
|
||||
[LuaMethodAttributes("createcanvas", "Creates a canvas of the given size.")]
|
||||
public LuaTable Text(int width, int height)
|
||||
{
|
||||
var canvas = new LuaCanvas(width, height);
|
||||
|
|
|
@ -15,12 +15,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
public InputLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
public override string Name { get { return "input"; } }
|
||||
public override string Name => "input";
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"get",
|
||||
"Returns a lua table of all the buttons the user is currently pressing on their keyboard and gamepads\nAll buttons that are pressed have their key values set to true; all others remain nil."
|
||||
)]
|
||||
"get", "Returns a lua table of all the buttons the user is currently pressing on their keyboard and gamepads\nAll buttons that are pressed have their key values set to true; all others remain nil.")]
|
||||
public LuaTable Get()
|
||||
{
|
||||
var buttons = Lua.NewTable();
|
||||
|
@ -33,13 +31,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"getmouse",
|
||||
"Returns a lua table of the mouse X/Y coordinates and button states. Table keys are X, Y, Left, Middle, Right, XButton1, XButton2, Wheel."
|
||||
)]
|
||||
"getmouse", "Returns a lua table of the mouse X/Y coordinates and button states. Table keys are X, Y, Left, Middle, Right, XButton1, XButton2, Wheel.")]
|
||||
public LuaTable GetMouse()
|
||||
{
|
||||
var buttons = Lua.NewTable();
|
||||
//TODO - need to specify whether in "emu" or "native" coordinate space.
|
||||
|
||||
// TODO - need to specify whether in "emu" or "native" coordinate space.
|
||||
var p = GlobalWin.DisplayManager.UntransformPoint(Control.MousePosition);
|
||||
buttons["X"] = p.X;
|
||||
buttons["Y"] = p.Y;
|
||||
|
|
|
@ -15,17 +15,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
public SavestateLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
public override string Name { get { return "savestate"; } }
|
||||
public override string Name => "savestate";
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"load",
|
||||
"Loads a savestate with the given path"
|
||||
)]
|
||||
[LuaMethodAttributes("load", "Loads a savestate with the given path")]
|
||||
public void Load(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Log(string.Format("could not find file: {0}", path));
|
||||
Log($"could not find file: {path}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -33,10 +30,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"loadslot",
|
||||
"Loads the savestate at the given slot number (must be an integer between 0 and 9)"
|
||||
)]
|
||||
[LuaMethodAttributes("loadslot", "Loads the savestate at the given slot number (must be an integer between 0 and 9)")]
|
||||
public void LoadSlot(int slotNum)
|
||||
{
|
||||
if (slotNum >= 0 && slotNum <= 9)
|
||||
|
@ -45,19 +39,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"save",
|
||||
"Saves a state at the given path"
|
||||
)]
|
||||
[LuaMethodAttributes("save", "Saves a state at the given path")]
|
||||
public void Save(string path)
|
||||
{
|
||||
GlobalWin.MainForm.SaveState(path, path, true);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"saveslot",
|
||||
"Saves a state at the given save slot (must be an integer between 0 and 9)"
|
||||
)]
|
||||
[LuaMethodAttributes("saveslot", "Saves a state at the given save slot (must be an integer between 0 and 9)")]
|
||||
public void SaveSlot(int slotNum)
|
||||
{
|
||||
if (slotNum >= 0 && slotNum <= 9)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using LuaInterface;
|
||||
using System.Drawing;
|
||||
|
||||
using LuaInterface;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
[Description("A library for manipulating the Tastudio dialog of the EmuHawk client")]
|
||||
|
@ -17,58 +17,38 @@ namespace BizHawk.Client.EmuHawk
|
|||
public TastudioLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||
: base(lua, logOutputCallback) { }
|
||||
|
||||
public override string Name { get { return "tastudio"; } }
|
||||
public override string Name => "tastudio";
|
||||
|
||||
private TAStudio Tastudio
|
||||
{
|
||||
get
|
||||
{
|
||||
return GlobalWin.Tools.Get<TAStudio>() as TAStudio;
|
||||
}
|
||||
}
|
||||
private TAStudio Tastudio => GlobalWin.Tools.Get<TAStudio>() as TAStudio;
|
||||
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"engaged",
|
||||
"returns whether or not tastudio is currently engaged (active)"
|
||||
)]
|
||||
[LuaMethodAttributes("engaged", "returns whether or not tastudio is currently engaged (active)")]
|
||||
public bool Engaged()
|
||||
{
|
||||
return GlobalWin.Tools.Has<TAStudio>(); // TODO: eventually tastudio should have an engaged flag
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"getrecording",
|
||||
"returns whether or not TAStudio is in recording mode"
|
||||
)]
|
||||
[LuaMethodAttributes("getrecording", "returns whether or not TAStudio is in recording mode")]
|
||||
public bool GetRecording()
|
||||
{
|
||||
return Tastudio.TasPlaybackBox.RecordingMode;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setrecording",
|
||||
"sets the recording mode on/off depending on the parameter"
|
||||
)]
|
||||
[LuaMethodAttributes("setrecording", "sets the recording mode on/off depending on the parameter")]
|
||||
public void SetRecording(bool val)
|
||||
{
|
||||
if (Tastudio.TasPlaybackBox.RecordingMode != val)
|
||||
{
|
||||
Tastudio.ToggleReadOnly();
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"togglerecording",
|
||||
"toggles tastudio recording mode on/off depending on its current state"
|
||||
)]
|
||||
[LuaMethodAttributes("togglerecording", "toggles tastudio recording mode on/off depending on its current state")]
|
||||
public void SetRecording()
|
||||
{
|
||||
Tastudio.ToggleReadOnly();
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setbranchtext",
|
||||
"adds the given message to the existing branch, or to the branch that will be created next if branch index is not specified"
|
||||
)]
|
||||
[LuaMethodAttributes("setbranchtext", "adds the given message to the existing branch, or to the branch that will be created next if branch index is not specified")]
|
||||
public void SetBranchText(string text, int? index = null)
|
||||
{
|
||||
if (index != null)
|
||||
|
@ -81,10 +61,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"getmarker",
|
||||
"returns the marker text at the given frame, or an empty string if there is no marker for the given frame"
|
||||
)]
|
||||
[LuaMethodAttributes("getmarker", "returns the marker text at the given frame, or an empty string if there is no marker for the given frame")]
|
||||
public string GetMarker(int frame)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -99,10 +76,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return "";
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"removemarker",
|
||||
"if there is a marker for the given frame, it will be removed"
|
||||
)]
|
||||
[LuaMethodAttributes("removemarker", "if there is a marker for the given frame, it will be removed")]
|
||||
public void RemoveMarker(int frame)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -116,10 +90,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setmarker",
|
||||
"Adds or sets a marker at the given frame, with an optional message"
|
||||
)]
|
||||
[LuaMethodAttributes("setmarker", "Adds or sets a marker at the given frame, with an optional message")]
|
||||
public void SetMarker(int frame, string message = null)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -137,10 +108,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"islag",
|
||||
"Returns whether or not the given frame was a lag frame, null if unknown"
|
||||
)]
|
||||
[LuaMethodAttributes("islag", "Returns whether or not the given frame was a lag frame, null if unknown")]
|
||||
public bool? IsLag(int frame)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -154,10 +122,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return null;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setlag",
|
||||
"Sets the lag information for the given frame, if the frame does not exist in the lag log, it will be added. If the value is null, the lag information for that frame will be removed"
|
||||
)]
|
||||
[LuaMethodAttributes("setlag", "Sets the lag information for the given frame, if the frame does not exist in the lag log, it will be added. If the value is null, the lag information for that frame will be removed")]
|
||||
public void SetLag(int frame, bool? value)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -166,10 +131,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"hasstate",
|
||||
"Returns whether or not the given frame has a savestate associated with it"
|
||||
)]
|
||||
[LuaMethodAttributes("hasstate", "Returns whether or not the given frame has a savestate associated with it")]
|
||||
public bool HasState(int frame)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -183,33 +145,36 @@ namespace BizHawk.Client.EmuHawk
|
|||
return false;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setplayback",
|
||||
"Seeks the given frame (a number) or marker (a string)"
|
||||
)]
|
||||
[LuaMethodAttributes("setplayback", "Seeks the given frame (a number) or marker (a string)")]
|
||||
public void SetPlayback(object frame)
|
||||
{
|
||||
if (Engaged())
|
||||
{
|
||||
int f;
|
||||
if (frame is double) f = (int)(double)frame;
|
||||
if (frame is double)
|
||||
{
|
||||
f = (int)(double)frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = Tastudio.CurrentTasMovie.Markers.FindIndex((string)frame);
|
||||
if (f == -1) return;
|
||||
if (f == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
f = Tastudio.CurrentTasMovie.Markers[f].Frame;
|
||||
}
|
||||
if (f < Tastudio.CurrentTasMovie.InputLogLength && f>=0)
|
||||
|
||||
if (f < Tastudio.CurrentTasMovie.InputLogLength && f >= 0)
|
||||
{
|
||||
Tastudio.GoToFrame(f,true);
|
||||
Tastudio.GoToFrame(f, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"onqueryitembg",
|
||||
"called during the background draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)"
|
||||
)]
|
||||
"onqueryitembg", "called during the background draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)")]
|
||||
public void OnQueryItemBg(LuaFunction luaf)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -230,9 +195,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"onqueryitemtext",
|
||||
"called during the text draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)"
|
||||
)]
|
||||
"onqueryitemtext", "called during the text draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)")]
|
||||
public void OnQueryItemText(LuaFunction luaf)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -241,23 +204,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var result = luaf.Call(index, name);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
if (result[0] != null)
|
||||
{
|
||||
return result[0].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
return (string)null;
|
||||
return result?[0]?.ToString();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"onqueryitemicon",
|
||||
"called during the icon draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)"
|
||||
)]
|
||||
"onqueryitemicon", "called during the icon draw event of the tastudio listview. luaf must be a function that takes 2 params: index, column. The first is the integer row index of the listview, and the 2nd is the string column name. luaf should return a value that can be parsed into a .NET Color object (string color name, or integer value)")]
|
||||
public void OnQueryItemIcon(LuaFunction luaf)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -265,17 +218,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
Tastudio.QueryItemIconCallback = (int index, string name) =>
|
||||
{
|
||||
var result = luaf.Call(index, name);
|
||||
if (result != null)
|
||||
if (result?[0] != null)
|
||||
{
|
||||
if (result[0] != null)
|
||||
{
|
||||
string path = result[0].ToString();
|
||||
Icon icon = new Icon(path);
|
||||
if (icon != null)
|
||||
{
|
||||
return icon.ToBitmap();
|
||||
}
|
||||
}
|
||||
string path = result[0].ToString();
|
||||
Icon icon = new Icon(path);
|
||||
return icon.ToBitmap();
|
||||
}
|
||||
|
||||
return (Bitmap)null;
|
||||
|
@ -283,10 +230,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"ongreenzoneinvalidated",
|
||||
"called whenever the greenzone is invalidated and returns the first frame that was invalidated"
|
||||
)]
|
||||
[LuaMethodAttributes("ongreenzoneinvalidated", "called whenever the greenzone is invalidated and returns the first frame that was invalidated")]
|
||||
public void OnGreenzoneInvalidated(LuaFunction luaf)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -298,10 +242,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"getselection",
|
||||
"gets the currently selected frames"
|
||||
)]
|
||||
[LuaMethodAttributes("getselection", "gets the currently selected frames")]
|
||||
public LuaTable GetSelection()
|
||||
{
|
||||
LuaTable table = Lua.NewTable();
|
||||
|
@ -319,10 +260,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return table;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"insertframes",
|
||||
"inserts the given number of blank frames at the given insertion frame"
|
||||
)]
|
||||
[LuaMethodAttributes("insertframes", "inserts the given number of blank frames at the given insertion frame")]
|
||||
public void InsertNumFrames(int insertionFrame, int numberOfFrames)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -333,15 +271,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
Log(insertionFrame.ToString() + " is out of range");
|
||||
Log(insertionFrame + " is out of range");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"deleteframes",
|
||||
"deletes the given number of blank frames beginning at the given frame"
|
||||
)]
|
||||
[LuaMethodAttributes("deleteframes", "deletes the given number of blank frames beginning at the given frame")]
|
||||
public void DeleteFrames(int beginningFrame, int numberOfFrames)
|
||||
{
|
||||
if (Engaged())
|
||||
|
@ -352,7 +287,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
Log(beginningFrame.ToString() + " is out of range");
|
||||
Log(beginningFrame + " is out of range");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,37 +15,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public class EmuLuaLibrary
|
||||
{
|
||||
private readonly Dictionary<Type, LuaLibraryBase> Libraries = new Dictionary<Type, LuaLibraryBase>();
|
||||
|
||||
private Lua _lua = new Lua();
|
||||
private Lua _currThread;
|
||||
|
||||
public EmuLuaLibrary()
|
||||
{
|
||||
Docs = new LuaDocumentation();
|
||||
_lua["keepalives"] = _lua.NewTable();
|
||||
}
|
||||
|
||||
private FormsLuaLibrary FormsLibrary
|
||||
{
|
||||
get { return (FormsLuaLibrary)Libraries[typeof(FormsLuaLibrary)]; }
|
||||
}
|
||||
|
||||
private EventLuaLibrary EventsLibrary
|
||||
{
|
||||
get { return (EventLuaLibrary)Libraries[typeof(EventLuaLibrary)]; }
|
||||
}
|
||||
|
||||
private EmulatorLuaLibrary EmulatorLuaLibrary
|
||||
{
|
||||
get { return (EmulatorLuaLibrary)Libraries[typeof(EmulatorLuaLibrary)]; }
|
||||
}
|
||||
|
||||
public GuiLuaLibrary GuiLibrary
|
||||
{
|
||||
get { return (GuiLuaLibrary)Libraries[typeof(GuiLuaLibrary)]; }
|
||||
}
|
||||
|
||||
public EmuLuaLibrary(IEmulatorServiceProvider serviceProvider)
|
||||
: this()
|
||||
{
|
||||
|
@ -67,8 +42,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
.GetTypes()
|
||||
.Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
|
||||
.Where(t => t.IsSealed)
|
||||
.Where(t => ServiceInjector.IsAvailable(serviceProvider, t))
|
||||
);
|
||||
.Where(t => ServiceInjector.IsAvailable(serviceProvider, t)));
|
||||
|
||||
foreach (var lib in libs)
|
||||
{
|
||||
|
@ -96,7 +70,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
// Add LuaCanvas to Docs
|
||||
Type luaCanvas = typeof(LuaCanvas);
|
||||
var luaAttr = typeof(LuaMethodAttributes);
|
||||
|
||||
var methods = luaCanvas
|
||||
.GetMethods()
|
||||
|
@ -104,13 +77,31 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
foreach (var method in methods)
|
||||
{
|
||||
var luaMethodAttr = method.GetCustomAttributes(luaAttr, false).First() as LuaMethodAttributes;
|
||||
var luaName = "(Canvas)." + luaMethodAttr.Name;
|
||||
|
||||
Docs.Add(new LibraryFunction(nameof(LuaCanvas), luaCanvas.Description(), method));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRebootingCore { get; set; } // pretty hacky.. we dont want a lua script to be able to restart itself by rebooting the core
|
||||
|
||||
private readonly Dictionary<Type, LuaLibraryBase> Libraries = new Dictionary<Type, LuaLibraryBase>();
|
||||
public LuaFileList ScriptList { get; } = new LuaFileList();
|
||||
|
||||
public IEnumerable<LuaFile> RunningScripts
|
||||
{
|
||||
get { return ScriptList.Where(lf => lf.Enabled); }
|
||||
}
|
||||
|
||||
private Lua _lua = new Lua();
|
||||
private Lua _currThread;
|
||||
|
||||
private FormsLuaLibrary FormsLibrary => (FormsLuaLibrary)Libraries[typeof(FormsLuaLibrary)];
|
||||
|
||||
private EventLuaLibrary EventsLibrary => (EventLuaLibrary)Libraries[typeof(EventLuaLibrary)];
|
||||
|
||||
private EmulatorLuaLibrary EmulatorLuaLibrary => (EmulatorLuaLibrary)Libraries[typeof(EmulatorLuaLibrary)];
|
||||
|
||||
public GuiLuaLibrary GuiLibrary => (GuiLuaLibrary)Libraries[typeof(GuiLuaLibrary)];
|
||||
|
||||
public void Restart(IEmulatorServiceProvider newServiceProvider)
|
||||
{
|
||||
foreach (var lib in Libraries)
|
||||
|
@ -119,15 +110,28 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public LuaDocumentation Docs { get; private set; }
|
||||
public void StartLuaDrawing()
|
||||
{
|
||||
if (ScriptList.Any() && GuiLibrary.SurfaceIsNull)
|
||||
{
|
||||
GuiLibrary.DrawNew("emu");
|
||||
}
|
||||
}
|
||||
|
||||
public void EndLuaDrawing()
|
||||
{
|
||||
if (ScriptList.Any())
|
||||
{
|
||||
GuiLibrary.DrawFinish();
|
||||
}
|
||||
}
|
||||
|
||||
public LuaDocumentation Docs { get; }
|
||||
public bool IsRunning { get; set; }
|
||||
public EventWaitHandle LuaWait { get; private set; }
|
||||
public bool FrameAdvanceRequested { get; private set; }
|
||||
|
||||
public LuaFunctionList RegisteredFunctions
|
||||
{
|
||||
get { return EventsLibrary.RegisteredFunctions; }
|
||||
}
|
||||
public LuaFunctionList RegisteredFunctions => EventsLibrary.RegisteredFunctions;
|
||||
|
||||
public void WindowClosed(IntPtr handle)
|
||||
{
|
||||
|
@ -196,7 +200,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
var execResult = script.Resume(0);
|
||||
|
||||
_lua.RunScheduledDisposes();
|
||||
//not sure how this is going to work out, so do this too
|
||||
|
||||
// not sure how this is going to work out, so do this too
|
||||
script.RunScheduledDisposes();
|
||||
|
||||
_currThread = null;
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -17,7 +11,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public bool IsInstalled(TextEditors editor)
|
||||
{
|
||||
switch(editor)
|
||||
switch (editor)
|
||||
{
|
||||
case TextEditors.Sublime2:
|
||||
return IsSublimeInstalled();
|
||||
|
@ -43,7 +37,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void InstallBizLua(TextEditors editor)
|
||||
{
|
||||
switch(editor)
|
||||
switch (editor)
|
||||
{
|
||||
case TextEditors.Sublime2:
|
||||
InstallBizLuaToSublime2();
|
||||
|
@ -56,10 +50,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
#endregion
|
||||
|
||||
private string AppDataFolder
|
||||
{
|
||||
get { return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); }
|
||||
}
|
||||
private string AppDataFolder => Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
|
||||
private bool IsSublimeInstalled()
|
||||
{
|
||||
|
|
|
@ -3,12 +3,12 @@ using System.Windows.Forms;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
class LuaButton : Button
|
||||
internal class LuaButton : Button
|
||||
{
|
||||
private void DoLuaClick(object sender, EventArgs e)
|
||||
{
|
||||
LuaWinform parent = Parent as LuaWinform;
|
||||
if (parent != null) parent.DoLuaEvent(Handle);
|
||||
parent?.DoLuaEvent(Handle);
|
||||
}
|
||||
|
||||
protected override void OnClick(EventArgs e)
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
[Description("Represents a canvas object returned by the gui.createcanvas() method")]
|
||||
public partial class LuaCanvas : Form
|
||||
{
|
||||
private Graphics graphics;
|
||||
private readonly Graphics _graphics;
|
||||
|
||||
public LuaCanvas(int width, int height)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
pictureBox.Width = width;
|
||||
pictureBox.Height = height;
|
||||
pictureBox.Image = new Bitmap(width, height);
|
||||
graphics = Graphics.FromImage(pictureBox.Image);
|
||||
_graphics = Graphics.FromImage(pictureBox.Image);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes("SetTitle", "Sets the canvas window title")]
|
||||
|
@ -29,7 +29,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
[LuaMethodAttributes("Clear", "Clears the canvas")]
|
||||
public void Clear(Color color)
|
||||
{
|
||||
graphics.Clear(color);
|
||||
_graphics.Clear(color);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes("Refresh", "Redraws the canvas")]
|
||||
|
@ -46,11 +46,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (fill.HasValue)
|
||||
{
|
||||
var brush = new SolidBrush(fill.Value);
|
||||
graphics.FillRectangle(brush, x, y, width, height);
|
||||
_graphics.FillRectangle(brush, x, y, width, height);
|
||||
}
|
||||
|
||||
var pen = new Pen(outline.HasValue ? outline.Value : Color.Black);
|
||||
graphics.DrawRectangle(pen, x, y, width, height);
|
||||
_graphics.DrawRectangle(pen, x, y, width, height);
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
|
@ -88,8 +88,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
var font = new Font(family, fontsize ?? 12, fstyle, GraphicsUnit.Pixel);
|
||||
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
graphics.DrawString(message, font, new SolidBrush(color ?? Color.White), x, y);
|
||||
_graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
_graphics.DrawString(message, font, new SolidBrush(color ?? Color.White), x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void DoLuaClick(object sender, EventArgs e)
|
||||
{
|
||||
var parent = Parent as LuaWinform;
|
||||
if (parent != null)
|
||||
{
|
||||
parent.DoLuaEvent(Handle);
|
||||
}
|
||||
parent?.DoLuaEvent(Handle);
|
||||
}
|
||||
|
||||
protected override void OnClick(EventArgs e)
|
||||
|
|
|
@ -19,15 +19,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
[RequiredService]
|
||||
private IEmulator Emulator { get; set; }
|
||||
|
||||
private readonly LuaFileList _luaList;
|
||||
private bool _sortReverse;
|
||||
private string _lastColumnSorted;
|
||||
|
||||
private readonly List<string> _consoleCommandHistory = new List<string>();
|
||||
private int _consoleCommandHistoryIndex = -1;
|
||||
|
||||
public bool IsRebootingCore { get; set; }
|
||||
|
||||
public ToolDialogSettings.ColumnList Columns { get; set; }
|
||||
|
||||
public class LuaConsoleSettings
|
||||
|
@ -52,11 +49,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
Settings = new LuaConsoleSettings();
|
||||
_sortReverse = false;
|
||||
_lastColumnSorted = "";
|
||||
_luaList = new LuaFileList
|
||||
{
|
||||
ChangedCallback = SessionChangedCallback,
|
||||
LoadCallback = ClearOutputWindow
|
||||
};
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
|
@ -92,7 +84,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private IEnumerable<LuaFile> SelectedItems
|
||||
{
|
||||
get { return LuaListView.SelectedIndices().Select(index => _luaList[index]); }
|
||||
get { return LuaListView.SelectedIndices().Select(index => LuaImp.ScriptList[index]); }
|
||||
}
|
||||
|
||||
private IEnumerable<LuaFile> SelectedFiles
|
||||
|
@ -122,9 +114,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void LuaConsole_Load(object sender, EventArgs e)
|
||||
{
|
||||
LuaImp.ScriptList.ChangedCallback = SessionChangedCallback;
|
||||
LuaImp.ScriptList.LoadCallback = ClearOutputWindow;
|
||||
|
||||
if (Global.Config.RecentLuaSession.AutoLoad && !Global.Config.RecentLuaSession.Empty)
|
||||
{
|
||||
LoadSessionFromRecent(Global.Config.RecentLuaSession.MostRecent);
|
||||
LoadSessionFromRecent(Global.Config.RecentLuaSession.MostRecent);
|
||||
}
|
||||
else if (Global.Config.RecentLua.AutoLoad)
|
||||
{
|
||||
|
@ -139,37 +134,50 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void Restart()
|
||||
{
|
||||
// Even if the lua console is self-rebooting from client.reboot_core() we still want to re-inject dependencies
|
||||
if (IsRebootingCore)
|
||||
List<LuaFile> runningScripts = new List<LuaFile>();
|
||||
|
||||
if (LuaImp != null) // Things we need to do with the existing LuaImp before we can make a new one
|
||||
{
|
||||
LuaImp.Restart(Emulator.ServiceProvider);
|
||||
return;
|
||||
}
|
||||
|
||||
if (LuaImp?.GuiLibrary != null && LuaImp.GuiLibrary.HasLuaSurface)
|
||||
{
|
||||
LuaImp.GuiLibrary.DrawFinish();
|
||||
}
|
||||
|
||||
var runningScripts = _luaList.Where(f => f.Enabled).ToList();
|
||||
|
||||
foreach (var file in runningScripts)
|
||||
{
|
||||
LuaImp.CallExitEvent(file.Thread);
|
||||
|
||||
var functions = LuaImp.RegisteredFunctions.Where(lf => lf.Lua == file.Thread).ToList();
|
||||
|
||||
foreach (var function in functions)
|
||||
if (LuaImp.IsRebootingCore == true)
|
||||
{
|
||||
LuaImp.RegisteredFunctions.Remove(function);
|
||||
// Even if the lua console is self-rebooting from client.reboot_core() we still want to re-inject dependencies
|
||||
LuaImp.Restart(Emulator.ServiceProvider);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateRegisteredFunctionsDialog();
|
||||
if (LuaImp.GuiLibrary != null && LuaImp.GuiLibrary.HasLuaSurface)
|
||||
{
|
||||
LuaImp.GuiLibrary.DrawFinish();
|
||||
}
|
||||
|
||||
file.Stop();
|
||||
runningScripts = LuaImp.RunningScripts.ToList();
|
||||
|
||||
foreach (var file in runningScripts)
|
||||
{
|
||||
LuaImp.CallExitEvent(file.Thread);
|
||||
|
||||
var functions = LuaImp.RegisteredFunctions
|
||||
.Where(lf => lf.Lua == file.Thread)
|
||||
.ToList();
|
||||
|
||||
foreach (var function in functions)
|
||||
{
|
||||
LuaImp.RegisteredFunctions.Remove(function);
|
||||
}
|
||||
|
||||
UpdateRegisteredFunctionsDialog();
|
||||
|
||||
file.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
var currentScripts = LuaImp?.ScriptList; // Temp fix for now
|
||||
LuaImp = new EmuLuaLibrary(Emulator.ServiceProvider);
|
||||
if (currentScripts != null)
|
||||
{
|
||||
LuaImp.ScriptList.AddRange(currentScripts);
|
||||
}
|
||||
|
||||
InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray());
|
||||
|
||||
foreach (var file in runningScripts)
|
||||
|
@ -202,7 +210,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void AddFileWatches()
|
||||
{
|
||||
_watches.Clear();
|
||||
foreach (var item in _luaList)
|
||||
foreach (var item in LuaImp.ScriptList)
|
||||
{
|
||||
var processedPath = PathManager.TryMakeRelative(item.Path);
|
||||
string pathToLoad = ProcessPath(processedPath);
|
||||
|
@ -246,8 +254,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var luaFile = new LuaFile("", processedPath);
|
||||
|
||||
_luaList.Add(luaFile);
|
||||
LuaListView.ItemCount = _luaList.Count;
|
||||
LuaImp.ScriptList.Add(luaFile);
|
||||
LuaListView.ItemCount = LuaImp.ScriptList.Count;
|
||||
Global.Config.RecentLua.Add(processedPath);
|
||||
|
||||
if (!Global.Config.DisableLuaScriptsOnLoad)
|
||||
|
@ -281,7 +289,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
foreach (var file in _luaList.Where(file => processedPath == file.Path && file.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad))
|
||||
foreach (var file in LuaImp.ScriptList.Where(file => processedPath == file.Path && file.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad))
|
||||
{
|
||||
file.Toggle();
|
||||
break;
|
||||
|
@ -295,7 +303,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void UpdateDialog()
|
||||
{
|
||||
LuaListView.ItemCount = _luaList.Count;
|
||||
LuaListView.ItemCount = LuaImp.ScriptList.Count;
|
||||
LuaListView.Refresh();
|
||||
UpdateNumberOfScripts();
|
||||
UpdateRegisteredFunctionsDialog();
|
||||
|
@ -303,7 +311,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RunLuaScripts()
|
||||
{
|
||||
foreach (var file in _luaList)
|
||||
foreach (var file in LuaImp.ScriptList)
|
||||
{
|
||||
if (!file.Enabled && file.Thread == null)
|
||||
{
|
||||
|
@ -334,8 +342,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void SessionChangedCallback()
|
||||
{
|
||||
OutputMessages.Text =
|
||||
(_luaList.Changes ? "* " : "") +
|
||||
Path.GetFileName(_luaList.Filename);
|
||||
(LuaImp.ScriptList.Changes ? "* " : "") +
|
||||
Path.GetFileName(LuaImp.ScriptList.Filename);
|
||||
}
|
||||
|
||||
private void LuaListView_QueryItemImage(int item, int subItem, out int imageIndex)
|
||||
|
@ -346,11 +354,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
if (_luaList[item].Paused)
|
||||
if (LuaImp.ScriptList[item].Paused)
|
||||
{
|
||||
imageIndex = 2;
|
||||
}
|
||||
else if (_luaList[item].Enabled)
|
||||
else if (LuaImp.ScriptList[item].Enabled)
|
||||
{
|
||||
imageIndex = 1;
|
||||
}
|
||||
|
@ -369,15 +377,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (column == 0)
|
||||
{
|
||||
if (_luaList[index].IsSeparator)
|
||||
if (LuaImp.ScriptList[index].IsSeparator)
|
||||
{
|
||||
color = BackColor;
|
||||
}
|
||||
else if (_luaList[index].Enabled && !_luaList[index].Paused)
|
||||
else if (LuaImp.ScriptList[index].Enabled && !LuaImp.ScriptList[index].Paused)
|
||||
{
|
||||
color = Color.LightCyan;
|
||||
}
|
||||
else if (_luaList[index].Enabled && _luaList[index].Paused)
|
||||
else if (LuaImp.ScriptList[index].Enabled && LuaImp.ScriptList[index].Paused)
|
||||
{
|
||||
color = Color.LightPink;
|
||||
}
|
||||
|
@ -391,11 +399,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
text = "";
|
||||
if (column == 0)
|
||||
{
|
||||
text = Path.GetFileNameWithoutExtension(_luaList[index].Path); // TODO: how about allow the user to name scripts?
|
||||
text = Path.GetFileNameWithoutExtension(LuaImp.ScriptList[index].Path); // TODO: how about allow the user to name scripts?
|
||||
}
|
||||
else if (column == 1)
|
||||
{
|
||||
text = DressUpRelative(_luaList[index].Path);
|
||||
text = DressUpRelative(LuaImp.ScriptList[index].Path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,8 +444,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var message = "";
|
||||
var total = SelectedFiles.Count();
|
||||
var active = _luaList.Count(file => file.Enabled);
|
||||
var paused = _luaList.Count(file => file.Enabled && file.Paused);
|
||||
var active = LuaImp.ScriptList.Count(file => file.Enabled);
|
||||
var paused = LuaImp.ScriptList.Count(file => file.Enabled && file.Paused);
|
||||
|
||||
if (total == 1)
|
||||
{
|
||||
|
@ -462,7 +470,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private bool LuaAlreadyInSession(string path)
|
||||
{
|
||||
return _luaList.Any(t => path == t.Path);
|
||||
return LuaImp.ScriptList.Any(t => path == t.Path);
|
||||
}
|
||||
|
||||
public void WriteToOutputWindow(string message)
|
||||
|
@ -496,11 +504,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public bool LoadLuaSession(string path)
|
||||
{
|
||||
var result = _luaList.LoadLuaSession(path);
|
||||
var result = LuaImp.ScriptList.LoadLuaSession(path);
|
||||
|
||||
RunLuaScripts();
|
||||
UpdateDialog();
|
||||
_luaList.Changes = false;
|
||||
LuaImp.ScriptList.Changes = false;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -511,7 +519,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// <param name="includeFrameWaiters">should frame waiters be waken up? only use this immediately before a frame of emulation</param>
|
||||
public void ResumeScripts(bool includeFrameWaiters)
|
||||
{
|
||||
if (!_luaList.Any())
|
||||
if (!LuaImp.ScriptList.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -521,7 +529,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
LuaImp.GuiLibrary.DrawNew("emu");
|
||||
}
|
||||
|
||||
foreach (var lf in _luaList.Where(l => l.Enabled && l.Thread != null && !l.Paused))
|
||||
foreach (var lf in LuaImp.ScriptList.Where(l => l.Enabled && l.Thread != null && !l.Paused))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -552,22 +560,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public void StartLuaDrawing()
|
||||
{
|
||||
if (_luaList.Any() && LuaImp.GuiLibrary.SurfaceIsNull)
|
||||
{
|
||||
LuaImp.GuiLibrary.DrawNew("emu");
|
||||
}
|
||||
}
|
||||
|
||||
public void EndLuaDrawing()
|
||||
{
|
||||
if (_luaList.Any())
|
||||
{
|
||||
LuaImp.GuiLibrary.DrawFinish();
|
||||
}
|
||||
}
|
||||
|
||||
public bool WaitOne(int timeout)
|
||||
{
|
||||
if (!IsHandleCreated || IsDisposed)
|
||||
|
@ -581,10 +573,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
private FileInfo GetSaveFileFromUser()
|
||||
{
|
||||
var sfd = new SaveFileDialog();
|
||||
if (!string.IsNullOrWhiteSpace(_luaList.Filename))
|
||||
if (!string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename))
|
||||
{
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(_luaList.Filename);
|
||||
sfd.InitialDirectory = Path.GetDirectoryName(_luaList.Filename);
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(LuaImp.ScriptList.Filename);
|
||||
sfd.InitialDirectory = Path.GetDirectoryName(LuaImp.ScriptList.Filename);
|
||||
}
|
||||
else if (Global.Game != null)
|
||||
{
|
||||
|
@ -613,22 +605,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
var file = GetSaveFileFromUser();
|
||||
if (file != null)
|
||||
{
|
||||
_luaList.SaveSession(file.FullName);
|
||||
OutputMessages.Text = Path.GetFileName(_luaList.Filename) + " saved.";
|
||||
LuaImp.ScriptList.SaveSession(file.FullName);
|
||||
OutputMessages.Text = Path.GetFileName(LuaImp.ScriptList.Filename) + " saved.";
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadSessionFromRecent(string path)
|
||||
{
|
||||
var doload = true;
|
||||
if (_luaList.Changes)
|
||||
if (LuaImp.ScriptList.Changes)
|
||||
{
|
||||
doload = AskSaveChanges();
|
||||
}
|
||||
|
||||
if (doload)
|
||||
{
|
||||
if (!_luaList.LoadLuaSession(path))
|
||||
if (!LuaImp.ScriptList.LoadLuaSession(path))
|
||||
{
|
||||
Global.Config.RecentLuaSession.HandleLoadError(path);
|
||||
}
|
||||
|
@ -636,7 +628,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
RunLuaScripts();
|
||||
UpdateDialog();
|
||||
_luaList.Changes = false;
|
||||
LuaImp.ScriptList.Changes = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,16 +637,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public bool AskSaveChanges()
|
||||
{
|
||||
if (_luaList.Changes && !string.IsNullOrEmpty(_luaList.Filename))
|
||||
if (LuaImp.ScriptList.Changes && !string.IsNullOrEmpty(LuaImp.ScriptList.Filename))
|
||||
{
|
||||
GlobalWin.Sound.StopSound();
|
||||
var result = MessageBox.Show("Save changes to session?", "Lua Console", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
|
||||
GlobalWin.Sound.StartSound();
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_luaList.Filename))
|
||||
if (!string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename))
|
||||
{
|
||||
_luaList.SaveSession();
|
||||
LuaImp.ScriptList.SaveSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -666,7 +658,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (result == DialogResult.No)
|
||||
{
|
||||
_luaList.Changes = false;
|
||||
LuaImp.ScriptList.Changes = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -693,7 +685,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
SaveSessionMenuItem.Enabled = _luaList.Changes;
|
||||
SaveSessionMenuItem.Enabled = LuaImp.ScriptList.Changes;
|
||||
}
|
||||
|
||||
private void RecentSessionsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
|
@ -712,11 +704,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void NewSessionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var result = !_luaList.Changes || AskSaveChanges();
|
||||
var result = !LuaImp.ScriptList.Changes || AskSaveChanges();
|
||||
|
||||
if (result)
|
||||
{
|
||||
_luaList.Clear();
|
||||
LuaImp.ScriptList.Clear();
|
||||
ClearOutputWindow();
|
||||
UpdateDialog();
|
||||
}
|
||||
|
@ -727,27 +719,27 @@ namespace BizHawk.Client.EmuHawk
|
|||
var file = GetFileFromUser("Lua Session Files (*.luases)|*.luases|All Files|*.*");
|
||||
if (file != null)
|
||||
{
|
||||
_luaList.LoadLuaSession(file.FullName);
|
||||
LuaImp.ScriptList.LoadLuaSession(file.FullName);
|
||||
RunLuaScripts();
|
||||
UpdateDialog();
|
||||
_luaList.Changes = false;
|
||||
LuaImp.ScriptList.Changes = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveSessionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_luaList.Changes)
|
||||
if (LuaImp.ScriptList.Changes)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_luaList.Filename))
|
||||
if (!string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename))
|
||||
{
|
||||
_luaList.SaveSession();
|
||||
LuaImp.ScriptList.SaveSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveSessionAs();
|
||||
}
|
||||
|
||||
OutputMessages.Text = Path.GetFileName(_luaList.Filename) + " saved.";
|
||||
OutputMessages.Text = Path.GetFileName(LuaImp.ScriptList.Filename) + " saved.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -778,21 +770,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
MoveDownMenuItem.Enabled =
|
||||
LuaListView.SelectedIndices().Any();
|
||||
|
||||
SelectAllMenuItem.Enabled = _luaList.Any();
|
||||
StopAllScriptsMenuItem.Enabled = _luaList.Any(script => script.Enabled);
|
||||
RegisteredFunctionsMenuItem.Enabled = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any();
|
||||
SelectAllMenuItem.Enabled = LuaImp.ScriptList.Any();
|
||||
StopAllScriptsMenuItem.Enabled = LuaImp.ScriptList.Any(script => script.Enabled);
|
||||
RegisteredFunctionsMenuItem.Enabled = LuaImp.RegisteredFunctions.Any();
|
||||
}
|
||||
|
||||
private void NewScriptMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = !string.IsNullOrWhiteSpace(_luaList.Filename) ?
|
||||
Path.GetDirectoryName(_luaList.Filename) :
|
||||
InitialDirectory = !string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename) ?
|
||||
Path.GetDirectoryName(LuaImp.ScriptList.Filename) :
|
||||
PathManager.MakeAbsolutePath(Global.Config.PathEntries.LuaPathFragment, null),
|
||||
DefaultExt = ".lua",
|
||||
FileName = !string.IsNullOrWhiteSpace(_luaList.Filename) ?
|
||||
Path.GetFileNameWithoutExtension(_luaList.Filename) :
|
||||
FileName = !string.IsNullOrWhiteSpace(LuaImp.ScriptList.Filename) ?
|
||||
Path.GetFileNameWithoutExtension(LuaImp.ScriptList.Filename) :
|
||||
Path.GetFileNameWithoutExtension(Global.Game.Name),
|
||||
OverwritePrompt = true,
|
||||
Filter = "Lua Scripts (*.lua)|*.lua|All Files (*.*)|*.*"
|
||||
|
@ -804,7 +796,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
string defaultTemplate = "while true do\n\temu.frameadvance();\nend";
|
||||
File.WriteAllText(sfd.FileName, defaultTemplate);
|
||||
_luaList.Add(new LuaFile(Path.GetFileNameWithoutExtension(sfd.FileName), sfd.FileName));
|
||||
LuaImp.ScriptList.Add(new LuaFile(Path.GetFileNameWithoutExtension(sfd.FileName), sfd.FileName));
|
||||
UpdateDialog();
|
||||
System.Diagnostics.Process.Start(sfd.FileName);
|
||||
}
|
||||
|
@ -822,7 +814,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void ToggleScriptMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var files = !SelectedFiles.Any() && Global.Config.ToggleAllIfNoneSelected ? _luaList : SelectedFiles;
|
||||
var files = !SelectedFiles.Any() && Global.Config.ToggleAllIfNoneSelected ? LuaImp.ScriptList : SelectedFiles;
|
||||
foreach (var item in files)
|
||||
{
|
||||
item.Toggle();
|
||||
|
@ -848,8 +840,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
// We want any gui.text messages from a script to immediately update even when paused
|
||||
GlobalWin.OSD.ClearGUIText();
|
||||
GlobalWin.Tools.UpdateToolsAfter();
|
||||
EndLuaDrawing();
|
||||
StartLuaDrawing();
|
||||
LuaImp.EndLuaDrawing();
|
||||
LuaImp.StartLuaDrawing();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
|
@ -881,7 +873,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
item.Stop();
|
||||
if (Global.Config.RemoveRegisteredFunctionsOnToggle)
|
||||
{
|
||||
GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.ClearAll();
|
||||
LuaImp.RegisteredFunctions.ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -927,7 +919,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
LuaImp.RegisteredFunctions.Remove(function);
|
||||
}
|
||||
|
||||
_luaList.Remove(item);
|
||||
LuaImp.ScriptList.Remove(item);
|
||||
}
|
||||
|
||||
UpdateRegisteredFunctionsDialog();
|
||||
|
@ -954,7 +946,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
string text = File.ReadAllText(script.Path);
|
||||
File.WriteAllText(sfd.FileName, text);
|
||||
_luaList.Add(new LuaFile(Path.GetFileNameWithoutExtension(sfd.FileName), sfd.FileName));
|
||||
LuaImp.ScriptList.Add(new LuaFile(Path.GetFileNameWithoutExtension(sfd.FileName), sfd.FileName));
|
||||
UpdateDialog();
|
||||
System.Diagnostics.Process.Start(sfd.FileName);
|
||||
}
|
||||
|
@ -964,13 +956,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void InsertSeparatorMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var indices = LuaListView.SelectedIndices().ToList();
|
||||
if (indices.Any() && indices.Last() < _luaList.Count)
|
||||
if (indices.Any() && indices.Last() < LuaImp.ScriptList.Count)
|
||||
{
|
||||
_luaList.Insert(indices.Last(), LuaFile.SeparatorInstance);
|
||||
LuaImp.ScriptList.Insert(indices.Last(), LuaFile.SeparatorInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
_luaList.Add(LuaFile.SeparatorInstance);
|
||||
LuaImp.ScriptList.Add(LuaFile.SeparatorInstance);
|
||||
}
|
||||
|
||||
UpdateDialog();
|
||||
|
@ -986,9 +978,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
foreach (var index in indices)
|
||||
{
|
||||
var file = _luaList[index];
|
||||
_luaList.Remove(file);
|
||||
_luaList.Insert(index - 1, file);
|
||||
var file = LuaImp.ScriptList[index];
|
||||
LuaImp.ScriptList.Remove(file);
|
||||
LuaImp.ScriptList.Insert(index - 1, file);
|
||||
}
|
||||
|
||||
var newindices = indices.Select(t => t - 1).ToList();
|
||||
|
@ -1005,16 +997,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void MoveDownMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var indices = LuaListView.SelectedIndices().ToList();
|
||||
if (indices.Count == 0 || indices.Last() == _luaList.Count - 1)
|
||||
if (indices.Count == 0 || indices.Last() == LuaImp.ScriptList.Count - 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = indices.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var file = _luaList[indices[i]];
|
||||
_luaList.Remove(file);
|
||||
_luaList.Insert(indices[i] + 1, file);
|
||||
var file = LuaImp.ScriptList[indices[i]];
|
||||
LuaImp.ScriptList.Remove(file);
|
||||
LuaImp.ScriptList.Insert(indices[i] + 1, file);
|
||||
}
|
||||
|
||||
var newindices = indices.Select(t => t + 1).ToList();
|
||||
|
@ -1035,7 +1027,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void StopAllScriptsMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_luaList.StopAllScripts();
|
||||
LuaImp.ScriptList.StopAllScripts();
|
||||
}
|
||||
|
||||
private void RegisteredFunctionsMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -1192,7 +1184,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
StopAllScriptsContextItem.Visible =
|
||||
ScriptContextSeparator.Visible =
|
||||
_luaList.Any(file => file.Enabled);
|
||||
LuaImp.ScriptList.Any(file => file.Enabled);
|
||||
}
|
||||
|
||||
private void ConsoleContextMenu_Opening(object sender, CancelEventArgs e)
|
||||
|
@ -1223,10 +1215,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else if (Path.GetExtension(path).ToLower() == ".luases")
|
||||
{
|
||||
_luaList.LoadLuaSession(path);
|
||||
LuaImp.ScriptList.LoadLuaSession(path);
|
||||
RunLuaScripts();
|
||||
UpdateDialog();
|
||||
_luaList.Changes = false;
|
||||
LuaImp.ScriptList.Changes = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1280,12 +1272,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
// For getting the name of the .lua file, for some reason this field is kept blank in LuaFile.cs?
|
||||
// The Name variable gets emptied again near the end just in case it would break something.
|
||||
for (var i = 0; i < _luaList.Count; i++)
|
||||
for (var i = 0; i < LuaImp.ScriptList.Count; i++)
|
||||
{
|
||||
var words = Regex.Split(_luaList[i].Path, ".lua");
|
||||
var words = Regex.Split(LuaImp.ScriptList[i].Path, ".lua");
|
||||
var split = words[0].Split(Path.DirectorySeparatorChar);
|
||||
|
||||
luaListTemp.Add(_luaList[i]);
|
||||
luaListTemp.Add(LuaImp.ScriptList[i]);
|
||||
luaListTemp[i].Name = split[split.Length - 1];
|
||||
}
|
||||
|
||||
|
@ -1304,10 +1296,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
break;
|
||||
}
|
||||
|
||||
for (var i = 0; i < _luaList.Count; i++)
|
||||
for (var i = 0; i < LuaImp.ScriptList.Count; i++)
|
||||
{
|
||||
_luaList[i] = luaListTemp[i];
|
||||
_luaList[i].Name = "";
|
||||
LuaImp.ScriptList[i] = luaListTemp[i];
|
||||
LuaImp.ScriptList[i].Name = "";
|
||||
}
|
||||
|
||||
UpdateDialog();
|
||||
|
|
|
@ -7,14 +7,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
public class LuaDropDown : ComboBox
|
||||
{
|
||||
public LuaDropDown(List<string> items)
|
||||
: base()
|
||||
{
|
||||
Items.AddRange(items.Cast<object>().ToArray());
|
||||
SelectedIndex = 0;
|
||||
DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
}
|
||||
|
||||
public void SetItems(List<string> items) {
|
||||
public void SetItems(List<string> items)
|
||||
{
|
||||
Items.Clear();
|
||||
Items.AddRange(items.Cast<object>().ToArray());
|
||||
SelectedIndex = 0;
|
||||
|
|
|
@ -41,8 +41,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void LuaFunctionList_Load(object sender, EventArgs e)
|
||||
{
|
||||
FunctionList = GlobalWin.Tools.LuaConsole.LuaImp.Docs
|
||||
.OrderBy(x => x.Library)
|
||||
.ThenBy(x => x.Name)
|
||||
.OrderBy(l => l.Library)
|
||||
.ThenBy(l => l.Name)
|
||||
.ToList();
|
||||
UpdateList();
|
||||
FilterBox.Focus();
|
||||
|
@ -52,7 +52,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void FunctionView_QueryItemBkColor(int index, int column, ref Color color)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FunctionView_QueryItemText(int index, int column, out string text)
|
||||
|
@ -148,7 +147,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
OrderColumn(e.Column);
|
||||
}
|
||||
|
||||
public class Sorting
|
||||
private class Sorting
|
||||
{
|
||||
private bool _desc;
|
||||
private int _column = 1;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class LuaRegisteredFunctionsList : Form
|
||||
{
|
||||
public Point StartLocation = new Point(0, 0);
|
||||
public Point StartLocation { get; set; } = new Point(0, 0);
|
||||
public LuaRegisteredFunctionsList()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
|
|
@ -1,28 +1,25 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Common.StringExtensions;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
enum BoxType { All, Signed, Unsigned, Hex };
|
||||
class LuaTextBox : TextBox
|
||||
internal enum BoxType
|
||||
{
|
||||
All, Signed, Unsigned, Hex
|
||||
}
|
||||
|
||||
internal class LuaTextBox : TextBox
|
||||
{
|
||||
private BoxType _boxType = BoxType.All;
|
||||
|
||||
public void SetType(BoxType type)
|
||||
{
|
||||
_boxType = type;
|
||||
if (type != BoxType.All)
|
||||
{
|
||||
CharacterCasing = CharacterCasing.Upper;
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterCasing = CharacterCasing.Normal;
|
||||
}
|
||||
CharacterCasing = type != BoxType.All
|
||||
? CharacterCasing.Upper
|
||||
: CharacterCasing.Normal;
|
||||
}
|
||||
|
||||
protected override void OnKeyPress(KeyPressEventArgs e)
|
||||
|
@ -33,7 +30,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
|
||||
if (e.KeyCode == Keys.Up)
|
||||
{
|
||||
switch (_boxType)
|
||||
|
@ -76,7 +72,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void Increment()
|
||||
{
|
||||
string text = String.IsNullOrWhiteSpace(Text) ? "0" : Text;
|
||||
string text = string.IsNullOrWhiteSpace(Text) ? "0" : Text;
|
||||
switch (_boxType)
|
||||
{
|
||||
case BoxType.Hex:
|
||||
|
@ -90,6 +86,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Text = "0";
|
||||
}
|
||||
|
||||
break;
|
||||
case BoxType.Signed:
|
||||
var sval = int.Parse(text);
|
||||
|
@ -102,6 +99,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Text = "0";
|
||||
}
|
||||
|
||||
break;
|
||||
case BoxType.Unsigned:
|
||||
var uval = uint.Parse(text);
|
||||
|
@ -114,13 +112,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Text = "0";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Decrement()
|
||||
{
|
||||
string text = String.IsNullOrWhiteSpace(Text) ? "0" : Text;
|
||||
string text = string.IsNullOrWhiteSpace(Text) ? "0" : Text;
|
||||
switch (_boxType)
|
||||
{
|
||||
case BoxType.Hex:
|
||||
|
@ -130,6 +129,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
hval--;
|
||||
Text = hval.ToString("X");
|
||||
}
|
||||
|
||||
break;
|
||||
case BoxType.Signed:
|
||||
var sval = int.Parse(text);
|
||||
|
@ -143,27 +143,40 @@ namespace BizHawk.Client.EmuHawk
|
|||
uval--;
|
||||
Text = uval.ToString();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SpecificValueBox_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (e.KeyChar == '\b') return;
|
||||
if (e.KeyChar == '\b')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_boxType)
|
||||
{
|
||||
case BoxType.Unsigned:
|
||||
if (!e.KeyChar.IsUnsigned())
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case BoxType.Signed:
|
||||
if (!e.KeyChar.IsSigned())
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case BoxType.Hex:
|
||||
if (!e.KeyChar.IsHex())
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
using LuaInterface;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class LuaWinform : Form
|
||||
{
|
||||
public List<LuaEvent> ControlEvents = new List<LuaEvent>();
|
||||
public List<LuaEvent> ControlEvents { get; } = new List<LuaEvent>();
|
||||
|
||||
private string CurrentDirectory = Environment.CurrentDirectory;
|
||||
|
||||
Lua OwnerThread;
|
||||
private readonly string _currentDirectory = Environment.CurrentDirectory;
|
||||
private readonly Lua _ownerThread;
|
||||
|
||||
public LuaWinform(Lua ownerThread)
|
||||
{
|
||||
InitializeComponent();
|
||||
OwnerThread = ownerThread;
|
||||
_ownerThread = ownerThread;
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Closing += (o, e) => CloseThis();
|
||||
}
|
||||
|
||||
private void LuaWinform_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void CloseThis()
|
||||
private void CloseThis()
|
||||
{
|
||||
GlobalWin.Tools.LuaConsole.LuaImp.WindowClosed(Handle);
|
||||
}
|
||||
|
||||
public void DoLuaEvent(IntPtr handle)
|
||||
{
|
||||
LuaSandbox.Sandbox(OwnerThread, () =>
|
||||
LuaSandbox.Sandbox(_ownerThread, () =>
|
||||
{
|
||||
Environment.CurrentDirectory = CurrentDirectory;
|
||||
foreach (LuaEvent l_event in ControlEvents)
|
||||
Environment.CurrentDirectory = _currentDirectory;
|
||||
foreach (LuaEvent luaEvent in ControlEvents)
|
||||
{
|
||||
if (l_event.Control == handle)
|
||||
if (luaEvent.Control == handle)
|
||||
{
|
||||
l_event.Event.Call();
|
||||
luaEvent.Event.Call();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -49,15 +49,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public class LuaEvent
|
||||
{
|
||||
public LuaFunction Event;
|
||||
public IntPtr Control;
|
||||
|
||||
public LuaEvent() { }
|
||||
public LuaEvent(IntPtr handle, LuaFunction lfunction)
|
||||
{
|
||||
Event = lfunction;
|
||||
Control = handle;
|
||||
}
|
||||
|
||||
public LuaFunction Event { get; }
|
||||
public IntPtr Control { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,21 @@
|
|||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
class SyncTextBox : RichTextBox
|
||||
internal class SyncTextBox : RichTextBox
|
||||
{
|
||||
public SyncTextBox()
|
||||
{
|
||||
this.Multiline = true;
|
||||
this.ScrollBars = RichTextBoxScrollBars.Vertical;
|
||||
|
||||
}
|
||||
|
||||
public Control Buddy { get; set; }
|
||||
|
||||
private static bool scrolling; // In case buddy tries to scroll us
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
|
||||
// Trap WM_VSCROLL message and pass to buddy
|
||||
if ((m.Msg == 0x115 || m.Msg == 0x20a) && !scrolling && Buddy != null && Buddy.IsHandleCreated)
|
||||
{
|
||||
|
@ -24,6 +25,7 @@ class SyncTextBox : RichTextBox
|
|||
scrolling = false;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
|
||||
}
|
|
@ -150,7 +150,7 @@
|
|||
//
|
||||
this.BranchView.AllowColumnReorder = false;
|
||||
this.BranchView.AllowColumnResize = false;
|
||||
this.BranchView.allowRightClickSelecton = true;
|
||||
this.BranchView.AllowRightClickSelecton = true;
|
||||
this.BranchView.AlwaysScroll = false;
|
||||
this.BranchView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
|
@ -161,7 +161,7 @@
|
|||
this.BranchView.HideWasLagFrames = false;
|
||||
this.BranchView.HorizontalOrientation = false;
|
||||
this.BranchView.LagFramesToHide = 0;
|
||||
this.BranchView.letKeysModifySelection = false;
|
||||
this.BranchView.LetKeysModifySelection = false;
|
||||
this.BranchView.Location = new System.Drawing.Point(6, 19);
|
||||
this.BranchView.MaxCharactersInHorizontal = 1;
|
||||
this.BranchView.MultiSelect = false;
|
||||
|
@ -170,7 +170,7 @@
|
|||
this.BranchView.ScrollSpeed = 13;
|
||||
this.BranchView.SeekingCutoffInterval = 0;
|
||||
this.BranchView.Size = new System.Drawing.Size(186, 224);
|
||||
this.BranchView.suspendHotkeys = false;
|
||||
this.BranchView.SuspendHotkeys = false;
|
||||
this.BranchView.TabIndex = 0;
|
||||
this.BranchView.PointedCellChanged += new BizHawk.Client.EmuHawk.InputRoll.CellChangeEventHandler(this.BranchView_PointedCellChanged);
|
||||
this.BranchView.CellDropped += new BizHawk.Client.EmuHawk.InputRoll.CellDroppedEvent(this.BranchView_CellDropped);
|
||||
|
|
|
@ -2,32 +2,36 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class BookmarksBranchesBox : UserControl
|
||||
{
|
||||
public TAStudio Tastudio { get; set; }
|
||||
private const string BranchNumberColumnName = "BranchNumberColumn";
|
||||
private const string FrameColumnName = "FrameColumn";
|
||||
private const string UserTextColumnName = "TextColumn";
|
||||
private readonly PlatformFrameRates FrameRates = new PlatformFrameRates();
|
||||
private ScreenshotForm Screenshot = new ScreenshotForm();
|
||||
private TasMovie Movie { get { return Tastudio.CurrentTasMovie; } }
|
||||
public TasBranch BackupBranch;
|
||||
private enum BranchUndo { Load, Update, Text, Remove, None }
|
||||
|
||||
private readonly ScreenshotForm Screenshot = new ScreenshotForm();
|
||||
|
||||
private TasMovie Movie => Tastudio.CurrentTasMovie;
|
||||
private TasBranch _backupBranch;
|
||||
private BranchUndo _branchUndo = BranchUndo.None;
|
||||
private int LongestBranchText = 0;
|
||||
public int HoverInterval {
|
||||
|
||||
private enum BranchUndo
|
||||
{
|
||||
Load, Update, Text, Remove, None
|
||||
}
|
||||
|
||||
public TAStudio Tastudio { get; set; }
|
||||
|
||||
public int HoverInterval
|
||||
{
|
||||
get { return BranchView.HoverInterval; }
|
||||
set { BranchView.HoverInterval = value; }
|
||||
}
|
||||
|
@ -36,7 +40,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
BranchView.AllColumns.AddRange(new InputRoll.RollColumn[]
|
||||
BranchView.AllColumns.AddRange(new[]
|
||||
{
|
||||
new InputRoll.RollColumn
|
||||
{
|
||||
|
@ -82,7 +86,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
text = GetBranch(index).Frame.ToString();
|
||||
break;
|
||||
case UserTextColumnName:
|
||||
//text = GetBranch(index).TimeStamp.ToString(@"hh\:mm\:ss\.ff");
|
||||
text = GetBranch(index).UserText;
|
||||
break;
|
||||
}
|
||||
|
@ -95,17 +98,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var record = Tastudio.CurrentTasMovie[branch.Frame];
|
||||
if (index == Movie.CurrentBranch)
|
||||
color = TAStudio.CurrentFrame_InputLog; // SystemColors.HotTrack;
|
||||
{
|
||||
color = TAStudio.CurrentFrame_InputLog;
|
||||
}
|
||||
else if (record.Lagged.HasValue)
|
||||
{
|
||||
if (record.Lagged.Value)
|
||||
{
|
||||
color = TAStudio.LagZone_InputLog;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = TAStudio.GreenZone_InputLog;
|
||||
}
|
||||
color = record.Lagged.Value
|
||||
? TAStudio.LagZone_InputLog
|
||||
: TAStudio.GreenZone_InputLog;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
var stateInfo = new KeyValuePair<int, byte[]>(branch.Frame, branch.CoreData);
|
||||
Tastudio.LoadState(stateInfo);
|
||||
QuickBmpFile.Copy(new BitmapBufferVideoProvider(branch.OSDFrameBuffer), Tastudio.VideoProvider);
|
||||
//GlobalWin.MainForm.PauseEmulator();
|
||||
GlobalWin.MainForm.PauseOnFrame = null;
|
||||
Tastudio.RefreshDialog();
|
||||
}
|
||||
|
@ -190,8 +189,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (SelectedBranch != null)
|
||||
{
|
||||
int index = BranchView.SelectedRows.First();
|
||||
//if (Movie.CurrentBranch == index) // if the current branch was edited, we should allow loading it. some day there might be a proper check
|
||||
// return;
|
||||
Movie.CurrentBranch = index;
|
||||
LoadBranch(SelectedBranch);
|
||||
BranchView.Refresh();
|
||||
|
@ -224,11 +221,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void LoadBranchToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
BackupBranch = CreateBranch();
|
||||
_backupBranch = CreateBranch();
|
||||
|
||||
var currentHashes = Movie.Branches.Select(b => b.UniqueIdentifier.GetHashCode()).ToList();
|
||||
do BackupBranch.UniqueIdentifier = Guid.NewGuid();
|
||||
while (currentHashes.Contains(BackupBranch.UniqueIdentifier.GetHashCode()));
|
||||
do
|
||||
{
|
||||
_backupBranch.UniqueIdentifier = Guid.NewGuid();
|
||||
}
|
||||
while (currentHashes.Contains(_backupBranch.UniqueIdentifier.GetHashCode()));
|
||||
|
||||
UndoBranchToolStripMenuItem.Enabled = UndoBranchButton.Enabled = true;
|
||||
UndoBranchToolStripMenuItem.Text = "Undo Branch Load";
|
||||
|
@ -244,14 +244,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Movie.CurrentBranch = BranchView.SelectedRows.First();
|
||||
|
||||
BackupBranch = SelectedBranch.Clone();
|
||||
_backupBranch = SelectedBranch.Clone();
|
||||
UndoBranchToolStripMenuItem.Enabled = UndoBranchButton.Enabled = true;
|
||||
UndoBranchToolStripMenuItem.Text = "Undo Branch Update";
|
||||
toolTip1.SetToolTip(UndoBranchButton, "Undo Branch Update");
|
||||
_branchUndo = BranchUndo.Update;
|
||||
|
||||
UpdateBranch(SelectedBranch);
|
||||
GlobalWin.OSD.AddMessage("Saved branch " + Movie.CurrentBranch.ToString());
|
||||
GlobalWin.OSD.AddMessage("Saved branch " + Movie.CurrentBranch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,8 +264,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (EditBranchTextPopUp(index))
|
||||
{
|
||||
BackupBranch = SelectedBranch.Clone();
|
||||
BackupBranch.UserText = oldText;
|
||||
_backupBranch = SelectedBranch.Clone();
|
||||
_backupBranch.UserText = oldText;
|
||||
UndoBranchToolStripMenuItem.Enabled = UndoBranchButton.Enabled = true;
|
||||
UndoBranchToolStripMenuItem.Text = "Undo Branch Text Edit";
|
||||
toolTip1.SetToolTip(UndoBranchButton, "Undo Branch Text Edit");
|
||||
|
@ -300,7 +300,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Movie.CurrentBranch--;
|
||||
}
|
||||
|
||||
BackupBranch = SelectedBranch.Clone();
|
||||
_backupBranch = SelectedBranch.Clone();
|
||||
UndoBranchToolStripMenuItem.Enabled = UndoBranchButton.Enabled = true;
|
||||
UndoBranchToolStripMenuItem.Text = "Undo Branch Removal";
|
||||
toolTip1.SetToolTip(UndoBranchButton, "Undo Branch Removal");
|
||||
|
@ -315,7 +315,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
BranchView.SelectRow(Movie.BranchCount - 1, true);
|
||||
}
|
||||
|
||||
//BranchView.Refresh();
|
||||
Tastudio.RefreshDialog();
|
||||
GlobalWin.OSD.AddMessage("Removed branch " + index.ToString());
|
||||
}
|
||||
|
@ -325,25 +324,26 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (_branchUndo == BranchUndo.Load)
|
||||
{
|
||||
LoadBranch(BackupBranch);
|
||||
LoadBranch(_backupBranch);
|
||||
GlobalWin.OSD.AddMessage("Branch Load canceled");
|
||||
}
|
||||
else if (_branchUndo == BranchUndo.Update)
|
||||
{
|
||||
Movie.UpdateBranch(Movie.GetBranch(BackupBranch.UniqueIdentifier), BackupBranch);
|
||||
Movie.UpdateBranch(Movie.GetBranch(_backupBranch.UniqueIdentifier), _backupBranch);
|
||||
GlobalWin.OSD.AddMessage("Branch Update canceled");
|
||||
}
|
||||
else if (_branchUndo == BranchUndo.Text)
|
||||
{
|
||||
Movie.GetBranch(BackupBranch.UniqueIdentifier).UserText = BackupBranch.UserText;
|
||||
Movie.GetBranch(_backupBranch.UniqueIdentifier).UserText = _backupBranch.UserText;
|
||||
GlobalWin.OSD.AddMessage("Branch Text Edit canceled");
|
||||
}
|
||||
else if (_branchUndo == BranchUndo.Remove)
|
||||
{
|
||||
Movie.AddBranch(BackupBranch);
|
||||
Movie.AddBranch(_backupBranch);
|
||||
BranchView.RowCount = Movie.BranchCount;
|
||||
GlobalWin.OSD.AddMessage("Branch Removal canceled");
|
||||
}
|
||||
|
||||
UndoBranchToolStripMenuItem.Enabled = UndoBranchButton.Enabled = false;
|
||||
BranchView.Refresh();
|
||||
Tastudio.RefreshDialog();
|
||||
|
@ -359,7 +359,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void LoadBranchExternal(int slot = -1)
|
||||
{
|
||||
if (Tastudio.FloatEditingMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot != -1)
|
||||
{
|
||||
|
@ -373,13 +375,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LoadBranchToolStripMenuItem_Click(null, null);
|
||||
}
|
||||
|
||||
public void UpdateBranchExternal(int slot = -1)
|
||||
{
|
||||
if (Tastudio.FloatEditingMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot != -1)
|
||||
{
|
||||
|
@ -393,6 +398,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateBranchToolStripMenuItem_Click(null, null);
|
||||
}
|
||||
|
||||
|
@ -404,7 +410,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void SelectBranchExternal(int slot)
|
||||
{
|
||||
if (Tastudio.FloatEditingMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetBranch(slot) != null)
|
||||
{
|
||||
|
@ -425,6 +433,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
BranchView.Refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
int sel = BranchView.SelectedRows.First();
|
||||
if (next)
|
||||
{
|
||||
|
@ -442,14 +451,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
BranchView.SelectRow(sel - 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
BranchView.Refresh();
|
||||
}
|
||||
|
||||
public void NonExistentBranchMessage(int slot)
|
||||
{
|
||||
string binding = Global.Config.HotkeyBindings.Where(x => x.DisplayName == "Add Branch").FirstOrDefault().Bindings;
|
||||
GlobalWin.OSD.AddMessage("Branch " + slot.ToString() + " does not exist");
|
||||
GlobalWin.OSD.AddMessage("Use " + binding + " to add branches");
|
||||
string binding = Global.Config.HotkeyBindings.First(x => x.DisplayName == "Add Branch").Bindings;
|
||||
GlobalWin.OSD.AddMessage($"Branch {slot} does not exist");
|
||||
GlobalWin.OSD.AddMessage($"Use {binding} to add branches");
|
||||
}
|
||||
|
||||
public void UpdateValues()
|
||||
|
@ -471,18 +481,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
foreach (TasBranch b in Movie.Branches)
|
||||
{
|
||||
if (string.IsNullOrEmpty(b.UserText))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (temp < b.UserText.Length)
|
||||
{
|
||||
temp = b.UserText.Length;
|
||||
}
|
||||
}
|
||||
|
||||
LongestBranchText = temp;
|
||||
|
||||
int textWidth = LongestBranchText * 12 + 14; // sorry for magic numbers. see TAStudio.SetUpColumns()
|
||||
InputRoll.RollColumn column = BranchView.AllColumns.Where(c => c.Name == UserTextColumnName).SingleOrDefault();
|
||||
int textWidth = (LongestBranchText * 12) + 14; // sorry for magic numbers. see TAStudio.SetUpColumns()
|
||||
var column = BranchView.AllColumns.Single(c => c.Name == UserTextColumnName);
|
||||
|
||||
if (textWidth < 90)
|
||||
{
|
||||
textWidth = 90;
|
||||
}
|
||||
|
||||
if (column.Width != textWidth)
|
||||
{
|
||||
|
@ -495,9 +512,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
TasBranch branch = Movie.GetBranch(index);
|
||||
if (branch == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
InputPrompt i = new InputPrompt
|
||||
var i = new InputPrompt
|
||||
{
|
||||
Text = "Text for branch " + index,
|
||||
TextInputType = InputPrompt.InputType.Text,
|
||||
|
@ -516,6 +535,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
UpdateValues();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -557,7 +577,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void BranchView_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (BranchView.CurrentCell == null || !BranchView.CurrentCell.RowIndex.HasValue || BranchView.CurrentCell.Column == null)
|
||||
if (BranchView.CurrentCell?.RowIndex == null || BranchView.CurrentCell.Column == null)
|
||||
{
|
||||
Screenshot.FadeOut();
|
||||
}
|
||||
|
@ -582,7 +602,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void BranchView_PointedCellChanged(object sender, InputRoll.CellEventArgs e)
|
||||
{
|
||||
if (e.NewCell != null && e.NewCell.RowIndex.HasValue && e.NewCell.Column != null && e.NewCell.RowIndex < Movie.BranchCount)
|
||||
if (e.NewCell?.RowIndex != null && e.NewCell.Column != null && e.NewCell.RowIndex < Movie.BranchCount)
|
||||
{
|
||||
if (BranchView.CurrentCell.Column.Name == BranchNumberColumnName &&
|
||||
BranchView.CurrentCell.RowIndex.HasValue &&
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -13,32 +7,32 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class DefaultGreenzoneSettings : Form
|
||||
{
|
||||
TasStateManagerSettings settings;
|
||||
private TasStateManagerSettings _settings;
|
||||
|
||||
public DefaultGreenzoneSettings()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
settings = new TasStateManagerSettings(Global.Config.DefaultTasProjSettings);
|
||||
_settings = new TasStateManagerSettings(Global.Config.DefaultTasProjSettings);
|
||||
|
||||
SettingsPropertyGrid.SelectedObject = settings;
|
||||
SettingsPropertyGrid.SelectedObject = _settings;
|
||||
}
|
||||
|
||||
private void OkBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.DefaultTasProjSettings = settings;
|
||||
this.Close();
|
||||
Global.Config.DefaultTasProjSettings = _settings;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void CancelBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void DefaultsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
settings = new TasStateManagerSettings();
|
||||
SettingsPropertyGrid.SelectedObject = settings;
|
||||
_settings = new TasStateManagerSettings();
|
||||
SettingsPropertyGrid.SelectedObject = _settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -16,10 +10,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
public int Frames
|
||||
{
|
||||
get { return NumFramesBox.ToRawInt() ?? 0; }
|
||||
}
|
||||
public int Frames => NumFramesBox.ToRawInt() ?? 0;
|
||||
|
||||
private void FramesPrompt_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
using BizHawk.Client.Common;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -17,11 +10,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public IStatable Statable { get; set; }
|
||||
|
||||
private readonly TasStateManagerSettings Settings;
|
||||
private readonly TasStateManagerSettings _settings;
|
||||
private decimal _stateSizeMb;
|
||||
|
||||
public StateHistorySettingsForm(TasStateManagerSettings settings)
|
||||
{
|
||||
Settings = settings;
|
||||
_settings = settings;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
@ -30,38 +24,38 @@ namespace BizHawk.Client.EmuHawk
|
|||
_stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / (decimal)1024;
|
||||
|
||||
if (Environment.Is64BitProcess) // ?
|
||||
{
|
||||
MemCapacityNumeric.Maximum = 1024 * 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
MemCapacityNumeric.Maximum = 1024;
|
||||
}
|
||||
|
||||
MemCapacityNumeric.Value = Settings.Capacitymb < MemCapacityNumeric.Maximum ?
|
||||
Settings.Capacitymb : MemCapacityNumeric.Maximum;
|
||||
DiskCapacityNumeric.Value = Settings.DiskCapacitymb < MemCapacityNumeric.Maximum ?
|
||||
Settings.DiskCapacitymb : MemCapacityNumeric.Maximum;
|
||||
SaveCapacityNumeric.Value = Settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ?
|
||||
Settings.DiskSaveCapacitymb : MemCapacityNumeric.Maximum;
|
||||
MemCapacityNumeric.Value = _settings.Capacitymb < MemCapacityNumeric.Maximum ?
|
||||
_settings.Capacitymb : MemCapacityNumeric.Maximum;
|
||||
DiskCapacityNumeric.Value = _settings.DiskCapacitymb < MemCapacityNumeric.Maximum ?
|
||||
_settings.DiskCapacitymb : MemCapacityNumeric.Maximum;
|
||||
SaveCapacityNumeric.Value = _settings.DiskSaveCapacitymb < MemCapacityNumeric.Maximum ?
|
||||
_settings.DiskSaveCapacitymb : MemCapacityNumeric.Maximum;
|
||||
|
||||
StateGap.Value = Settings.StateGap;
|
||||
StateGap.Value = _settings.StateGap;
|
||||
SavestateSizeLabel.Text = Math.Round(_stateSizeMb, 2).ToString() + " mb";
|
||||
CapacityNumeric_ValueChanged(null, null);
|
||||
SaveCapacityNumeric_ValueChanged(null, null);
|
||||
BranchStatesInTasproj.Checked = Settings.BranchStatesInTasproj;
|
||||
EraseBranchStatesFirst.Checked = Settings.EraseBranchStatesFirst;
|
||||
BranchStatesInTasproj.Checked = _settings.BranchStatesInTasproj;
|
||||
EraseBranchStatesFirst.Checked = _settings.EraseBranchStatesFirst;
|
||||
}
|
||||
|
||||
private int MaxStatesInCapacity
|
||||
{
|
||||
get { return (int)Math.Floor(MemCapacityNumeric.Value / _stateSizeMb)
|
||||
+ (int)Math.Floor(DiskCapacityNumeric.Value / _stateSizeMb);
|
||||
}
|
||||
}
|
||||
private int MaxStatesInCapacity => (int)Math.Floor(MemCapacityNumeric.Value / _stateSizeMb)
|
||||
+ (int)Math.Floor(DiskCapacityNumeric.Value / _stateSizeMb);
|
||||
|
||||
private void OkBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Settings.Capacitymb = (int)MemCapacityNumeric.Value;
|
||||
Settings.DiskCapacitymb = (int)DiskCapacityNumeric.Value;
|
||||
Settings.DiskSaveCapacitymb = (int)SaveCapacityNumeric.Value;
|
||||
Settings.StateGap = (int)StateGap.Value;
|
||||
_settings.Capacitymb = (int)MemCapacityNumeric.Value;
|
||||
_settings.DiskCapacitymb = (int)DiskCapacityNumeric.Value;
|
||||
_settings.DiskSaveCapacitymb = (int)SaveCapacityNumeric.Value;
|
||||
_settings.StateGap = (int)StateGap.Value;
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
@ -86,17 +80,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void BranchStatesInTasproj_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Settings.BranchStatesInTasproj = BranchStatesInTasproj.Checked;
|
||||
_settings.BranchStatesInTasproj = BranchStatesInTasproj.Checked;
|
||||
}
|
||||
|
||||
private void EraseBranchStatesFIrst_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
Settings.EraseBranchStatesFirst = EraseBranchStatesFirst.Checked;
|
||||
_settings.EraseBranchStatesFirst = EraseBranchStatesFirst.Checked;
|
||||
}
|
||||
|
||||
private void StateGap_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
NumFramesLabel.Text = ((StateGap.Value == 0) ? "frame" : (1 << (int)StateGap.Value).ToString() + " frames");
|
||||
NumFramesLabel.Text = StateGap.Value == 0
|
||||
? "frame"
|
||||
: $"{1 << (int)StateGap.Value} frames";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -13,36 +7,37 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class MovieHeaderEditor : Form
|
||||
{
|
||||
private readonly IMovie Movie;
|
||||
private readonly IMovie _movie;
|
||||
|
||||
public MovieHeaderEditor(IMovie movie)
|
||||
{
|
||||
Movie = movie;
|
||||
_movie = movie;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void MovieHeaderEditor_Load(object sender, EventArgs e)
|
||||
{
|
||||
AuthorTextBox.Text = Movie.Author;
|
||||
EmulatorVersionTextBox.Text = Movie.EmulatorVersion;
|
||||
PlatformTextBox.Text = Movie.SystemID;
|
||||
CoreTextBox.Text = Movie.Core;
|
||||
BoardNameTextBox.Text = Movie.BoardName;
|
||||
GameNameTextBox.Text = Movie.GameName;
|
||||
AuthorTextBox.Text = _movie.Author;
|
||||
EmulatorVersionTextBox.Text = _movie.EmulatorVersion;
|
||||
PlatformTextBox.Text = _movie.SystemID;
|
||||
CoreTextBox.Text = _movie.Core;
|
||||
BoardNameTextBox.Text = _movie.BoardName;
|
||||
GameNameTextBox.Text = _movie.GameName;
|
||||
}
|
||||
|
||||
private void OkBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Movie.Author = AuthorTextBox.Text;
|
||||
_movie.Author = AuthorTextBox.Text;
|
||||
if (MakeDefaultCheckbox.Checked)
|
||||
{
|
||||
Global.Config.DefaultAuthor = AuthorTextBox.Text;
|
||||
}
|
||||
|
||||
Movie.EmulatorVersion = EmulatorVersionTextBox.Text;
|
||||
Movie.SystemID = PlatformTextBox.Text;
|
||||
Movie.Core = CoreTextBox.Text;
|
||||
Movie.BoardName = BoardNameTextBox.Text;
|
||||
Movie.GameName = GameNameTextBox.Text;
|
||||
_movie.EmulatorVersion = EmulatorVersionTextBox.Text;
|
||||
_movie.SystemID = PlatformTextBox.Text;
|
||||
_movie.Core = CoreTextBox.Text;
|
||||
_movie.BoardName = BoardNameTextBox.Text;
|
||||
_movie.GameName = GameNameTextBox.Text;
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
|
|
@ -185,7 +185,7 @@
|
|||
//
|
||||
this.MarkerView.AllowColumnReorder = false;
|
||||
this.MarkerView.AllowColumnResize = false;
|
||||
this.MarkerView.allowRightClickSelecton = true;
|
||||
this.MarkerView.AllowRightClickSelecton = true;
|
||||
this.MarkerView.AlwaysScroll = false;
|
||||
this.MarkerView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
@ -16,13 +13,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
public partial class MarkerControl : UserControl
|
||||
{
|
||||
public TAStudio Tastudio { get; set; }
|
||||
public TasMovieMarkerList Markers { get { return Tastudio.CurrentTasMovie.Markers; } }
|
||||
public TasMovieMarkerList Markers => Tastudio.CurrentTasMovie.Markers;
|
||||
|
||||
public MarkerControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
MarkerView.AllColumns.AddRange(new InputRoll.RollColumn[]
|
||||
MarkerView.AllColumns.AddRange(new[]
|
||||
{
|
||||
new InputRoll.RollColumn
|
||||
{
|
||||
|
@ -44,15 +41,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void MarkerControl_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public InputRoll MarkerInputRoll { get { return MarkerView; } }
|
||||
public InputRoll MarkerInputRoll => MarkerView;
|
||||
|
||||
private void MarkerView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color)
|
||||
{
|
||||
var prev = Markers.PreviousOrCurrent(Tastudio.Emulator.Frame);
|
||||
|
||||
|
||||
if (prev != null && index == Markers.IndexOf(prev))
|
||||
{
|
||||
// feos: taseditor doesn't have it, so we're free to set arbitrary color scheme. and I prefer consistency
|
||||
|
@ -80,7 +76,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
color = Color.White;
|
||||
}
|
||||
}
|
||||
|
||||
private void MarkerView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY)
|
||||
|
@ -165,7 +163,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (editText)
|
||||
{
|
||||
InputPrompt i = new InputPrompt
|
||||
var i = new InputPrompt
|
||||
{
|
||||
Text = "Marker for frame " + markerFrame,
|
||||
TextInputType = InputPrompt.InputType.Text,
|
||||
|
@ -191,6 +189,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Markers.Add(new TasMovieMarker(markerFrame, ""));
|
||||
UpdateValues();
|
||||
}
|
||||
|
||||
Tastudio.RefreshDialog();
|
||||
}
|
||||
|
||||
|
@ -198,15 +197,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var markerFrame = marker.Frame;
|
||||
var point = default(Point);
|
||||
InputPrompt i = new InputPrompt
|
||||
var i = new InputPrompt
|
||||
{
|
||||
Text = "Marker for frame " + markerFrame,
|
||||
TextInputType = InputPrompt.InputType.Text,
|
||||
Message = "Enter a message",
|
||||
InitialValue =
|
||||
Markers.IsMarker(markerFrame) ?
|
||||
Markers.PreviousOrCurrent(markerFrame).Message :
|
||||
""
|
||||
Markers.IsMarker(markerFrame)
|
||||
? Markers.PreviousOrCurrent(markerFrame).Message
|
||||
: ""
|
||||
};
|
||||
|
||||
if (followCursor)
|
||||
|
@ -214,6 +213,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
point = Cursor.Position;
|
||||
point.Offset(i.Width / -2, i.Height / -2);
|
||||
}
|
||||
|
||||
var result = i.ShowHawkDialog(position: point);
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
|
@ -225,10 +225,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void UpdateValues()
|
||||
{
|
||||
if (MarkerView != null &&
|
||||
Tastudio != null &&
|
||||
Tastudio.CurrentTasMovie != null &&
|
||||
Markers != null)
|
||||
if (MarkerView != null && Tastudio?.CurrentTasMovie != null && Markers != null)
|
||||
{
|
||||
MarkerView.RowCount = Markers.Count;
|
||||
}
|
||||
|
@ -270,8 +267,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// A much more useful feature would be to easily jump to it.
|
||||
private void MarkerView_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (MarkerView.CurrentCell != null && MarkerView.CurrentCell.RowIndex.HasValue &&
|
||||
MarkerView.CurrentCell.RowIndex < MarkerView.RowCount)
|
||||
if (MarkerView.CurrentCell?.RowIndex != null && MarkerView.CurrentCell.RowIndex < MarkerView.RowCount)
|
||||
{
|
||||
var marker = Markers[MarkerView.CurrentCell.RowIndex.Value];
|
||||
Tastudio.GoToFrame(marker.Frame);
|
||||
|
@ -284,8 +280,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var index = MarkerView.SelectedRows.First();
|
||||
var marker = Markers[index];
|
||||
|
||||
return marker.Frame;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -13,17 +8,32 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class PatternsForm : Form
|
||||
{
|
||||
private TAStudio tastudio;
|
||||
private readonly TAStudio _tastudio;
|
||||
|
||||
private readonly List<int> _counts = new List<int>();
|
||||
private readonly List<string> _values = new List<string>();
|
||||
private int _loopAt;
|
||||
private bool _updating;
|
||||
|
||||
private string SelectedButton => ButtonBox.Text;
|
||||
|
||||
private bool IsBool => SelectedButton == "Default bool Auto-Fire" || Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(SelectedButton);
|
||||
|
||||
public PatternsForm(TAStudio owner)
|
||||
{
|
||||
InitializeComponent();
|
||||
tastudio = owner;
|
||||
_tastudio = owner;
|
||||
|
||||
foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons)
|
||||
{
|
||||
ButtonBox.Items.Add(button);
|
||||
}
|
||||
|
||||
foreach (var button in Global.MovieSession.MovieControllerAdapter.Definition.FloatControls)
|
||||
{
|
||||
ButtonBox.Items.Add(button);
|
||||
}
|
||||
|
||||
ButtonBox.Items.Add("Default bool Auto-Fire");
|
||||
ButtonBox.Items.Add("Default float Auto-Fire");
|
||||
}
|
||||
|
@ -33,18 +43,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
ButtonBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
List<int> counts = new List<int>();
|
||||
List<string> values = new List<string>();
|
||||
int loopAt;
|
||||
string selectedButton { get { return ButtonBox.Text; } }
|
||||
bool isBool { get { return selectedButton == "Default bool Auto-Fire" || Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.Contains(selectedButton); } }
|
||||
|
||||
private void ButtonBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
GetPattern();
|
||||
UpdateDisplay();
|
||||
|
||||
if (isBool)
|
||||
if (IsBool)
|
||||
{
|
||||
OnOffBox.Visible = true;
|
||||
ValueNum.Visible = false;
|
||||
|
@ -54,22 +58,28 @@ namespace BizHawk.Client.EmuHawk
|
|||
ValueNum.Visible = true;
|
||||
OnOffBox.Visible = false;
|
||||
}
|
||||
CountNum.Value = counts[0];
|
||||
|
||||
CountNum.Value = _counts[0];
|
||||
}
|
||||
|
||||
private void PatternList_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!_updating)
|
||||
{
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
private void InsertButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
counts.Insert(PatternList.SelectedIndex, 1);
|
||||
_counts.Insert(PatternList.SelectedIndex, 1);
|
||||
string defaultStr = "false";
|
||||
if (!isBool)
|
||||
if (!IsBool)
|
||||
{
|
||||
defaultStr = "0";
|
||||
values.Insert(PatternList.SelectedIndex, defaultStr);
|
||||
}
|
||||
|
||||
_values.Insert(PatternList.SelectedIndex, defaultStr);
|
||||
|
||||
UpdatePattern();
|
||||
UpdateDisplay();
|
||||
|
@ -77,8 +87,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
counts.RemoveAt(PatternList.SelectedIndex);
|
||||
values.RemoveAt(PatternList.SelectedIndex);
|
||||
_counts.RemoveAt(PatternList.SelectedIndex);
|
||||
_values.RemoveAt(PatternList.SelectedIndex);
|
||||
UpdatePattern();
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
@ -90,36 +100,48 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void ValueNum_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex >= counts.Count)
|
||||
if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex >= _counts.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
values[PatternList.SelectedIndex] = ValueNum.Value.ToString();
|
||||
_values[PatternList.SelectedIndex] = ValueNum.Value.ToString();
|
||||
UpdatePattern();
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
private void OnOffBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex >= counts.Count)
|
||||
if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex >= _counts.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
values[PatternList.SelectedIndex] = OnOffBox.Checked.ToString();
|
||||
_values[PatternList.SelectedIndex] = OnOffBox.Checked.ToString();
|
||||
UpdatePattern();
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
private void CountNum_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex > counts.Count)
|
||||
if (_updating || PatternList.SelectedIndex == -1 || PatternList.SelectedIndex > _counts.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (PatternList.SelectedIndex == counts.Count)
|
||||
loopAt = (int)CountNum.Value;
|
||||
if (PatternList.SelectedIndex == _counts.Count)
|
||||
{
|
||||
_loopAt = (int)CountNum.Value;
|
||||
}
|
||||
else
|
||||
counts[PatternList.SelectedIndex] = (int)CountNum.Value;
|
||||
{
|
||||
_counts[PatternList.SelectedIndex] = (int)CountNum.Value;
|
||||
}
|
||||
|
||||
UpdatePattern();
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
private bool _updating = false;
|
||||
private void UpdateDisplay()
|
||||
{
|
||||
_updating = true;
|
||||
|
@ -127,52 +149,71 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
int oldIndex = PatternList.SelectedIndex;
|
||||
if (oldIndex == -1)
|
||||
{
|
||||
oldIndex = 0;
|
||||
}
|
||||
|
||||
PatternList.Items.Clear();
|
||||
int index = 0;
|
||||
for (int i = 0; i < counts.Count; i++)
|
||||
for (int i = 0; i < _counts.Count; i++)
|
||||
{
|
||||
string str = index.ToString() + ": ";
|
||||
if (isBool)
|
||||
str += values[i][0] == 'T' ? "On" : "Off";
|
||||
string str = index + ": ";
|
||||
if (IsBool)
|
||||
{
|
||||
str += _values[i][0] == 'T' ? "On" : "Off";
|
||||
}
|
||||
else
|
||||
str += values[i].ToString();
|
||||
{
|
||||
str += _values[i];
|
||||
}
|
||||
|
||||
PatternList.Items.Add(str + ("\t(x" + counts[i] + ")"));
|
||||
index += counts[i];
|
||||
PatternList.Items.Add(str + ("\t(x" + _counts[i] + ")"));
|
||||
index += _counts[i];
|
||||
}
|
||||
PatternList.Items.Add("Loop to: " + loopAt);
|
||||
|
||||
PatternList.Items.Add("Loop to: " + _loopAt);
|
||||
|
||||
if (oldIndex >= PatternList.Items.Count)
|
||||
{
|
||||
oldIndex = PatternList.Items.Count - 1;
|
||||
}
|
||||
|
||||
PatternList.SelectedIndex = oldIndex;
|
||||
|
||||
if (PatternList.SelectedIndex != -1 && PatternList.SelectedIndex < values.Count)
|
||||
if (PatternList.SelectedIndex != -1 && PatternList.SelectedIndex < _values.Count)
|
||||
{
|
||||
index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton);
|
||||
if (selectedButton == "Default bool Auto-Fire")
|
||||
index = tastudio.BoolPatterns.Length + 1;
|
||||
index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(SelectedButton);
|
||||
if (SelectedButton == "Default bool Auto-Fire")
|
||||
{
|
||||
index = _tastudio.BoolPatterns.Length + 1;
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
LagBox.Checked = tastudio.BoolPatterns[index].SkipsLag;
|
||||
OnOffBox.Checked = values[PatternList.SelectedIndex][0] == 'T';
|
||||
CountNum.Value = (decimal)counts[PatternList.SelectedIndex];
|
||||
LagBox.Checked = _tastudio.BoolPatterns[index].SkipsLag;
|
||||
OnOffBox.Checked = _values[PatternList.SelectedIndex][0] == 'T';
|
||||
CountNum.Value = _counts[PatternList.SelectedIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedButton == "Default float Auto-Fire")
|
||||
index = tastudio.FloatPatterns.Length + 1;
|
||||
if (SelectedButton == "Default float Auto-Fire")
|
||||
{
|
||||
index = _tastudio.FloatPatterns.Length + 1;
|
||||
}
|
||||
else
|
||||
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton);
|
||||
{
|
||||
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(SelectedButton);
|
||||
}
|
||||
|
||||
LagBox.Checked = tastudio.FloatPatterns[index].SkipsLag;
|
||||
ValueNum.Value = Convert.ToDecimal(values[PatternList.SelectedIndex]);
|
||||
CountNum.Value = (decimal)counts[PatternList.SelectedIndex];
|
||||
LagBox.Checked = _tastudio.FloatPatterns[index].SkipsLag;
|
||||
ValueNum.Value = Convert.ToDecimal(_values[PatternList.SelectedIndex]);
|
||||
CountNum.Value = _counts[PatternList.SelectedIndex];
|
||||
}
|
||||
}
|
||||
else if (PatternList.SelectedIndex == values.Count)
|
||||
CountNum.Value = (decimal)loopAt;
|
||||
else if (PatternList.SelectedIndex == _values.Count)
|
||||
{
|
||||
CountNum.Value = _loopAt;
|
||||
}
|
||||
|
||||
PatternList.ResumeLayout();
|
||||
_updating = false;
|
||||
|
@ -180,91 +221,116 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void UpdatePattern()
|
||||
{
|
||||
int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton);
|
||||
if (selectedButton == "Default bool Auto-Fire")
|
||||
index = tastudio.BoolPatterns.Length + 1;
|
||||
int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(SelectedButton);
|
||||
if (SelectedButton == "Default bool Auto-Fire")
|
||||
{
|
||||
index = _tastudio.BoolPatterns.Length + 1;
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
List<bool> p = new List<bool>();
|
||||
for (int i = 0; i < counts.Count; i++)
|
||||
for (int i = 0; i < _counts.Count; i++)
|
||||
{
|
||||
for (int c = 0; c < counts[i]; c++)
|
||||
p.Add(Convert.ToBoolean(values[i]));
|
||||
for (int c = 0; c < _counts[i]; c++)
|
||||
{
|
||||
p.Add(Convert.ToBoolean(_values[i]));
|
||||
}
|
||||
}
|
||||
tastudio.BoolPatterns[index] = new AutoPatternBool(p.ToArray(), LagBox.Checked, 0, loopAt);
|
||||
|
||||
_tastudio.BoolPatterns[index] = new AutoPatternBool(p.ToArray(), LagBox.Checked, 0, _loopAt);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedButton == "Default float Auto-Fire")
|
||||
index = tastudio.FloatPatterns.Length + 1;
|
||||
else
|
||||
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton);
|
||||
List<float> p = new List<float>();
|
||||
for (int i = 0; i < counts.Count; i++)
|
||||
if (SelectedButton == "Default float Auto-Fire")
|
||||
{
|
||||
for (int c = 0; c < counts[i]; c++)
|
||||
p.Add(Convert.ToSingle(values[i]));
|
||||
index = _tastudio.FloatPatterns.Length + 1;
|
||||
}
|
||||
tastudio.FloatPatterns[index] = new AutoPatternFloat(p.ToArray(), LagBox.Checked, 0, loopAt);
|
||||
else
|
||||
{
|
||||
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(SelectedButton);
|
||||
}
|
||||
|
||||
List<float> p = new List<float>();
|
||||
for (int i = 0; i < _counts.Count; i++)
|
||||
{
|
||||
for (int c = 0; c < _counts[i]; c++)
|
||||
{
|
||||
p.Add(Convert.ToSingle(_values[i]));
|
||||
}
|
||||
}
|
||||
|
||||
_tastudio.FloatPatterns[index] = new AutoPatternFloat(p.ToArray(), LagBox.Checked, 0, _loopAt);
|
||||
}
|
||||
|
||||
tastudio.UpdateAutoFire(selectedButton, null);
|
||||
_tastudio.UpdateAutoFire(SelectedButton, null);
|
||||
}
|
||||
|
||||
private void GetPattern()
|
||||
{
|
||||
int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton);
|
||||
if (selectedButton == "Default bool Auto-Fire")
|
||||
index = tastudio.BoolPatterns.Length + 1;
|
||||
int index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(SelectedButton);
|
||||
if (SelectedButton == "Default bool Auto-Fire")
|
||||
{
|
||||
index = _tastudio.BoolPatterns.Length + 1;
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
bool[] p = tastudio.BoolPatterns[index].Pattern;
|
||||
bool[] p = _tastudio.BoolPatterns[index].Pattern;
|
||||
bool lastValue = p[0];
|
||||
counts.Clear();
|
||||
values.Clear();
|
||||
counts.Add(1);
|
||||
values.Add(lastValue.ToString());
|
||||
_counts.Clear();
|
||||
_values.Clear();
|
||||
_counts.Add(1);
|
||||
_values.Add(lastValue.ToString());
|
||||
for (int i = 1; i < p.Length; i++)
|
||||
{
|
||||
if (p[i] == lastValue)
|
||||
counts[counts.Count - 1]++;
|
||||
{
|
||||
_counts[_counts.Count - 1]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
counts.Add(1);
|
||||
values.Add(p[i].ToString());
|
||||
_counts.Add(1);
|
||||
_values.Add(p[i].ToString());
|
||||
lastValue = p[i];
|
||||
}
|
||||
}
|
||||
loopAt = tastudio.BoolPatterns[index].Loop;
|
||||
|
||||
_loopAt = _tastudio.BoolPatterns[index].Loop;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedButton == "Default float Auto-Fire")
|
||||
index = tastudio.FloatPatterns.Length + 1;
|
||||
if (SelectedButton == "Default float Auto-Fire")
|
||||
{
|
||||
index = _tastudio.FloatPatterns.Length + 1;
|
||||
}
|
||||
else
|
||||
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton);
|
||||
float[] p = tastudio.FloatPatterns[index].Pattern;
|
||||
{
|
||||
index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(SelectedButton);
|
||||
}
|
||||
|
||||
float[] p = _tastudio.FloatPatterns[index].Pattern;
|
||||
float lastValue = p[0];
|
||||
counts.Clear();
|
||||
values.Clear();
|
||||
counts.Add(1);
|
||||
values.Add(lastValue.ToString());
|
||||
_counts.Clear();
|
||||
_values.Clear();
|
||||
_counts.Add(1);
|
||||
_values.Add(lastValue.ToString());
|
||||
for (int i = 1; i < p.Length; i++)
|
||||
{
|
||||
if (p[i] == lastValue)
|
||||
counts[counts.Count - 1]++;
|
||||
{
|
||||
_counts[_counts.Count - 1]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
counts.Add(1);
|
||||
values.Add(p[i].ToString());
|
||||
_counts.Add(1);
|
||||
_values.Add(p[i].ToString());
|
||||
lastValue = p[i];
|
||||
}
|
||||
}
|
||||
loopAt = tastudio.FloatPatterns[index].Loop;
|
||||
|
||||
_loopAt = _tastudio.FloatPatterns[index].Loop;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
|
@ -18,7 +13,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public TAStudio Tastudio { get; set; }
|
||||
|
||||
[Browsable(true)]
|
||||
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool TurboSeek
|
||||
{
|
||||
get
|
||||
|
@ -33,7 +28,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[Browsable(true)]
|
||||
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool AutoRestore
|
||||
{
|
||||
get
|
||||
|
@ -48,7 +43,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[Browsable(true)]
|
||||
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool FollowCursor
|
||||
{
|
||||
get
|
||||
|
@ -63,7 +58,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
[Browsable(true)]
|
||||
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool RecordingMode
|
||||
{
|
||||
get
|
||||
|
@ -83,6 +78,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Global.MovieSession.Movie.SwitchToPlay();
|
||||
}
|
||||
|
||||
GlobalWin.MainForm.SetMainformMovieInfo();
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +187,5 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
GlobalWin.MainForm.HoldFrameAdvance = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue