diff --git a/.gitignore b/.gitignore index 7072e3190b74b3e07c5e0a8fb812a6a2e4ca8b74..7f254794fcffc36e63e6df55e64194c745d19fc3 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,6 @@ ios/robovm.properties ## core core/gen + + +temp/ \ No newline at end of file diff --git a/android/assets/gfx/screen_loader_background.jpg b/android/assets/gfx/screen_loader_background.jpg index 068d4c4a8a5072b259522826146892d7c46b89ee..557d43642701c1132b9c393836c23e578983a7e9 100644 Binary files a/android/assets/gfx/screen_loader_background.jpg and b/android/assets/gfx/screen_loader_background.jpg differ diff --git a/core/assets/common/_global/application/dialog/bubble_arrow_left.9.png b/core/assets/common/_global/application/dialog/bubble_arrow_bend_left.9.png similarity index 100% rename from core/assets/common/_global/application/dialog/bubble_arrow_left.9.png rename to core/assets/common/_global/application/dialog/bubble_arrow_bend_left.9.png diff --git a/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_bottom.png b/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..cfe8a8cac86793c73bb46db2d2de8aa52da13ced Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_bottom.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_left.png b/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_left.png new file mode 100644 index 0000000000000000000000000000000000000000..a42afeb2013abfecc29cefb103315785e9ff682c Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_left.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_right.png b/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_right.png new file mode 100644 index 0000000000000000000000000000000000000000..bc1472627461fd7c791ae9974256474b84a38734 Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_right.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_top.png b/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_top.png new file mode 100644 index 0000000000000000000000000000000000000000..76bf3287e05c0a5ee5e4af7f025b145e902840b9 Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_arrow_bend_left_top.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_arrow_bottom.png b/core/assets/common/_global/application/dialog/bubble_arrow_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..52858de2bd584ffdb0302887421fc46e3d204a26 Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_arrow_bottom.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_arrow_left.png b/core/assets/common/_global/application/dialog/bubble_arrow_left.png new file mode 100644 index 0000000000000000000000000000000000000000..4af146ada9cbc7a802c1fedaf695ff051bb633de Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_arrow_left.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_arrow_right.png b/core/assets/common/_global/application/dialog/bubble_arrow_right.png new file mode 100644 index 0000000000000000000000000000000000000000..eee63640d0f80393689e80abf3bfdc770bd56b86 Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_arrow_right.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_arrow_top.png b/core/assets/common/_global/application/dialog/bubble_arrow_top.png new file mode 100644 index 0000000000000000000000000000000000000000..03a8be1ae99dada6cd9743cfec9c5827bd055628 Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_arrow_top.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_classic_bottom.png b/core/assets/common/_global/application/dialog/bubble_classic_bottom.png index e7f4bd67203c9ee7372960db1a06d4a787b13d37..2cf48fb63c3b535194068712a0cb0f4ed74bb3ef 100644 Binary files a/core/assets/common/_global/application/dialog/bubble_classic_bottom.png and b/core/assets/common/_global/application/dialog/bubble_classic_bottom.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_classic_left.png b/core/assets/common/_global/application/dialog/bubble_classic_left.png new file mode 100644 index 0000000000000000000000000000000000000000..578340bcc420db76ddfb22aa64adf533653e5c18 Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_classic_left.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_classic_pure.9.png b/core/assets/common/_global/application/dialog/bubble_classic_pure.9.png deleted file mode 100644 index 8691e269318802c88eb7331779b1b4fa1c709e3f..0000000000000000000000000000000000000000 Binary files a/core/assets/common/_global/application/dialog/bubble_classic_pure.9.png and /dev/null differ diff --git a/core/assets/common/_global/application/dialog/bubble_classic_right.png b/core/assets/common/_global/application/dialog/bubble_classic_right.png new file mode 100644 index 0000000000000000000000000000000000000000..2693875c4cce16104db9982c1bde97ca218377c1 Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_classic_right.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_classic_round.9.png b/core/assets/common/_global/application/dialog/bubble_classic_round.9.png new file mode 100644 index 0000000000000000000000000000000000000000..63bb6235f0f344142f70fbefc07a663f58c60663 Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_classic_round.9.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_classic_square.9.png b/core/assets/common/_global/application/dialog/bubble_classic_square.9.png new file mode 100644 index 0000000000000000000000000000000000000000..dd35fc71b9b8a39402355abbca2543a4b4f35585 Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_classic_square.9.png differ diff --git a/core/assets/common/_global/application/dialog/bubble_classic_top.png b/core/assets/common/_global/application/dialog/bubble_classic_top.png new file mode 100644 index 0000000000000000000000000000000000000000..b11dd5dc096273ba765940510d892dffac9f597e Binary files /dev/null and b/core/assets/common/_global/application/dialog/bubble_classic_top.png differ diff --git a/core/assets/common/game/robbery/gamescreen/background_bank.png b/core/assets/common/game/robbery/gamescreen/background_bank.png index 58642f677a8f6f3fcc379bf4b4e78cb502b26743..4216324568b615bd3d36637e8f5c66197fe88ada 100644 Binary files a/core/assets/common/game/robbery/gamescreen/background_bank.png and b/core/assets/common/game/robbery/gamescreen/background_bank.png differ diff --git a/core/assets/common/game/robbery/gamescreen/background_bank_bottom.png b/core/assets/common/game/robbery/gamescreen/background_bank_bottom.png index e3b8c7d9e93435ab587b0a0eb73e3d60892ba53d..8cdb84def979463d9e923147dedb670d6fac9e70 100644 Binary files a/core/assets/common/game/robbery/gamescreen/background_bank_bottom.png and b/core/assets/common/game/robbery/gamescreen/background_bank_bottom.png differ diff --git a/core/assets/common/game/robbery/gamescreen/background_jewellery.png b/core/assets/common/game/robbery/gamescreen/background_jewellery.png index 166d569a74e6909d64304f6fcd9fddce5aef0f9a..40d082e1982652f4fcee7c1d7b34e73dc15790bf 100644 Binary files a/core/assets/common/game/robbery/gamescreen/background_jewellery.png and b/core/assets/common/game/robbery/gamescreen/background_jewellery.png differ diff --git a/core/assets/common/game/robbery/gamescreen/background_jewellery_bottom.png b/core/assets/common/game/robbery/gamescreen/background_jewellery_bottom.png index c95b54ce6c4e138327fb354b90a59e9a68f09dfb..bf8b0d72bfad549fab37ecb1a86830fc142e5381 100644 Binary files a/core/assets/common/game/robbery/gamescreen/background_jewellery_bottom.png and b/core/assets/common/game/robbery/gamescreen/background_jewellery_bottom.png differ diff --git a/core/assets/common/game/robbery/gamescreen/background_newsstand.png b/core/assets/common/game/robbery/gamescreen/background_newsstand.png index 4088b0b1419be2db1ebc9067790374c508e5dd4b..527eca74aea98211dc31d00013d352cce87c3fc6 100644 Binary files a/core/assets/common/game/robbery/gamescreen/background_newsstand.png and b/core/assets/common/game/robbery/gamescreen/background_newsstand.png differ diff --git a/core/assets/common/game/robbery/gamescreen/background_newsstand_bottom.png b/core/assets/common/game/robbery/gamescreen/background_newsstand_bottom.png index 9eae098bdcbd462bafa13dcc632af0e0643aca19..87263c38d62bdaf06361c553bbfa3d13db2f47a6 100644 Binary files a/core/assets/common/game/robbery/gamescreen/background_newsstand_bottom.png and b/core/assets/common/game/robbery/gamescreen/background_newsstand_bottom.png differ diff --git a/core/assets/common/game/robbery/gamescreen/door_background.png b/core/assets/common/game/robbery/gamescreen/door_background.png index ba3a39c17df18a2885c4db0216154ce53f8819a4..91e02a162c00f1f4c5978d3bf8c520c6040f3e2d 100644 Binary files a/core/assets/common/game/robbery/gamescreen/door_background.png and b/core/assets/common/game/robbery/gamescreen/door_background.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/bankovniloupez_back.png b/core/assets/common/screen/gamemenu/gfx/bankovniloupez_back.png index d9d3c637e1255f67af94b207b0d9fd6883fb4772..3159e8e6cd55c6d5ad3fea28a8bd185b0e1fbd32 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/bankovniloupez_back.png and b/core/assets/common/screen/gamemenu/gfx/bankovniloupez_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/bankovniloupez_fore.png b/core/assets/common/screen/gamemenu/gfx/bankovniloupez_fore.png index 59057615e33af54d54e6b28fd18da85c705a9b00..7122f089fb2e11d6345615600e2690cb50d9fb4a 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/bankovniloupez_fore.png and b/core/assets/common/screen/gamemenu/gfx/bankovniloupez_fore.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/bankovniloupez_mid.png b/core/assets/common/screen/gamemenu/gfx/bankovniloupez_mid.png index 74775e68cb0df75051b39285e3c386e53348c2d9..3b1cc0dda92d871c2a491a9530ae2d23dd199923 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/bankovniloupez_mid.png and b/core/assets/common/screen/gamemenu/gfx/bankovniloupez_mid.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/clickablemap.png b/core/assets/common/screen/gamemenu/gfx/clickablemap.png index 73f656ead93ad3c7254dc2c462595db870ec2547..bdeadd17d82ad54416a42ed3fb3c5e4c6ecc23cf 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/clickablemap.png and b/core/assets/common/screen/gamemenu/gfx/clickablemap.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/desk.png b/core/assets/common/screen/gamemenu/gfx/desk.png index 38fc8f00f6ac77a0aa08429bc99265a755f6a251..0bb46440af168b3e8cc03a1a50d974b7734d3a4b 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/desk.png and b/core/assets/common/screen/gamemenu/gfx/desk.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/encyclopedia_pressed.png b/core/assets/common/screen/gamemenu/gfx/encyclopedia_pressed.png index 74db6065095ddb394f41fbea5dbd6776d5f9c2b4..038d8bb801c47957e2aecc01b6846106811443e8 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/encyclopedia_pressed.png and b/core/assets/common/screen/gamemenu/gfx/encyclopedia_pressed.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/halloffame_pressed.png b/core/assets/common/screen/gamemenu/gfx/halloffame_pressed.png index 2b3f290191f25e8c2b6d15267c1e3be3e70396b3..67f57dc512943123067bb0ccdeaa5b6dd2688a9d 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/halloffame_pressed.png and b/core/assets/common/screen/gamemenu/gfx/halloffame_pressed.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/nocnisledovani_back.png b/core/assets/common/screen/gamemenu/gfx/nocnisledovani_back.png index 663b9c0d5236dfe49b6090a53b9a8ac8d4e27bed..4d6ca9b284bf55814892f65708957d8857e4ca69 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/nocnisledovani_back.png and b/core/assets/common/screen/gamemenu/gfx/nocnisledovani_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/nocnisledovani_fore.png b/core/assets/common/screen/gamemenu/gfx/nocnisledovani_fore.png index 4f3727508f0cbef101f675d490ede92f8d4911c6..6bb038fad6d47ffa797a2db95cdc91c4e1767776 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/nocnisledovani_fore.png and b/core/assets/common/screen/gamemenu/gfx/nocnisledovani_fore.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/nocnisledovani_mid.png b/core/assets/common/screen/gamemenu/gfx/nocnisledovani_mid.png index c2ec630adcf5a9dbf548fd17a0e3096b26ff1625..19878ce681e77a4d2464ed8a2ac20f92811b5303 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/nocnisledovani_mid.png and b/core/assets/common/screen/gamemenu/gfx/nocnisledovani_mid.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/office.jpg b/core/assets/common/screen/gamemenu/gfx/office.jpg index a99af7be97b9f6c09cbe90796f19d906a248e1b4..5c1317971e1101ba8f81ed6e10a02fa3ad3555ab 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/office.jpg and b/core/assets/common/screen/gamemenu/gfx/office.jpg differ diff --git a/core/assets/common/screen/gamemenu/gfx/potme_back.png b/core/assets/common/screen/gamemenu/gfx/potme_back.png index 6eabf1d99e7bed3f680584bb6fbfadae3a538e70..fb154eb87931ba20afae1f0680ce1dc8689b4f56 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/potme_back.png and b/core/assets/common/screen/gamemenu/gfx/potme_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/potme_fore.png b/core/assets/common/screen/gamemenu/gfx/potme_fore.png index 723044ed2001fd145670b2b415cd5b414f4dfbf5..fc6e05da64924bd821846118719c2748183ffd31 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/potme_fore.png and b/core/assets/common/screen/gamemenu/gfx/potme_fore.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/potme_mid.png b/core/assets/common/screen/gamemenu/gfx/potme_mid.png index 017bffca99d67c5d5f5c96948a1d3dbe1620d71b..b95a10439e9798ce0a3c334f2141974308d31eb8 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/potme_mid.png and b/core/assets/common/screen/gamemenu/gfx/potme_mid.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/profile_pressed.png b/core/assets/common/screen/gamemenu/gfx/profile_pressed.png index 2c2e54e9b36f299988c011522fdb55e61e607e25..baa46a7d1e20e71f9a18ebde6d1a6fded85d3e1a 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/profile_pressed.png and b/core/assets/common/screen/gamemenu/gfx/profile_pressed.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/pronasledovani_back.png b/core/assets/common/screen/gamemenu/gfx/pronasledovani_back.png index cf8a55f8c84d57c0120a450fbf5b4260b71c9299..a975f5114df47eb0a5c985b42aad0b3dad3491aa 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/pronasledovani_back.png and b/core/assets/common/screen/gamemenu/gfx/pronasledovani_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/pronasledovani_fore.png b/core/assets/common/screen/gamemenu/gfx/pronasledovani_fore.png index 753143e8a2809687a62696bf9dc590262888da07..45cd8108d686ce060258ac94a645a8f15d49a376 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/pronasledovani_fore.png and b/core/assets/common/screen/gamemenu/gfx/pronasledovani_fore.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/pronasledovani_mid.png b/core/assets/common/screen/gamemenu/gfx/pronasledovani_mid.png index a97adfee1cc802af3795a8089e59ae6e0ed51aad..f4f56c2abcd4188492797e67d9b93cca3b647fcb 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/pronasledovani_mid.png and b/core/assets/common/screen/gamemenu/gfx/pronasledovani_mid.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/statistics_pressed.png b/core/assets/common/screen/gamemenu/gfx/statistics_pressed.png index bebbb128babf83e47ee69a41852d63938206236b..0a1bee859e4e980d1b29ae7c86a42211acbdd8af 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/statistics_pressed.png and b/core/assets/common/screen/gamemenu/gfx/statistics_pressed.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/streetdoor_pressed.png b/core/assets/common/screen/gamemenu/gfx/streetdoor_pressed.png index af4b3a8e16edf7211a31ec22be11c1decbcc3ed6..b230009f86f0334feb23859295e7ccd5a9de8354 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/streetdoor_pressed.png and b/core/assets/common/screen/gamemenu/gfx/streetdoor_pressed.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/strelnice_back.png b/core/assets/common/screen/gamemenu/gfx/strelnice_back.png index 10333b95475123376c6067f3c1d34f025d57a04e..bef8bf9a378eeed3687639e132f593ea5583146e 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/strelnice_back.png and b/core/assets/common/screen/gamemenu/gfx/strelnice_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/strelnice_fore.png b/core/assets/common/screen/gamemenu/gfx/strelnice_fore.png index c4a0a41e2e8e05225247bafb190d0ec910043e39..ac1fbe83a618a48c808089bfd6062d6dd8c1623c 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/strelnice_fore.png and b/core/assets/common/screen/gamemenu/gfx/strelnice_fore.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/strelnice_mid.png b/core/assets/common/screen/gamemenu/gfx/strelnice_mid.png index f543837c39eb520cd93aeb74baa5d991684191d0..b5cb9216ae8cff7cff6313f54de0ebd99992cfd1 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/strelnice_mid.png and b/core/assets/common/screen/gamemenu/gfx/strelnice_mid.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/unos_back.png b/core/assets/common/screen/gamemenu/gfx/unos_back.png index 7d6448ea367f76be9c1b5f2bf172a45d2fa8e301..2690d439d6618707eabbafe6e9f3e4146f72abb7 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/unos_back.png and b/core/assets/common/screen/gamemenu/gfx/unos_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/unos_fore.png b/core/assets/common/screen/gamemenu/gfx/unos_fore.png index a741561713869570be5e47648fc414190df73d1a..c1256d7b5cd5a131963504d4f8a15e2a0dd9af30 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/unos_fore.png and b/core/assets/common/screen/gamemenu/gfx/unos_fore.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/unos_mid.png b/core/assets/common/screen/gamemenu/gfx/unos_mid.png index 2ba240c927532ba1052b7b832a984a2d5eaffac8..a7a40d342be850b433f049ad3a8bf7debcfdca96 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/unos_mid.png and b/core/assets/common/screen/gamemenu/gfx/unos_mid.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/vignetting.png b/core/assets/common/screen/gamemenu/gfx/vignetting.png index c9247ca51177da00cb240b86720de9699deb450e..afc4309686c011fa527dc6f519e712c7890bf242 100644 Binary files a/core/assets/common/screen/gamemenu/gfx/vignetting.png and b/core/assets/common/screen/gamemenu/gfx/vignetting.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/wall_back.png b/core/assets/common/screen/gamemenu/gfx/wall_back.png new file mode 100644 index 0000000000000000000000000000000000000000..3159e8e6cd55c6d5ad3fea28a8bd185b0e1fbd32 Binary files /dev/null and b/core/assets/common/screen/gamemenu/gfx/wall_back.png differ diff --git a/core/assets/common/screen/gamemenu/gfx/wall_mid.png b/core/assets/common/screen/gamemenu/gfx/wall_mid.png new file mode 100644 index 0000000000000000000000000000000000000000..215716a44d7011edc92caf71a0c0fcf1cdaf6f93 Binary files /dev/null and b/core/assets/common/screen/gamemenu/gfx/wall_mid.png differ diff --git a/core/assets/common/screen/panorama/gfx/balcony.jpg b/core/assets/common/screen/panorama/gfx/balcony.jpg index b3f094f3b8e399abd1ef3803e545169897721f1b..7ccc10b38ae036de57bb7a3299eb2091ec24d778 100644 Binary files a/core/assets/common/screen/panorama/gfx/balcony.jpg and b/core/assets/common/screen/panorama/gfx/balcony.jpg differ diff --git a/core/assets/common/screen/panorama/gfx/balcony_blur.jpg b/core/assets/common/screen/panorama/gfx/balcony_blur.jpg new file mode 100644 index 0000000000000000000000000000000000000000..265394f5a161502daf3afdf7d927e2aff860ed07 Binary files /dev/null and b/core/assets/common/screen/panorama/gfx/balcony_blur.jpg differ diff --git a/core/assets/common/screen/panorama/gfx/balcony_blur.png b/core/assets/common/screen/panorama/gfx/balcony_blur.png deleted file mode 100644 index 8a53b2d509c0912dcc6dc6939a3d1936ea09d33b..0000000000000000000000000000000000000000 Binary files a/core/assets/common/screen/panorama/gfx/balcony_blur.png and /dev/null differ diff --git a/core/assets/common/screen/panorama/gfx/balcony_blur_winter.jpg b/core/assets/common/screen/panorama/gfx/balcony_blur_winter.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a1edc36dd7b30b58456a22e88c9c2fb57a7b69a8 Binary files /dev/null and b/core/assets/common/screen/panorama/gfx/balcony_blur_winter.jpg differ diff --git a/core/assets/common/screen/panorama/gfx/balcony_blur_winter.png b/core/assets/common/screen/panorama/gfx/balcony_blur_winter.png deleted file mode 100644 index 4566f553b7f0e5c1452d0065b9d07fecb844adea..0000000000000000000000000000000000000000 Binary files a/core/assets/common/screen/panorama/gfx/balcony_blur_winter.png and /dev/null differ diff --git a/core/assets/common/screen/panorama/gfx/balcony_winter.jpg b/core/assets/common/screen/panorama/gfx/balcony_winter.jpg index 76f8ebcf04fa2f0746f1bc016563b0302484b1c5..47ffe5c9aa6eb30b133774cd39c596ef67ba064e 100644 Binary files a/core/assets/common/screen/panorama/gfx/balcony_winter.jpg and b/core/assets/common/screen/panorama/gfx/balcony_winter.jpg differ diff --git a/core/assets/common/screen/panorama/gfx/detectiveoffice.jpg b/core/assets/common/screen/panorama/gfx/detectiveoffice.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d9de04159214ce47e5862631dc6995e4c8769619 Binary files /dev/null and b/core/assets/common/screen/panorama/gfx/detectiveoffice.jpg differ diff --git a/core/assets/common/screen/panorama/gfx/detectiveoffice.png b/core/assets/common/screen/panorama/gfx/detectiveoffice.png deleted file mode 100644 index 0a6a534aa775bcc1548467cc47f7c066f52da70a..0000000000000000000000000000000000000000 Binary files a/core/assets/common/screen/panorama/gfx/detectiveoffice.png and /dev/null differ diff --git a/core/assets/cs/screen/gamemenu/gfx/helplayer.png b/core/assets/cs/screen/gamemenu/gfx/helplayer.png index ef6ac7ca9283901add57541243ccbe741c211fc9..c1b39c46f1b6b8ee5bf4e24ca669fc0d60c45d47 100644 Binary files a/core/assets/cs/screen/gamemenu/gfx/helplayer.png and b/core/assets/cs/screen/gamemenu/gfx/helplayer.png differ diff --git a/core/assets/cs/screen/gamemenu/gfx/office_halloffame.png b/core/assets/cs/screen/gamemenu/gfx/office_halloffame.png index 0191b1b1150ebe094b0fa6e3df17055103b07cc6..6115eefc07263d8f6d956e6350847e9dc1650f12 100644 Binary files a/core/assets/cs/screen/gamemenu/gfx/office_halloffame.png and b/core/assets/cs/screen/gamemenu/gfx/office_halloffame.png differ diff --git a/core/assets/de/screen/gamemenu/gfx/helplayer.png b/core/assets/de/screen/gamemenu/gfx/helplayer.png index 0f08331881f098a49acedf33d635d0c3cf595cd7..f969bf79336e9a3cdfdf4684311e8625817e9e05 100644 Binary files a/core/assets/de/screen/gamemenu/gfx/helplayer.png and b/core/assets/de/screen/gamemenu/gfx/helplayer.png differ diff --git a/core/assets/de/screen/gamemenu/gfx/office_halloffame.png b/core/assets/de/screen/gamemenu/gfx/office_halloffame.png index b541934e5c5485b3c3ed05bda78d3bb41621f02b..76da8970904be5fd64fd1523c38117ea68563fa3 100644 Binary files a/core/assets/de/screen/gamemenu/gfx/office_halloffame.png and b/core/assets/de/screen/gamemenu/gfx/office_halloffame.png differ diff --git a/core/assets/sk/screen/gamemenu/gfx/helplayer.png b/core/assets/sk/screen/gamemenu/gfx/helplayer.png index 70305da923c04fc5b20aa96f9f5e454e76e27c75..e52d0c7fc701dcbfe50607fce766519803f42d8f 100644 Binary files a/core/assets/sk/screen/gamemenu/gfx/helplayer.png and b/core/assets/sk/screen/gamemenu/gfx/helplayer.png differ diff --git a/core/assets/sk/screen/gamemenu/gfx/office_halloffame.png b/core/assets/sk/screen/gamemenu/gfx/office_halloffame.png index c63ee22cdfc03350eac55b9e845f4b55ce020279..6191821d41be87f6259256772c17b7df37e0f950 100644 Binary files a/core/assets/sk/screen/gamemenu/gfx/office_halloffame.png and b/core/assets/sk/screen/gamemenu/gfx/office_halloffame.png differ diff --git a/core/src/cz/nic/tablexia/TablexiaSettings.java b/core/src/cz/nic/tablexia/TablexiaSettings.java index 0c032bc1367996d73d7b330500ffeb5335498b1d..f4eaf6ef900e93994e084dff618a23293a9efaf3 100644 --- a/core/src/cz/nic/tablexia/TablexiaSettings.java +++ b/core/src/cz/nic/tablexia/TablexiaSettings.java @@ -9,7 +9,6 @@ import java.util.Locale; import cz.nic.tablexia.bus.ApplicationBus; import cz.nic.tablexia.game.GameDefinition; import cz.nic.tablexia.game.difficulty.GameDifficulty; -import cz.nic.tablexia.game.games.kidnapping.KidnappingGame; import cz.nic.tablexia.loader.application.ApplicationTextManager; import cz.nic.tablexia.model.User; import cz.nic.tablexia.screen.AbstractTablexiaScreen; diff --git a/core/src/cz/nic/tablexia/game/games/robbery/GameScreen.java b/core/src/cz/nic/tablexia/game/games/robbery/GameScreen.java index 8a3cf508369bbf1a7e41e28e98bf0df19c9dd247..88a44b02da0d6e7ff8253b4deb4773a9321c65af 100644 --- a/core/src/cz/nic/tablexia/game/games/robbery/GameScreen.java +++ b/core/src/cz/nic/tablexia/game/games/robbery/GameScreen.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.Action; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; +import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.actions.DelayAction; import com.badlogic.gdx.scenes.scene2d.actions.RunnableAction; @@ -20,6 +21,7 @@ import java.util.List; import java.util.Map; import java.util.Random; +import cz.nic.tablexia.TablexiaSettings; import cz.nic.tablexia.game.difficulty.GameDifficulty; import cz.nic.tablexia.game.games.robbery.assets.RobberyAssets; import cz.nic.tablexia.game.games.robbery.creature.CreatureRoot; @@ -105,7 +107,7 @@ public class GameScreen extends AbstractRobberyScreen { } } - public static void init(Group infoItemLayer, Group colorInfoLayer, SceneBackground sceneBackground, AbstractRobberyScreen abstractRobberyScreen) { + public static void init(Stage stage, Group infoItemLayer, Group colorInfoLayer, SceneBackground sceneBackground, AbstractRobberyScreen abstractRobberyScreen) { for (InfoItem container : InfoItem.values()) { container.init(abstractRobberyScreen); container.infoItemGroup.setVisible(false); @@ -115,7 +117,7 @@ public class GameScreen extends AbstractRobberyScreen { colorInfoLayer.addActor(container.infoBanner); } } - calculateDimensions(infoItemLayer.getStage().getWidth(), infoItemLayer.getStage().getHeight(), sceneBackground); + calculateDimensions(TablexiaSettings.getSceneWidth(stage), TablexiaSettings.getSceneOuterHeight(stage), sceneBackground); } public static void calculateDimensions(float width, float height, SceneBackground sceneBackground) { @@ -139,9 +141,9 @@ public class GameScreen extends AbstractRobberyScreen { private enum SceneBackground { - NEWSSTAND (GameDifficulty.EASY, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND_BOTTOM, 11f/36, 2f/7), - JEWELLERY (GameDifficulty.MEDIUM, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY_BOTTOM, 59f/160, 2f/7), - BANK (GameDifficulty.HARD, RobberyAssets.SCREEN_BACKGROUND_BANK, RobberyAssets.SCREEN_BACKGROUND_BANK_BOTTOM, 23f/72, 9f/28); + NEWSSTAND (GameDifficulty.EASY, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND, RobberyAssets.SCREEN_BACKGROUND_NEWSSTAND_BOTTOM, 11f/36, 1f/6), + JEWELLERY (GameDifficulty.MEDIUM, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY, RobberyAssets.SCREEN_BACKGROUND_JEWELLERY_BOTTOM, 59f/160, 1f/6), + BANK (GameDifficulty.HARD, RobberyAssets.SCREEN_BACKGROUND_BANK, RobberyAssets.SCREEN_BACKGROUND_BANK_BOTTOM, 23f/72, 1f/5); private final GameDifficulty gameDifficulty; private final String sceneBackground; @@ -228,7 +230,7 @@ public class GameScreen extends AbstractRobberyScreen { private static final float COLORBANNER_WIDTH_RATIO = 1f/3; private static final float PERSON_COUNTER_POSITION_X_RATIO = 5f/6; - private static final float PERSON_COUNTER_POSITION_Y_RATIO = 1f/4; + private static final float PERSON_COUNTER_POSITION_Y_RATIO = 1f/8; private static final Color PERSON_COUNTER_TEXT_COLOR = Color.WHITE; private static final ApplicationFontManager.FontType PERSON_COUNTER_FONT = ApplicationFontManager.FontType.ROBOTO_BOLD_20; @@ -307,12 +309,12 @@ public class GameScreen extends AbstractRobberyScreen { sceneBackground = new Image(getScreenTextureRegion(sceneBackgroundDefinition.getSceneBackground())); sceneBackgroundBottom = new Image(getScreenTextureRegion(sceneBackgroundDefinition.getSceneBackgroundBottom(), false)); - float width = getStage().getWidth(); - float height = getStage().getHeight(); + float width = getSceneWidth(); + float height = getSceneOuterHeight(); setActorToFullScene(sceneBackground); sceneBackground.setTouchable(Touchable.disabled); - doorBackground.setBounds(getSceneLeftX(), getSceneInnerBottomY(), width, height); + doorBackground.setBounds(getSceneLeftX(), getSceneOuterBottomY(), width, height); sceneBackgroundBottom.setBounds(getSceneLeftX() + BACKGROUND_BOTTOM_POSITION_X_CORRECTION_OFFSET, getSceneOuterBottomY(), getSceneWidth() + BACKGROUND_BOTTOM_WIDTH_CORRECTION_OFFSET, @@ -329,7 +331,7 @@ public class GameScreen extends AbstractRobberyScreen { getStage().addActor(infoItemLayer); getStage().addActor(personCounter); - InfoItem.init(infoItemLayer, colorInfoLayer, sceneBackgroundDefinition, this); + InfoItem.init(getStage(), infoItemLayer, colorInfoLayer, sceneBackgroundDefinition, this); prepareCreaturePositions(getSceneWidth(), getSceneInnerHeight()); } diff --git a/core/src/cz/nic/tablexia/game/games/shooting_range/tools/ShootingRangeResultResolver.java b/core/src/cz/nic/tablexia/game/games/shooting_range/tools/ShootingRangeResultResolver.java index 69bbd0e77d10deaf9137bdac0fa0fd25c96ec7b0..ea62aef3a1cc34f66c1aafcc6418f3b9f69932cf 100644 --- a/core/src/cz/nic/tablexia/game/games/shooting_range/tools/ShootingRangeResultResolver.java +++ b/core/src/cz/nic/tablexia/game/games/shooting_range/tools/ShootingRangeResultResolver.java @@ -12,7 +12,7 @@ public class ShootingRangeResultResolver implements GameDefinition.GameResultRes @Override public AbstractTablexiaGame.GameResult getGameResult(Game game) { int[][] CUPS = {Properties.CUPS_EASY, Properties.CUPS_MEDIUM, Properties.CUPS_HARD}; - int gameScore = Integer.valueOf(game.getGameScore(Properties.SCORE_TOTAL)); + int gameScore = Integer.valueOf(game.getGameScore(Properties.SCORE_TOTAL, "0")); int gameDificultyOrdinal = game.getDifficulty().getDifficultyNumber() -1; if (gameScore > CUPS[gameDificultyOrdinal][2]) { diff --git a/core/src/cz/nic/tablexia/game/trophy/TrophyReceivedDialog.java b/core/src/cz/nic/tablexia/game/trophy/TrophyReceivedDialog.java index b0e0522499b37085f90ad8a65fad91c21cecd4fd..fc7a7e2e43d63ab49b3eac8cdcfd434c76a38233 100644 --- a/core/src/cz/nic/tablexia/game/trophy/TrophyReceivedDialog.java +++ b/core/src/cz/nic/tablexia/game/trophy/TrophyReceivedDialog.java @@ -1,6 +1,7 @@ package cz.nic.tablexia.game.trophy; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.ui.Label; @@ -9,7 +10,6 @@ import com.badlogic.gdx.utils.Align; import java.util.HashMap; import java.util.Map; -import java.util.Objects; import cz.nic.tablexia.Tablexia; import cz.nic.tablexia.TablexiaApplication; @@ -30,9 +30,9 @@ public class TrophyReceivedDialog extends TablexiaDialog { private static final int DIALOG_OFFSET = 20; private static final int DIALOG_WIDTH = 200; private static final int DIALOG_HEIGHT = 150; - private static final float TITLE_FONT_SCALE = 0.7f; - private static final float CONTENT_FONT_SCALE = 0.5f; private static final int MAX_NUMBER_OF_TROPHIES_TO_DISPLAY = 4; + private static final BitmapFont DIALOG_BIGGER_FONT = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_14); + private static final BitmapFont DIALOG_NORMAL_FONT = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_12); private ITrophyDefinition trophy; private TextureRegion trophyTexture; @@ -58,15 +58,15 @@ public class TrophyReceivedDialog extends TablexiaDialog { String desc = ApplicationTextManager.getInstance().getText(trophy.getTrophyDescription()); String title = ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.VICTORYSCREEN_NEW_TROPHY); - this.addLabel(title, new Label.LabelStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(), Color.BLACK), Align.center, TITLE_FONT_SCALE); + this.addLabel(title, new Label.LabelStyle(DIALOG_BIGGER_FONT, Color.BLACK), Align.center); this.getContentTable().row(); this.addImage(trophyTexture, 1); this.getContentTable().row(); - this.addLabel(name, new Label.LabelStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(), Color.BLACK), Align.center, TITLE_FONT_SCALE); + this.addLabel(name, new Label.LabelStyle(DIALOG_BIGGER_FONT, Color.BLACK), Align.center); this.getContentTable().row(); - this.addLabel(desc, new Label.LabelStyle(ApplicationFontManager.getInstance().getDefaultApplicationRegularFont(), Color.GRAY), Align.center, CONTENT_FONT_SCALE); + this.addLabel(desc, new Label.LabelStyle(DIALOG_NORMAL_FONT, Color.GRAY), Align.center); super.prepareContent(); } @@ -165,13 +165,15 @@ public class TrophyReceivedDialog extends TablexiaDialog { final Placeholder other = ((Placeholder) otherObj); - return Objects.equals(getTotal(), other.getTotal()) - && Objects.equals(getActual(), other.getActual()); + return (getTotal() == other.getTotal() && getActual() == other.getActual()); } @Override public int hashCode() { - return Objects.hash(getTotal(), getActual()); + int code = 0; + code += getTotal() * 13; + code += getActual() * 53; + return code; } } } diff --git a/core/src/cz/nic/tablexia/loader/application/ApplicationAtlasManager.java b/core/src/cz/nic/tablexia/loader/application/ApplicationAtlasManager.java index 8a6aec534e71f95a05e25b0113605f7dd9965226..c48735a9651893dcdc987e6588ad12b3e8e9fd0a 100644 --- a/core/src/cz/nic/tablexia/loader/application/ApplicationAtlasManager.java +++ b/core/src/cz/nic/tablexia/loader/application/ApplicationAtlasManager.java @@ -60,15 +60,30 @@ public class ApplicationAtlasManager extends TablexiaAtlasManager implements IAp public static final String DIALOG_PATH = "dialog/"; public static final String DIALOG_BUBBLE_CLASSIC = DIALOG_PATH + "bubble_classic"; - public static final String DIALOG_BUBBLE_CLASSIC_PURE = DIALOG_PATH + "bubble_classic_pure"; - public static final String DIALOG_BUBBLE_CLASSIC_BOTTOM = DIALOG_PATH + "bubble_classic_bottom"; + public static final String DIALOG_BUBBLE_CLASSIC_ROUND = DIALOG_PATH + "bubble_classic_round"; + public static final String DIALOG_BUBBLE_CLASSIC_SQUARE = DIALOG_PATH + "bubble_classic_square"; public static final String DIALOG_BUBBLE_ARROW_DOWN = DIALOG_PATH + "bubble_arrow_down"; - public static final String DIALOG_BUBBLE_ARROW_LEFT = DIALOG_PATH + "bubble_arrow_left"; + public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT = DIALOG_PATH + "bubble_arrow_bend_left"; public static final String DIALOG_BUBBLE_CLASSIC_CONTINUE_BUTTON = DIALOG_PATH + "bubble_classic_continue_button"; public static final String DIALOG_RECTANGLE = DIALOG_PATH + "dialog_rectangle"; public static final String DIALOG_SQUARE = DIALOG_PATH + "dialog_square"; public static final String DIALOG_SQUARE_BORDER_LINES = DIALOG_PATH + "dialog_square_borderlines"; + public static final String DIALOG_BUBBLE_ARROW_BOTTOM = DIALOG_PATH + "bubble_arrow_bottom"; + public static final String DIALOG_BUBBLE_ARROW_TOP = DIALOG_PATH + "bubble_arrow_top"; + public static final String DIALOG_BUBBLE_ARROW_LEFT = DIALOG_PATH + "bubble_arrow_left"; + public static final String DIALOG_BUBBLE_ARROW_RIGHT = DIALOG_PATH + "bubble_arrow_right"; + + public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT_BOTTOM = DIALOG_PATH + "bubble_arrow_bend_left_bottom"; + public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT_TOP = DIALOG_PATH + "bubble_arrow_bend_left_top"; + public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT_LEFT = DIALOG_PATH + "bubble_arrow_bend_left_left"; + public static final String DIALOG_BUBBLE_ARROW_BEND_LEFT_RIGHT = DIALOG_PATH + "bubble_arrow_bend_left_right"; + + public static final String DIALOG_BUBBLE_CLASSIC_BOTTOM = DIALOG_PATH + "bubble_classic_bottom"; + public static final String DIALOG_BUBBLE_CLASSIC_TOP = DIALOG_PATH + "bubble_classic_top"; + public static final String DIALOG_BUBBLE_CLASSIC_LEFT = DIALOG_PATH + "bubble_classic_left"; + public static final String DIALOG_BUBBLE_CLASSIC_RIGHT = DIALOG_PATH + "bubble_classic_right"; + public static final String BUTTON_PATH = "button/"; public static final String BUTTON_BLUE_PART = "tablexiabutton_blank_blue"; public static final String BUTTON_GREEN_PART = "tablexiabutton_blank_green"; diff --git a/core/src/cz/nic/tablexia/model/User.java b/core/src/cz/nic/tablexia/model/User.java index 5b51841e932850cbfedba7db8bb31b9c4c61b371..b8d5c0b82b196b1caa949d15bcd3ad5fdad342ff 100644 --- a/core/src/cz/nic/tablexia/model/User.java +++ b/core/src/cz/nic/tablexia/model/User.java @@ -238,6 +238,7 @@ public class User implements IMenuItem { updateStatement.setInt(1, user.isHelp() ? 1 : 0); updateStatement.setInt(2, user.isIntro() ? 1 : 0); updateStatement.setInt(3, user.isDeleted() ? 1 : 0); + updateStatement.setLong(4, user.getId()); updateStatement.executeUpdate(); updateStatement.close(); return true; diff --git a/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java b/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java index 1705986f90afb4622c548a1e9f02b5fdbf907f8f..39e598be623d1f33bb33cfa750132e6c55980347 100644 --- a/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java +++ b/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java @@ -180,8 +180,11 @@ public class FormScreen extends AbstractTablexiaScreen<Void> { }); // signature pen needs to be below pen and stamp - group.addActor(signaturePane = new SignaturePane()); - signaturePane.setBounds(600, getStage().getHeight() * 0.1f, 300, getStage().getHeight() * 0.2f); + signaturePane = new SignaturePane(); + group.addActor(signaturePane); + signaturePane.setBounds(getSceneWidth() / 2, getSceneInnerHeight() * 0.1f, getSceneInnerHeight() / 2, getSceneInnerHeight() * 0.1f); + + signaturePane.setDebug(TablexiaSettings.getInstance().isShowBoundingBoxes()); // pencil and stamp layers group.addActor(pen = ScaleUtil.createImageWidthPosition(getScreenTextureRegion(GFX_PATH + "pencil_dropped", false), getStage().getWidth() * 0.2f, getStage().getWidth() * 0.85f, getStage().getWidth() * -0.13f)); diff --git a/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java b/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java index 85cf097694684904c09bc16f955df3fb9d0d272d..3bfefaeacab635981a77329b433534e20b701758 100644 --- a/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java +++ b/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java @@ -104,7 +104,7 @@ public class PanoramaScreen extends AbstractTablexiaScreen<int[][]> { private Actor prepareBalcony() { final Group group = new Group(); ScaleUtil.setFullScreen(group, getStage()); - boolean isWinter = true; + boolean isWinter = false; Image balcony = new TablexiaNoBlendingImage(getScreenTextureRegion(isWinter ? BALCONY_WINTER : BALCONY)); setActorToFullScene(balcony); diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuAssets.java b/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuAssets.java index 0ae854e09b536f67dc69821789e3d9a25026a994..10b6ad395fd98e73330d46baf20dc43337f91607 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuAssets.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuAssets.java @@ -8,22 +8,13 @@ import cz.nic.tablexia.menu.game.GameMenuDefinition; /** * Created by lhoracek on 3/11/15. + * Edited by Drahomir Karchnak */ public final class GameMenuAssets { - private GameMenuAssets() { } - public enum GameMenuLayers { - FORE, - MID, - BACK, - TITLE, - STARTBUTTON, - STARTBUTTON_PRESSED - } - - private static final String GFX_PATH = "gfx/"; + public static final String GFX_PATH = "gfx/"; public static final String OFFICE = GFX_PATH + "office"; public static final String OFFICE_HALLOFFAME = GFX_PATH + "office_halloffame"; @@ -38,56 +29,15 @@ public final class GameMenuAssets { public static final String DOOR_PRESSED = GFX_PATH + "streetdoor_pressed"; public static final String PROFILE_PRESSED = GFX_PATH + "profile_pressed"; + public static final String HELP_BUTTON_PRESSED = GFX_PATH + "helpbutton_pressed"; + public static final String HELP_BUTTON_RELEASE = GFX_PATH + "helpbutton_unpressed"; + public static final String DIFF_BAR = GFX_PATH + "difficultyseekbar_background"; public static final String DIFF_THUMB = GFX_PATH + "difficultyseekbar_thumb"; public static final String DIFF_THUMB_EASY = GFX_PATH + "difficultyseekbar_thumb_easy"; public static final String DIFF_THUMB_HARD = GFX_PATH + "difficultyseekbar_thumb_hard"; public static final String DIFF_THUMB_MEDIUM = GFX_PATH + "difficultyseekbar_thumb_medium"; - public static final String GAME_ROBBERY_BASE = "bankovniloupez"; - public static final String GAME_PURSUIT_BASE = "pronasledovani"; - public static final String GAME_KIDNAPPING_BASE = "unos"; - public static final String GAME_SHOOTING_RANGE_BASE = "strelnice"; - public static final String GAME_NIGHT_WATCH_BASE = "nocnisledovani"; - public static final String GAME_IN_THE_DARKNESS_BASE = "potme"; - - public static final String TEXT_PATH = "text/gamemenu"; - - public static List<String> textures = new ArrayList<String>(); - - static { - textures.add(OFFICE); - textures.add(OFFICE_CLICKMAP); - textures.add(DESK); - textures.add(OFFICE_HELP); - textures.add(VIGNETTE); - textures.add(OVERLAY); - - textures.add(DIFF_BAR); - textures.add(DIFF_THUMB); - textures.add(DIFF_THUMB_EASY); - textures.add(DIFF_THUMB_HARD); - textures.add(DIFF_THUMB_MEDIUM); - - textures.add(ENCYCLOPEDIA_PRESSED); - textures.add(HALLOFFAME_PRESSED); - textures.add(STATISTICS_PRESSED); - textures.add(DOOR_PRESSED); - textures.add(PROFILE_PRESSED); - - String baseGameAsset = "MENU_GAME_"; - for (GameMenuDefinition gd : GameMenuDefinition.values()) { - for (GameMenuLayers gml : GameMenuLayers.values()) { - textures.add(getResourcePath(gd.getGameDefinition(), gml)); - } - } - } - - public static String getResourcePath(GameDefinition game, GameMenuLayers layer) { - try { - return GFX_PATH + (GameMenuAssets.class.getField("GAME_" + game.name() + "_BASE").get(null)) + "_" + layer.name().toLowerCase(); - } catch (Exception e) { - throw new IllegalArgumentException("Error generating path for " + game.name() + " " + layer.name()); - } - } + public static final String WALL_MID = GFX_PATH + "wall_mid"; + public static final String WALL_BACK = GFX_PATH + "wall_back"; } \ No newline at end of file diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuScreen.java b/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuScreen.java index 203cf598f68932396bdad944595056abb940ae34..0f2946f0c0b382c83550757971ed675010286a52 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuScreen.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/GameMenuScreen.java @@ -1,7 +1,6 @@ package cz.nic.tablexia.screen.gamemenu; import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.scenes.scene2d.Touchable; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.ui.Image; @@ -11,7 +10,6 @@ import net.engio.mbassy.listener.Handler; import java.util.HashMap; import java.util.Map; -import cz.nic.tablexia.TablexiaSettings; import cz.nic.tablexia.bus.ApplicationBus; import cz.nic.tablexia.game.GameDefinition; import cz.nic.tablexia.menu.game.GameMenuDefinition; @@ -21,42 +19,73 @@ import cz.nic.tablexia.screen.gamemenu.actions.ScrollHomeAction; import cz.nic.tablexia.screen.gamemenu.event.ShowGameMenuPageEvent; import cz.nic.tablexia.screen.gamemenu.pages.GameMenuPage; import cz.nic.tablexia.screen.gamemenu.pages.OfficeMenuPage; +import cz.nic.tablexia.screen.gamemenu.pages.WallPage; import cz.nic.tablexia.util.Utility; -import cz.nic.tablexia.util.ui.ViewPager; +import cz.nic.tablexia.util.ui.PagedScrollPane; +/** + * Created by lhoracek + * Edited by Drahomir Karchnak on 2/12/15 + */ public class GameMenuScreen extends AbstractTablexiaScreen<int[][]> { - public static final String SCREEN_STATE_PAGE_NUMBER = "pageNumber"; + public enum GameMenuLayers { + FORE, + MID, + BACK, + TITLE, + STARTBUTTON, + STARTBUTTON_PRESSED + } + public enum GameMenuPageDefinition { + OFFICE_PAGE(0, null, null), + ROBBERY_PAGE(1, GameDefinition.ROBBERY, "bankovniloupez"), + PURSUIT_PAGE(2, GameDefinition.PURSUIT, "pronasledovani"), + KIDNAPPING_PAGE(3, GameDefinition.KIDNAPPING, "unos"), + NIGH_WATCH_PAGE(4, GameDefinition.NIGHT_WATCH, "nocnisledovani"), + SHOOTING_RANGE_PAGE(5, GameDefinition.SHOOTING_RANGE, "strelnice"), + IN_THE_DARKNESS_PAGE(6, GameDefinition.IN_THE_DARKNESS, "potme"); - OFFICE_PAGE(0, null), - ROBBERY_PAGE(1, GameDefinition.ROBBERY), - PURSUIT_PAGE(2, GameDefinition.PURSUIT), - KIDNAPPING_PAGE(3, GameDefinition.KIDNAPPING), - NIGH_WATCH_PAGE(4, GameDefinition.NIGHT_WATCH), - SHOOTING_RANGE_PAGE(5, GameDefinition.SHOOTING_RANGE), - IN_THE_DARKNESS_PAGE(6, GameDefinition.IN_THE_DARKNESS); + private int pageNumber; + private GameDefinition gameDefinition; - private int pageNumber; - private GameDefinition gameDefinition; + //base path to assets without postfix(layer) like mid, back, title etc... + private String baseAssetsPath; - GameMenuPageDefinition(int pageNumber, GameDefinition gameDefinition) { + GameMenuPageDefinition(int pageNumber, GameDefinition gameDefinition, String baseAssetsPath) { this.pageNumber = pageNumber; this.gameDefinition = gameDefinition; + this.baseAssetsPath = baseAssetsPath; + } + + public String getBaseAssetsPath() { + return baseAssetsPath; } public int getPageNumber() { return pageNumber; } + public static String getResourcePath(GameDefinition gameDefinition, GameMenuLayers gameMenuLayer) { + for(GameMenuPageDefinition game : GameMenuPageDefinition.values()) { + if(gameDefinition.getGameNumber() == game.getPageNumber()) { + return GameMenuAssets.GFX_PATH + game.getBaseAssetsPath() + "_" + gameMenuLayer.name().toLowerCase(); + } + } + + throw new IllegalArgumentException("Couldn't find game base assets for game definition: " + gameDefinition.name()); + } + public static GameMenuPageDefinition getGameMenuPageForNumber(int gameMenuPageNumber) { for (GameMenuPageDefinition gameMenuPageDefinition : GameMenuPageDefinition.values()) { if (gameMenuPageDefinition.getPageNumber() == gameMenuPageNumber) { return gameMenuPageDefinition; } } - return null; + + throw new IllegalArgumentException("Couldn't find game definition for page number: " + gameMenuPageNumber); } public static GameMenuPageDefinition getGameMenuPageForGameDefinition(GameDefinition gameDefinition) { @@ -65,11 +94,12 @@ public class GameMenuScreen extends AbstractTablexiaScreen<int[][]> { return gameMenuPageDefinition; } } - return null; + throw new IllegalArgumentException("Couldn't find game page number for game definition: " + gameDefinition.name()); } } - private ViewPager vp; + private PagedScrollPane pagedScrollPane; + private Image vignette; @Override protected String prepareScreenTextResourcesAssetName() { @@ -79,57 +109,81 @@ public class GameMenuScreen extends AbstractTablexiaScreen<int[][]> { @Override protected void screenLoaded(Map<String, String> screenState) { - getStage().setDebugAll(TablexiaSettings.getInstance().isShowBoundingBoxes()); - vp = new ViewPager(); - vp.addPage(new OfficeMenuPage(this)); + pagedScrollPane = new PagedScrollPane(); + pagedScrollPane.setBounds(getSceneLeftX(), getSceneOuterBottomY(), getSceneWidth(), getSceneOuterHeight()); + + vignette = new Image(getScreenTextureRegion(GameMenuAssets.VIGNETTE)); + vignette.setTouchable(Touchable.disabled); + prepareVignetteAndPagerSize(); + + //Adds office + OfficeMenuPage officeMenuPage = new OfficeMenuPage(this); + officeMenuPage.setSize(getSceneWidth(), getSceneOuterHeight()); + pagedScrollPane.addPage(officeMenuPage); + + //Adds wall to separate office and street + pagedScrollPane.addPage(new WallPage(this)); + + //Adds other game menu pages for (GameMenuDefinition gd : GameMenuDefinition.values()) { - vp.addPage(new GameMenuPage(this, gd.getGameDefinition())); + GameMenuPage gameMenuPage = new GameMenuPage(this, gd.getGameDefinition()); + gameMenuPage.setSize( getSceneWidth(), getSceneOuterHeight()); + pagedScrollPane.addPage(gameMenuPage); } - vp.setSize(getStage().getWidth(), getStage().getHeight()); - vp.setCullingArea(new Rectangle(0, 0, vp.getWidth(), vp.getHeight())); - getStage().addActor(vp); + pagedScrollPane.layout(); + getStage().addActor(pagedScrollPane); - Image im = new Image(getScreenTextureRegion(GameMenuAssets.VIGNETTE)); - im.setTouchable(Touchable.disabled); - im.setSize(getStage().getWidth(), getStage().getHeight()); - getStage().addActor(im); + prepareVignetteAndPagerSize(); + getStage().addActor(vignette); ApplicationBus.getInstance().subscribe(this); if (screenState.containsKey(GameMenuScreen.SCREEN_STATE_PAGE_NUMBER)) { - vp.scrollToPage(Integer.valueOf(screenState.get(GameMenuScreen.SCREEN_STATE_PAGE_NUMBER)), false); + pagedScrollPane.scrollToPage(Integer.valueOf(screenState.get(GameMenuScreen.SCREEN_STATE_PAGE_NUMBER)), false); } // show intro and disable it afterwards if (getSelectedUser().isIntro()) { - vp.setTouchable(Touchable.disabled); - vp.scrollToPage(vp.getChildren().size - 1, false); - float initScroll = vp.getScrollX(); - vp.addAction(Actions.sequence(ScrollHomeAction.createInstace(), Actions.run(new Runnable() { + pagedScrollPane.setTouchable(Touchable.disabled); + pagedScrollPane.scrollToPage(pagedScrollPane.getChildren().size - 1, false); + + pagedScrollPane.addAction(Actions.sequence(ScrollHomeAction.createInstace(), Actions.run(new Runnable() { @Override public void run() { - vp.setTouchable(Touchable.enabled); + pagedScrollPane.setTouchable(Touchable.enabled); getSelectedUser().setIntro(false); User.updateUser(getSelectedUser()); } }))); } + screenResized(0, 0); + } + + public void prepareVignetteAndPagerSize() { + vignette.setBounds(getViewportLeftX(), getViewportBottomY(), getViewportWidth(), getViewportHeight()); + setActorToFullScene(pagedScrollPane); + } + + @Override + protected void screenResized(int width, int height) { + super.screenResized(width, height); + prepareVignetteAndPagerSize(); } @Handler public void handleShowGameMenuPageEvent(ShowGameMenuPageEvent showGameMenuPageEvent) { - vp.scrollToPage(showGameMenuPageEvent.getGameMenuPageDefinition().getPageNumber(), showGameMenuPageEvent.isSmoothScroll()); + pagedScrollPane.scrollToPage(showGameMenuPageEvent.getGameMenuPageDefinition().getPageNumber(), showGameMenuPageEvent.isSmoothScroll()); } @Override protected int[][] prepareScreenData(Map<String, String> screenState) { - TextureRegion clickmap = getScreenTextureRegion(GameMenuAssets.OFFICE_CLICKMAP); - if (!clickmap.getTexture().getTextureData().isPrepared()) { - clickmap.getTexture().getTextureData().prepare(); + TextureRegion clickMap = getScreenTextureRegion(GameMenuAssets.OFFICE_CLICKMAP); + if (!clickMap.getTexture().getTextureData().isPrepared()) { + clickMap.getTexture().getTextureData().prepare(); } - return Utility.createColorMap(clickmap); + return Utility.createColorMap(clickMap); } public static Map<String, String> createScreenState(GameMenuPageDefinition gameMenuPageDefinition) { @@ -137,4 +191,8 @@ public class GameMenuScreen extends AbstractTablexiaScreen<int[][]> { screenState.put(GameMenuScreen.SCREEN_STATE_PAGE_NUMBER, String.valueOf(gameMenuPageDefinition.getPageNumber())); return screenState; } -} + + public PagedScrollPane getPagedScrollPane() { + return pagedScrollPane; + } +} \ No newline at end of file diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/actions/ScrollHomeAction.java b/core/src/cz/nic/tablexia/screen/gamemenu/actions/ScrollHomeAction.java index ad514644bdc58359660eebad171b70170b6e122e..83f444b6d90da298feef6b900df5f85ddf6415a9 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/actions/ScrollHomeAction.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/actions/ScrollHomeAction.java @@ -3,7 +3,7 @@ package cz.nic.tablexia.screen.gamemenu.actions; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.actions.TemporalAction; -import cz.nic.tablexia.util.ui.ViewPager; +import cz.nic.tablexia.util.ui.PagedScrollPane; /** * Created by lhoracek on 11/4/15. @@ -12,8 +12,8 @@ public class ScrollHomeAction extends TemporalAction { private static final float DURATION = 3; private float startX; - private ViewPager getTargetPager(){ - return (ViewPager) target; + private PagedScrollPane getTargetPager(){ + return (PagedScrollPane) target; } protected void begin() { diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/pages/GameMenuPage.java b/core/src/cz/nic/tablexia/screen/gamemenu/pages/GameMenuPage.java index c2ab92d23e1f3bf064fbaf1f4583423d8d4c1b5b..4bcd8a47dc197f44290c070b1b39f8c3a9c5c531 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/pages/GameMenuPage.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/pages/GameMenuPage.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.actions.AlphaAction; @@ -11,6 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Stack; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.Align; import cz.nic.tablexia.Tablexia; import cz.nic.tablexia.TablexiaApplication; @@ -18,71 +20,182 @@ import cz.nic.tablexia.TablexiaSettings; import cz.nic.tablexia.bus.ApplicationBus; import cz.nic.tablexia.game.GameDefinition; import cz.nic.tablexia.game.difficulty.GameDifficulty; -import cz.nic.tablexia.screen.AbstractTablexiaScreen; +import cz.nic.tablexia.loader.application.ApplicationFontManager; import cz.nic.tablexia.screen.gamemenu.GameMenuAssets; import cz.nic.tablexia.screen.gamemenu.GameMenuScreen; +import cz.nic.tablexia.util.ui.ClickListenerWithSound; import cz.nic.tablexia.util.ui.Switch; -import cz.nic.tablexia.util.ui.ViewPager; /** - * Representing one page in ViewPager with specific game + * Represents a single page with game in Main Menu * Created by lhoracek on 3/4/15. + * Edited by Drahomir Karchnak on 2/12/15. */ -public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener { +public class GameMenuPage extends MenuPage { + /* + * SIZE OF ACTORS + * Size is represented as a percentage of the screens width + * For example 0.6 means that Actors width will be scaled to 60% of the screens width + */ + private static final float TITLE_WIDTH = 0.6f; + private static final float START_BUTTON_WIDTH = 0.15f; + private static final float DIFFICULTY_THUMB_WIDTH = 0.074f; + private static final float DIFFICULTY_BAR_WIDTH = 0.22f; + /* + * OFFSET OF ACTORS + * Offset is represented as a percentage of the screens height + * for example 0.05 means that actor will have offset of 5% of the screens height + */ + private static final float TITLE_TOP_OFFSET = 0.05f; + private static final float START_BUTTON_BOTTOM_OFFSET = 0.20f; + private static final float DIFFICULTY_BOTTOM_OFFSET = 0.045f; + private static final float DIFFICULTY_BAR_BOTTOM_OFFSET = 0.04f; + + private static final float START_BUTTON_MIN_HEIGHT = 0.30f; + private static final float START_BUTTON_MAX_HEIGHT = 0.38f; + + /* + * offset to the center of edge buttons on difficulty bar + * multiply this value with difficulty bars width to get offset for current screens coord system + * + * 14 is distance to center of the edge button + * 251 is width of difficulty bar texture + */ + private static final float DIFFICULTY_BAR_EDGE_OFFSET = 14/251f; + + //Font for difficulty labels + private static final ApplicationFontManager.FontType LABELS_FONT_STYLE = ApplicationFontManager.FontType.ROBOTO_BOLD_18; + private static BitmapFont labelsFont; + + private GameMenuScreen screen; private GameDefinition game; private float diffEasyX, diffMediumX, diffHardX; - private Actor diffEasy, diffMedium, diffHard; + private Actor buttonDifficultyEasy, buttonDifficultyMedium, buttonDifficultyHard; + private Stack diffStack; private GameDifficulty gameDifficulty = GameDifficulty.EASY; private Switch.DragSwitchListener dragSwitchListener; - private float scrollOffset = TablexiaSettings.getWorldSize(); // hack to keep paralax layers out of picture before scrolled for first time + //hack to keep paralax layers out of picture before scrolled for first time + private float scrollXOffset = TablexiaSettings.getWorldSize(); + + //PagedScrollPane, which is parent of this menu page has Y offset, which we have to counter + //to position all elements correctly + private float pagedScrollPaneOffsetY; - public GameMenuPage(AbstractTablexiaScreen screen, GameDefinition game) { + public GameMenuPage(GameMenuScreen screen, GameDefinition game) { super(screen); + this.screen = screen; this.game = game; - // Title - TextureRegion title = getScreen().getScreenTextureRegion(GameMenuAssets.getResourcePath(game, GameMenuAssets.GameMenuLayers.TITLE)); - Image titleImage = new Image(title); - int titleX = (int) (screen.getStage().getWidth() * 0.2); - int titleWidth = (int) (screen.getStage().getWidth() * 0.6); + labelsFont = ApplicationFontManager.getInstance().getFont(LABELS_FONT_STYLE); + + //offset is needed to properly calculate position of elements + pagedScrollPaneOffsetY = screen.getPagedScrollPane().getY(); + + prepareTitle(); + prepareStartButton(); + prepareDifficulty(); + } + + /** + * Creates and repares Title + */ + public void prepareTitle() { + //Resources + TextureRegion title = getScreen().getScreenTextureRegion(GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuScreen.GameMenuLayers.TITLE)); + final Image titleImage = new Image(title); + + //Size + int titleWidth = (int) (getScreen().getSceneWidth() * TITLE_WIDTH); int titleHeight = (int) (titleWidth * ((float) title.getRegionHeight() / (float) title.getRegionWidth())); - int titleY = (int) (screen.getStage().getHeight() - (screen.getStage().getHeight() * 0.05) - titleHeight); + + //Position + int titleX = (int) (getScreen().getSceneWidth()/2 - titleWidth/2); + int titleY = (int) (getScreen().getSceneInnerTopY() - titleHeight - (getScreen().getSceneInnerHeight() * TITLE_TOP_OFFSET) - pagedScrollPaneOffsetY); + titleImage.setPosition(titleX, titleY); titleImage.setSize(titleWidth, titleHeight); + addActor(titleImage); + } + + /** + * Initializes StartButton Pressed and Released + */ + public void prepareStartButton() { + // Prepare Start Button UP/Released + // Resources + TextureRegion start = getScreen().getScreenTextureRegion(GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuScreen.GameMenuLayers.STARTBUTTON)); + final Image startButton = new Image(start); + + // Size + int startWidth = (int) (getScreen().getSceneWidth() * START_BUTTON_WIDTH); + int startHeight = (int) (startWidth * (start.getRegionHeight() / (float) start.getRegionWidth())); + + float tempHeight = MathUtils.clamp(startHeight, START_BUTTON_MIN_HEIGHT * getScreen().getSceneInnerHeight(), START_BUTTON_MAX_HEIGHT* getScreen().getSceneInnerHeight()); + if(tempHeight != startHeight) { + startHeight = (int) tempHeight; + startWidth = (int) (startHeight * (start.getRegionWidth() / (float) start.getRegionHeight())); + } - // Start button - TextureRegion start = getScreen().getScreenTextureRegion(GameMenuAssets.getResourcePath(game, GameMenuAssets.GameMenuLayers.STARTBUTTON)); - final Image startButton = new Image(start); - int startY = (int) (screen.getStage().getWidth() * 0.1); - int startHeight = (int) (screen.getStage().getHeight() * 0.25); - int startWidth = (int) (startHeight * ((float) start.getRegionWidth() / (float) start.getRegionHeight())); - int startX = (int) screen.getStage().getWidth() / 2 - startWidth / 2; - startButton.setSize(startWidth, startHeight); - startButton.setPosition(startX, startY); - - // Start button down - TextureRegion startDown = getScreen().getScreenTextureRegion(GameMenuAssets.getResourcePath(game, GameMenuAssets.GameMenuLayers.STARTBUTTON_PRESSED)); - final Image startDownButton = new Image(startDown); - int startDownY = (int) (screen.getStage().getWidth() * 0.1); - int startDownHeight = (int) (screen.getStage().getHeight() * 0.25); - int startDownWidth = (int) (startDownHeight * ((float) startDown.getRegionWidth() / (float) startDown.getRegionHeight())); - int startDownX = (int) screen.getStage().getWidth() / 2 - startDownWidth / 2; - startDownButton.setSize(startDownWidth, startDownHeight); - startDownButton.setPosition(startDownX, startDownY); - startDownButton.setVisible(false); + // Position + int startX = (int) getScreen().getStage().getWidth() / 2 - startWidth / 2; + int startY = (int) ( (getScreen().getStage().getHeight() * START_BUTTON_BOTTOM_OFFSET) - pagedScrollPaneOffsetY); + + startButton.setSize(startWidth, startHeight); + startButton.setPosition(startX, startY); + + //Prepare Strat Button Down/Pressed + // Resources + TextureRegion startDown = getScreen().getScreenTextureRegion(GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuScreen.GameMenuLayers.STARTBUTTON_PRESSED)); + final Image startDownButton = new Image(startDown); + + //Size + int startDownWidth = (int) (getScreen().getSceneWidth() * START_BUTTON_WIDTH); + int startDownHeight = (int) (startWidth * (start.getRegionHeight() / (float) start.getRegionWidth())); + + tempHeight = MathUtils.clamp(startDownHeight, START_BUTTON_MIN_HEIGHT * getScreen().getSceneInnerHeight(), START_BUTTON_MAX_HEIGHT* getScreen().getSceneInnerHeight()); + if(tempHeight != startDownHeight) { + startDownHeight = (int) tempHeight; + startDownWidth = (int) (startHeight * (start.getRegionWidth() / (float) start.getRegionHeight())); + } + + //Position + int startDownX = (int) getScreen().getStage().getWidth() / 2 - startDownWidth / 2; + int startDownY = (int) ( (getScreen().getStage().getHeight() * START_BUTTON_BOTTOM_OFFSET) - pagedScrollPaneOffsetY); + + startDownButton.setSize(startDownWidth, startDownHeight); + startDownButton.setPosition(startDownX, startDownY); + startDownButton.setVisible(false); addActor(startDownButton); addActor(startButton); - startButton.addListener(new ClickListener() { + + //Listeners and Input handling + startButton.addListener(new ClickListenerWithSound() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { + super.touchDown(event, x + scrollXOffset, y, pointer, button); + startButton.addAction(new AlphaAction()); startDownButton.setVisible(true); - return super.touchDown(event, x, y, pointer, button); + + setLastTouch(x, y); + + return true; + } + + @Override + public void clicked(InputEvent event, float x, float y) { + if(inTapSquare(x, y)) + super.clicked(event, x, y); + } + + @Override + public void touchUp(InputEvent event, float x, float y, int pointer, int button) { + super.touchUp(event, x + scrollXOffset, y, pointer, button); } @Override @@ -95,48 +208,64 @@ public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener { } @Override - public void clicked(InputEvent event, float x, float y) { - super.clicked(event, x, y); + public void onClick(InputEvent event, float x, float y) { + super.onClick(event, x, y); + ApplicationBus.getInstance().publishAsync(new Tablexia.ChangeScreenEvent(GameMenuPage.this.game.getScreenClass(), - TablexiaApplication.ScreenTransaction.FADE)); + TablexiaApplication.ScreenTransaction.FADE)); } }); + } - final TextureRegion diff = getScreen().getScreenTextureRegion(GameMenuAssets.DIFF_THUMB_EASY); - float diffY = screen.getStage().getHeight() * 0.06f; - float diffHeight = screen.getStage().getHeight() * 0.12f; - float diffWidth = diffHeight * ((float) diff.getRegionWidth() / (float) diff.getRegionHeight()); - + /** + * Creates and prepares Difficulty slider, Difficulty labels and Buttons + */ + public void prepareDifficulty() { + final float difficultyY = getScreen().getStage().getHeight() * DIFFICULTY_BOTTOM_OFFSET - pagedScrollPaneOffsetY; // Difficulty bar TextureRegion diffBar = getScreen().getScreenTextureRegion(GameMenuAssets.DIFF_BAR); Image diffBarImage = new Image(diffBar); - int diffBarHeight = (int) (screen.getStage().getHeight() * 0.04f); - int diffBarWidth = (int) (diffBarHeight * ((float) diffBar.getRegionWidth() / (float) diffBar.getRegionHeight())); - int diffBarX = (int) screen.getStage().getWidth() / 2 - diffBarWidth / 2; - int diffBarY = (int) (screen.getStage().getHeight() * 0.1); + int diffBarWidth = (int) (getScreen().getSceneWidth() * DIFFICULTY_BAR_WIDTH); + int diffBarHeight = (int) (diffBarWidth * (diffBar.getRegionHeight() / (float) diffBar.getRegionWidth())); + + int diffBarX = (int) getScreen().getStage().getWidth() / 2 - diffBarWidth / 2; + int diffBarY = (int) ( difficultyY + (getScreen().getSceneWidth() * DIFFICULTY_BAR_BOTTOM_OFFSET) ); + diffBarImage.setPosition(diffBarX, diffBarY); diffBarImage.setSize(diffBarWidth, diffBarHeight); addActor(diffBarImage); - diffMediumX = (screen.getStage().getWidth() / 2) - (diffWidth / 2); - diffEasyX = diffMediumX - (diffBarWidth / 2) + (diffWidth * 0.1f); - diffHardX = diffMediumX + (diffBarWidth / 2) - (diffWidth * 0.1f); + + //Difficulty Thumb + final TextureRegion diff = getScreen().getScreenTextureRegion(GameMenuAssets.DIFF_THUMB_EASY); + + float diffWidth = getScreen().getSceneWidth() * DIFFICULTY_THUMB_WIDTH; + float diffHeight = (int) (diffWidth * (diff.getRegionHeight() / (float) diff.getRegionWidth())); + + //Centers thumb difficulty button to difficulty bar + float diffY = diffBarY + (diffBarHeight/2) - (diffHeight/2); + + float centerDiffX = diffBarX + (diffBarWidth / 2); + diffMediumX = centerDiffX - (diffWidth / 2); + diffEasyX = centerDiffX - (diffBarWidth / 2) - (diffWidth / 2) + (diffBarWidth * DIFFICULTY_BAR_EDGE_OFFSET); // + (diffWidth * 0.1f); + diffHardX = centerDiffX + (diffBarWidth / 2) - (diffWidth / 2) - (diffBarWidth * DIFFICULTY_BAR_EDGE_OFFSET);// - (diffWidth * 0.1f); // Labels for diffuculty slider - BitmapFont font = screen.getDefaultBoldFont(); - Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.BLACK); + Label.LabelStyle labelStyle = new Label.LabelStyle(labelsFont, Color.BLACK); Label easy = new Label(GameDifficulty.EASY.getTextDescription(), labelStyle); Label medium = new Label(GameDifficulty.MEDIUM.getTextDescription(), labelStyle); Label hard = new Label(GameDifficulty.HARD.getTextDescription(), labelStyle); - easy.setFontScale(0.7f); - medium.setFontScale(0.7f); - hard.setFontScale(0.7f); - float labelY = screen.getStage().getHeight() * 0.06f; + easy.setAlignment(Align.center); + medium.setAlignment(Align.center); + hard.setAlignment(Align.center); + + float labelY = difficultyY; float labelAddX = diffWidth / 2; + easy.setPosition(diffEasyX + labelAddX - easy.getWidth() / 2, labelY); medium.setPosition(diffMediumX + labelAddX - medium.getWidth() / 2, labelY); hard.setPosition(diffHardX + labelAddX - hard.getWidth() / 2, labelY); @@ -145,16 +274,65 @@ public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener { addActor(medium); addActor(hard); + float buttonAddX = diffWidth/2.0f; + + //Invisible buttons for easier difficulty choosing + buttonDifficultyEasy = new Actor(); + buttonDifficultyEasy.setSize(diffWidth, diffWidth); + buttonDifficultyEasy.setPosition( diffEasyX + buttonAddX - buttonDifficultyEasy.getWidth() / 2, diffY); + + buttonDifficultyMedium = new Actor(); + buttonDifficultyMedium.setSize(diffWidth, diffWidth); + buttonDifficultyMedium.setPosition( diffMediumX + buttonAddX - buttonDifficultyMedium.getWidth() / 2, diffY); + + buttonDifficultyHard = new Actor(); + buttonDifficultyHard.setSize(diffWidth, diffWidth); + buttonDifficultyHard.setPosition(diffHardX + buttonAddX - buttonDifficultyHard.getWidth() / 2, diffY); + + buttonDifficultyEasy.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + super.clicked(event, x, y); + difficultyChanged(GameDifficulty.EASY); + dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); + } + }); + + buttonDifficultyMedium.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + super.clicked(event, x, y); + difficultyChanged(GameDifficulty.MEDIUM); + dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); + } + }); + + buttonDifficultyHard.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + super.clicked(event, x, y); + difficultyChanged(GameDifficulty.HARD); + dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); + } + }); + + addActor(buttonDifficultyEasy); + addActor(buttonDifficultyMedium); + addActor(buttonDifficultyHard); + // Difficulty button diffStack = new Stack(); - diffStack.addActor(diffEasy = new Image(diff)); - diffStack.addActor(diffMedium = new Image(getScreen().getScreenTextureRegion(GameMenuAssets.DIFF_THUMB_MEDIUM))); - diffStack.addActor(diffHard = new Image(getScreen().getScreenTextureRegion(GameMenuAssets.DIFF_THUMB_HARD))); + + // Creates and adds Difficulty thumbs + diffStack.addActor(new Image(diff)); + diffStack.addActor(new Image(getScreen().getScreenTextureRegion(GameMenuAssets.DIFF_THUMB_MEDIUM))); + diffStack.addActor(new Image(getScreen().getScreenTextureRegion(GameMenuAssets.DIFF_THUMB_HARD))); float diffX = diffEasyX; diffStack.setSize(diffWidth, diffHeight); diffStack.setPosition(diffX, diffY); addActor(diffStack); + diffStack.addListener(dragSwitchListener = new Switch.DragSwitchListener(diffStack, diffEasyX, diffHardX, diffMediumX)); dragSwitchListener.setSwitchMovedListener(new Switch.DragSwitchListener.SwitchMovedListener() { @Override @@ -172,7 +350,6 @@ public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener { }); gameDifficulty = TablexiaSettings.getInstance().getGameDifficulty(game); dragSwitchListener.switchToStep(gameDifficulty.getDifficultyNumber() - 1); - } /** @@ -185,6 +362,11 @@ public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener { TablexiaSettings.getInstance().setGameDifficulty(game, difficulty); } + /** + * Custom draw method + * @param batch + * @param parentAlpha + */ @Override public void draw(Batch batch, float parentAlpha) { // Paralax layers @@ -193,40 +375,61 @@ public class GameMenuPage extends MenuPage implements ViewPager.ScrollListener { Color color = new Color(this.getColor().r, this.getColor().g, this.getColor().b, this.getColor().a * parentAlpha); batch.setColor(color); - TextureRegion back = getScreen().getScreenTextureRegion(GameMenuAssets.getResourcePath(game, GameMenuAssets.GameMenuLayers.BACK)); - float scrollHalf = (Math.abs(scrollOffset / 2) / getWidth()) * back.getRegionWidth(); - int srcX = (int) scrollHalf; - int srcWidth = (int) (back.getRegionWidth() - (scrollHalf * 2)); - float x = getX() + Math.abs(Math.min(scrollOffset, 0)); - float width = getWidth() - Math.abs(scrollOffset); + TextureRegion back = getScreen().getScreenTextureRegion(GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuScreen.GameMenuLayers.BACK)); batch.disableBlending(); - batch.draw(back.getTexture(), x, getY(), width, getHeight(), back.getRegionX() + srcX, back.getRegionY(), srcWidth, back.getRegionHeight(), false, false); + + //Just adjusting sourceX coordinate to get animated background/sky + float xShift = scrollXOffset / 3.0f; + batch.draw( back.getTexture(), + getScreen().getSceneLeftX() + getX(), + getScreen().getSceneOuterBottomY() - pagedScrollPaneOffsetY, + getScreen().getSceneWidth(), + getScreen().getSceneOuterHeight(), + back.getRegionX() + (int)(xShift), + back.getRegionY(), + back.getRegionWidth(), + back.getRegionHeight(), + false, + false ); + batch.enableBlending(); + // Mid layer travels the same speed - batch.draw(getScreen().getScreenTextureRegion(GameMenuAssets.getResourcePath(game, GameMenuAssets.GameMenuLayers.MID)), getX(), getY(), getWidth(), getHeight()); + batch.draw( getScreen().getScreenTextureRegion(GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuScreen.GameMenuLayers.MID)), + getScreen().getSceneLeftX() + getX(), + getScreen().getSceneOuterBottomY() - pagedScrollPaneOffsetY, + getScreen().getSceneWidth(), + getScreen().getSceneOuterHeight() ); + + batch.enableBlending(); // Foreground layer travels faster and could be wider than screen. Needs to be clipped - TextureRegion fore = getScreen().getScreenTextureRegion(GameMenuAssets.getResourcePath(game, GameMenuAssets.GameMenuLayers.FORE)); - float foreWidth = (getHeight() / fore.getRegionHeight()) * fore.getRegionWidth(); - batch.draw(fore, getX() - ((foreWidth - getWidth()) / 2) + (scrollOffset / 2), getY(), foreWidth, getHeight()); + batch.draw( getScreen().getScreenTextureRegion(GameMenuScreen.GameMenuPageDefinition.getResourcePath(game, GameMenuScreen.GameMenuLayers.FORE)), + getScreen().getSceneLeftX() + getX() + (scrollXOffset / 2), + getScreen().getSceneOuterBottomY() - pagedScrollPaneOffsetY, + getScreen().getSceneWidth(), + getScreen().getSceneOuterHeight() ); + super.draw(batch, parentAlpha); } @Override public void onScroll(float offset) { - scrollOffset = offset; - //Log.info(((Object) this).getClass().getName(), "Scroll " + game.name() + ": " + offset); + scrollXOffset = offset; } @Override public void onScrolledToPage() { ApplicationBus.getInstance().post(new GameMenuPageScrolledEvent(GameMenuScreen.GameMenuPageDefinition.getGameMenuPageForGameDefinition(game))).asynchronously(); - //Log.info(((Object) this).getClass().getName(), "Scrolled to page: " + game.name()); } - public static class GameMenuPageScrolledEvent implements ApplicationBus.ApplicationEvent { + @Override + public boolean isSnapToAllowed() { + return true; + } + public static class GameMenuPageScrolledEvent implements ApplicationBus.ApplicationEvent { private GameMenuScreen.GameMenuPageDefinition gameMenuPageDefinition; GameMenuPageScrolledEvent(GameMenuScreen.GameMenuPageDefinition gameMenuPageDefinition) { diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/pages/MenuPage.java b/core/src/cz/nic/tablexia/screen/gamemenu/pages/MenuPage.java index 8f782e7e45719cb11171755201b49f218b70ec54..8d3473d84d3967aa93228f7f44d17c1d1afb3514 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/pages/MenuPage.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/pages/MenuPage.java @@ -7,10 +7,17 @@ import cz.nic.tablexia.screen.AbstractTablexiaScreen; /** * Created by lhoracek on 3/4/15. + * Edited by Drahomir Karchnak on 2/12/15 */ public abstract class MenuPage extends Group { + //see isClick method + private static final float MAX_CLICK_RADIUS = 20.0f; + private AbstractTablexiaScreen<int[][]> screen; + private float lastTouchX = -1; + private float lastTouchY = -1; + public MenuPage(AbstractTablexiaScreen<int[][]> screen) { this.screen = screen; } @@ -19,6 +26,21 @@ public abstract class MenuPage extends Group { return screen; } + //Tells if Paged Scroll Pane can snap to this page + public abstract boolean isSnapToAllowed(); + + public abstract void onScroll(float scroll); + public abstract void onScrolledToPage(); + + public void setLastTouch(float x, float y) { + lastTouchX = x; + lastTouchY = y; + } + + public float getLastTouchX() { return lastTouchX; } + + public float getLastTouchY() { return lastTouchY; } + @Override public void setDebug(boolean enabled) { super.setDebug(enabled); diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/pages/OfficeMenuPage.java b/core/src/cz/nic/tablexia/screen/gamemenu/pages/OfficeMenuPage.java index 92973662d97006fc79feabd1511cd0bbad51ea4e..a26e90f355bc5e4a9e876cfbbcc46a175b144e7f 100644 --- a/core/src/cz/nic/tablexia/screen/gamemenu/pages/OfficeMenuPage.java +++ b/core/src/cz/nic/tablexia/screen/gamemenu/pages/OfficeMenuPage.java @@ -5,11 +5,12 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.InputEvent; -import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction; +import com.badlogic.gdx.scenes.scene2d.ui.Button; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Stack; -import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import cz.nic.tablexia.Tablexia; import cz.nic.tablexia.TablexiaApplication; @@ -25,79 +26,149 @@ import cz.nic.tablexia.screen.gamemenu.event.ShowGameMenuPageEvent; import cz.nic.tablexia.screen.halloffame.HallOfFameScreen; import cz.nic.tablexia.screen.profile.ProfileScreen; import cz.nic.tablexia.screen.statistics.StatisticsScreen; -import cz.nic.tablexia.util.Log; +import cz.nic.tablexia.util.ui.ClickListenerWithSound; import cz.nic.tablexia.util.ui.TablexiaNoBlendingImage; -import cz.nic.tablexia.util.ui.ViewPager; /** * Created by lhoracek on 3/4/15. + * Edited by Drahomir Karchnak */ -public class OfficeMenuPage extends MenuPage implements ViewPager.ScrollListener { - +public class OfficeMenuPage extends MenuPage { + /* + Colors for ClickMap + check clickablemap.png in screen gamemenu assets folder, you'll get the idea. + */ public static final Color STREET_COLOR = Color.YELLOW; public static final Color HALLOFFAME_COLOR = Color.GREEN; public static final Color STATISTICS_COLOR = Color.RED; public static final Color ENCYCLOPEDIA_COLOR = Color.BLACK; public static final Color PROFILE_COLOR = Color.BLUE; - private Group help; + //Time for help overlay to fadein and fadeout + private static final float HELP_FADE_TIME = 0.25f; + + //Help Button + private static final float HELP_BUTTON_SCALE = 0.85f; + private static final float HELP_BUTTON_OFFSET_RIGHT = 0.07f; + private static final float HELP_BUTTON_OFFSET_BOTTOM = 0.05f; + + //Group for all helping elements, so we can hide/show 'em all at once + private Group helpGroup; + private Stack helpOverlayStack; //For all fullscreen toggle hide/show elements of help + + //Stack of all office related actors + private Stack officeStack; - private Image hallOfFame; - private Image statistics; - private Image encyclopedia; - private Image street; - private Image profile; + //Images for office related actors + private Image hallOfFame; + private Image statistics; + private Image encyclopedia; + private Image street; + private Image profilePressed; + + private Image profileUnpressed; + + private Button toggleHelpButton; + + //Texture region of clickable map private final TextureRegion clickmap; + //PagedScrollPane, which is parent of this menu page has Y offset, which we have to counter + //to position all elements correctly + private float pagedScrollPaneOffsetY; + + private float scrollXOffset = 0; public OfficeMenuPage(AbstractTablexiaScreen screen) { super(screen); + + pagedScrollPaneOffsetY = ((GameMenuScreen) screen).getPagedScrollPane().getY(); + createImageStack(); - // TODO show help layer button + //Prepares helpGroup, which is used to store helpOverlayStack and toggleHelpButton + helpGroup = new Group(); + helpGroup.setPosition(getScreen().getSceneLeftX(), getScreen().getSceneOuterBottomY() - pagedScrollPaneOffsetY); + helpGroup.setSize(getScreen().getSceneWidth(), getScreen().getSceneOuterHeight()); + + //Prepares helpOverlayStack, which is a parent of HelpOverlay and HelpColorOverlay + helpOverlayStack = new Stack(); + helpOverlayStack.setPosition(getScreen().getSceneLeftX(), getScreen().getSceneOuterBottomY() - pagedScrollPaneOffsetY); + helpOverlayStack.setSize(getScreen().getSceneWidth(), getScreen().getSceneOuterHeight()); + + helpGroup.addActor(helpOverlayStack); + addActor(helpGroup); + + //Init + prepareHelpOverlay(); + prepareToggleHelpButton(); + prepareInputListener(); + + //Have user seen the help overlay ? + if(TablexiaSettings.getInstance().getSelectedUser().isHelp()) { + TablexiaSettings.getInstance().getSelectedUser().setHelp(false); + User.updateUser(TablexiaSettings.getInstance().getSelectedUser()); + toggleHelpOverlay(); + } - addListener(new InputListener() { - private Color downColor; + clickmap = getScreen().getScreenTextureRegion(GameMenuAssets.OFFICE_CLICKMAP); + sizeChanged(); + } + + @Override + protected void sizeChanged() { + super.sizeChanged(); + } + /** + * Creates, prepares and adds InputListener to OfficeMenuPage + */ + public void prepareInputListener() { + addListener(new ClickListenerWithSound() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { - super.touchDown(event, x, y, pointer, button); - Color color = getTouchedColor(x, y); - downColor = color; - if (help.isVisible()) { - help.addAction(Actions.fadeOut(0.5f)); - TablexiaSettings.getInstance().getSelectedUser().setHelp(false); - User.updateUser(TablexiaSettings.getInstance().getSelectedUser()); - } - if (color.equals(ENCYCLOPEDIA_COLOR)) { - encyclopedia.setVisible(true); - } else if (color.equals(STATISTICS_COLOR)) { - statistics.setVisible(true); - } else if (color.equals(HALLOFFAME_COLOR)) { - hallOfFame.setVisible(true); - } else if (color.equals(STREET_COLOR)) { - street.setVisible(true); - } else if (color.equals(PROFILE_COLOR)) { - profile.setVisible(true); - } else { + super.touchDown(event, x + scrollXOffset, y, pointer, button); + + setLastTouch(x, y); + + //Don't do anything if help overlay is still visible + if (helpOverlayStack.isVisible()) { + toggleHelpOverlay(); return false; } + + Color color = getTouchedColor(x, y); + + if (!helpOverlayStack.isVisible()) { //If Help is visible, ignore the click + if (color.equals(ENCYCLOPEDIA_COLOR)) { + encyclopedia.setVisible(true); + } else if (color.equals(STATISTICS_COLOR)) { + statistics.setVisible(true); + } else if (color.equals(HALLOFFAME_COLOR)) { + hallOfFame.setVisible(true); + } else if (color.equals(STREET_COLOR)) { + street.setVisible(true); + } else if (color.equals(PROFILE_COLOR)) { + profilePressed.setVisible(true); + profileUnpressed.setVisible(false); + } + } return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { - super.touchUp(event, x, y, pointer, button); - Log.info(((Object) this).getClass().getName(), "Touch up "); + super.touchUp(event, x + scrollXOffset, y, pointer, button); hideAllActions(); } - }); - addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { - super.clicked(event, x, y); + if(!inTapSquare(x, y)) + return; + Color color = getTouchedColor(x, y); + if (color.equals(ENCYCLOPEDIA_COLOR)) { ApplicationBus.getInstance().publishAsync(new Tablexia.ChangeScreenEvent(EncyclopediaScreen.class, TablexiaApplication.ScreenTransaction.FADE)); } else if (color.equals(STATISTICS_COLOR)) { @@ -109,43 +180,85 @@ public class OfficeMenuPage extends MenuPage implements ViewPager.ScrollListener } else if (color.equals(PROFILE_COLOR)) { ApplicationBus.getInstance().publishAsync(new Tablexia.ChangeScreenEvent(ProfileScreen.class, TablexiaApplication.ScreenTransaction.FADE)); } + else { + //Wont let super.clicked to run + //and play the click sound + return; + } + + super.clicked(event, x, y); + } + }); + } + + /** + * Initializes Toggle Help Button + */ + private void prepareToggleHelpButton() { + toggleHelpButton = new Button( + new TextureRegionDrawable(getScreen().getScreenTextureRegion(GameMenuAssets.HELP_BUTTON_RELEASE)), + new TextureRegionDrawable(getScreen().getScreenTextureRegion(GameMenuAssets.HELP_BUTTON_PRESSED)) + ); + + toggleHelpButton.addListener( new ClickListenerWithSound() { + @Override + public void onClick(InputEvent event, float x, float y) { + super.onClick(event, x, y); + hideAllActions(); + toggleHelpOverlay(); } }); - clickmap = getScreen().getScreenTextureRegion(GameMenuAssets.OFFICE_CLICKMAP); + toggleHelpButton.setSize(toggleHelpButton.getPrefWidth() * HELP_BUTTON_SCALE, + toggleHelpButton.getPrefHeight() * HELP_BUTTON_SCALE); + + toggleHelpButton.setPosition(getScreen().getSceneRightX() - toggleHelpButton.getPrefWidth() - getScreen().getSceneWidth() * HELP_BUTTON_OFFSET_RIGHT, + getScreen().getSceneInnerBottomY() - pagedScrollPaneOffsetY + getScreen().getSceneInnerHeight() * HELP_BUTTON_OFFSET_BOTTOM); + + helpGroup.addActor(toggleHelpButton); + } + + /** + * Initializes Help Overlay + */ + private void prepareHelpOverlay() { + Actor helpColorOverlay = new Image(ApplicationAtlasManager.getInstance().getColorTexture(ApplicationAtlasManager.COLOR_OVERLAY)); + Actor helpOverlay = createImage(GameMenuAssets.OFFICE_HELP); + + helpOverlayStack.addActor(helpColorOverlay); + helpOverlayStack.addActor(helpOverlay); + + helpOverlayStack.setVisible(false); + helpOverlayStack.addAction(Actions.alpha(0)); } private void createImageStack() { - Stack stack = new Stack(); - stack.setSize(getScreen().getStage().getWidth(), getScreen().getStage().getHeight()); - stack.setPosition(0, 0); - addActor(stack); - - stack.addActor(new TablexiaNoBlendingImage(getScreen().getScreenTextureRegion(GameMenuAssets.OFFICE))); - stack.addActor(createImage(GameMenuAssets.OFFICE_HALLOFFAME)); - stack.addActor(street = createImage(GameMenuAssets.DOOR_PRESSED)); - stack.addActor(encyclopedia = createImage(GameMenuAssets.ENCYCLOPEDIA_PRESSED)); - stack.addActor(statistics = createImage(GameMenuAssets.STATISTICS_PRESSED)); - stack.addActor(hallOfFame = createImage(GameMenuAssets.HALLOFFAME_PRESSED)); - stack.addActor(createImage(GameMenuAssets.DESK)); - stack.addActor(profile = createImage(GameMenuAssets.PROFILE_PRESSED)); + officeStack = new Stack(); - hideAllActions(); + officeStack.setSize(getScreen().getSceneWidth(), getScreen().getSceneOuterHeight()); + officeStack.setPosition(0, getScreen().getSceneOuterBottomY() - pagedScrollPaneOffsetY); - help = new Stack(); - help.setSize(getScreen().getStage().getWidth(), getScreen().getStage().getHeight()); - help.setPosition(0, 0); - stack.addActor(help); - Actor overlay = new Image(ApplicationAtlasManager.getInstance().getColorTexture(ApplicationAtlasManager.COLOR_OVERLAY)); - help.addActor(overlay); - help.addActor(createImage(GameMenuAssets.OFFICE_HELP)); + officeStack.add(new TablexiaNoBlendingImage(getScreen().getScreenTextureRegion(GameMenuAssets.OFFICE))); + officeStack.addActor(createImage(GameMenuAssets.OFFICE_HALLOFFAME)); + officeStack.addActor(street = createImage(GameMenuAssets.DOOR_PRESSED)); + officeStack.addActor(encyclopedia = createImage(GameMenuAssets.ENCYCLOPEDIA_PRESSED)); + officeStack.addActor(statistics = createImage(GameMenuAssets.STATISTICS_PRESSED)); + officeStack.addActor(hallOfFame = createImage(GameMenuAssets.HALLOFFAME_PRESSED)); + officeStack.addActor(profileUnpressed = createImage(GameMenuAssets.DESK)); + officeStack.addActor(profilePressed = createImage(GameMenuAssets.PROFILE_PRESSED)); - help.setVisible(TablexiaSettings.getInstance().getSelectedUser().isHelp()); + addActor(officeStack); + hideAllActions(); } + /** + * Hides all possibly visible actions + */ private void hideAllActions() { - profile.setVisible(false); + profileUnpressed.setVisible(true); + + profilePressed.setVisible(false); street.setVisible(false); encyclopedia.setVisible(false); statistics.setVisible(false); @@ -155,27 +268,73 @@ public class OfficeMenuPage extends MenuPage implements ViewPager.ScrollListener /** * Helper method for creating image instances * - * @param texture - * @return + * @param texture texture name + * @return return image */ private Image createImage(String texture) { return new Image(getScreen().getScreenTextureRegion(texture)); } + /** + * Gets color from clickmap according to coords x and y + * @param x X coord + * @param y Y coord + * @return color clicked, Color.BLACK if anything went wrong + */ private Color getTouchedColor(float x, float y) { int clickX = (int) (x / getWidth() * clickmap.getRegionWidth()); int clickY = clickmap.getRegionHeight() - (int) (y / getHeight() * clickmap.getRegionHeight()); + if (clickX >= getScreen().getData().length || + clickY >= getScreen().getData()[0].length || + clickX < 0 || clickY < 0) + { + return Color.BLACK; + } + return new Color(getScreen().getData()[clickX][clickY]); } + @Override + public void onScrolledToPage() { + ApplicationBus.getInstance().post(new GameMenuPage.GameMenuPageScrolledEvent(GameMenuScreen.GameMenuPageDefinition.OFFICE_PAGE)).asynchronously(); + } + @Override public void onScroll(float offset) { - // nothing needed + scrollXOffset = offset; + } + + /** + * Toggles (FadeIn/FadeOut) help overlay + */ + private void toggleHelpOverlay() { + if(helpOverlayStack.isVisible()) { + helpOverlayStack.addAction( new SequenceAction( + Actions.fadeOut(HELP_FADE_TIME), + Actions.run( new Runnable() { + @Override + public void run() { + helpOverlayStack.setVisible(false); + } + }) + )); + } + else { + helpOverlayStack.addAction( new SequenceAction( + Actions.run( new Runnable() { + @Override + public void run() { + helpOverlayStack.setVisible(true); + } + }), + Actions.fadeIn(HELP_FADE_TIME) + )); + } } @Override - public void onScrolledToPage() { - ApplicationBus.getInstance().post(new GameMenuPage.GameMenuPageScrolledEvent(GameMenuScreen.GameMenuPageDefinition.OFFICE_PAGE)).asynchronously(); + public boolean isSnapToAllowed() { + return true; } -} +} \ No newline at end of file diff --git a/core/src/cz/nic/tablexia/screen/gamemenu/pages/WallPage.java b/core/src/cz/nic/tablexia/screen/gamemenu/pages/WallPage.java new file mode 100644 index 0000000000000000000000000000000000000000..edb1c92bd946de4cff174970fc207fec22a32e3d --- /dev/null +++ b/core/src/cz/nic/tablexia/screen/gamemenu/pages/WallPage.java @@ -0,0 +1,73 @@ +package cz.nic.tablexia.screen.gamemenu.pages; + +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +import cz.nic.tablexia.TablexiaSettings; +import cz.nic.tablexia.screen.AbstractTablexiaScreen; +import cz.nic.tablexia.screen.gamemenu.GameMenuAssets; +import cz.nic.tablexia.screen.gamemenu.GameMenuScreen; + +/** + * Created by Drahomir Karchnak on 02/12/15. + */ +public class WallPage extends MenuPage{ + private TextureRegion back = getScreen().getScreenTextureRegion(GameMenuAssets.WALL_BACK); + private TextureRegion mid = getScreen().getScreenTextureRegion(GameMenuAssets.WALL_MID); + + private float scrollOffset = TablexiaSettings.getWorldSize(); + private float pagedScrollPaneOffsetY; + + public WallPage(AbstractTablexiaScreen<int[][]> screen) { + super(screen); + + pagedScrollPaneOffsetY = ((GameMenuScreen) screen).getPagedScrollPane().getY(); + + setSize(mid.getRegionWidth(), getScreen().getSceneOuterHeight()); + setPosition(getScreen().getSceneWidth(), getScreen().getSceneOuterBottomY() - getScreen().getSceneOuterBottomY()); + } + + @Override + public void draw(Batch batch, float parentAlpha) { + batch.setColor(batch.getColor().r, batch.getColor().g, batch.getColor().b, parentAlpha); + + batch.disableBlending(); + + //Just adjusting sourceX coordinate to get animated background/sky + float xShift = scrollOffset / 3.0f; + batch.draw(back.getTexture(), + getScreen().getSceneLeftX() + getX(), + getScreen().getSceneOuterBottomY() - pagedScrollPaneOffsetY, + getWidth(), + getScreen().getSceneOuterHeight(), + back.getRegionX() + (int) (xShift), + back.getRegionY(), + (int)(back.getRegionHeight() * (getWidth()/getHeight())), + back.getRegionHeight(), + false, + false); + + + batch.enableBlending(); + + batch.draw( mid, + getScreen().getSceneLeftX() + getX(), + getScreen().getSceneOuterBottomY() - pagedScrollPaneOffsetY, + getWidth(), + getHeight()); + + + super.draw(batch, parentAlpha); + } + + @Override + public boolean isSnapToAllowed() { + return false; + } + + @Override + public void onScroll(float scroll) { scrollOffset = scroll; } + + @Override + public void onScrolledToPage() { } +} diff --git a/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java b/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java index ab5c2c3d6df57323736f780838b033c577fedc50..c863ce1c5e031cf59e8cc39c6538a4877bc7387c 100644 --- a/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java +++ b/core/src/cz/nic/tablexia/screen/halloffame/HallOfFameScreen.java @@ -53,11 +53,9 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti private static final int TROPHY_DIALOG_HEIGHT = 300; private static final int BACKGROUND_TILE_REPEAT_COUNT = 22; private static final float TILE_SCREE_WIDTH_RATIO = 0.25f; - private static final int MOUSE_DIALOG_Y = 190; - private static final int MOUSE_DIALOG_SCREEN_BORDER_PADDING = 20; private static final int MOUSE_DIALOG_WIDTH = 300; private static final int MOUSE_DIALOG_HEIGHT = 50; - private static final int MOUSE_DIALOG_DEFAULT_OFFSET_X = 410; + private static final float MOUSE_IMAGE_DIALOG_POINT_HEIGHT = 3f / 5f; private static final String SCREEN_STATE_SCROLL_POSITION_X = "scrollPositionX"; public static final String SCROLL_TO_TROPHY_KEY = "scrollToTrophy"; @@ -219,10 +217,8 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti }); // heap number of trophies text - BitmapFont bf = ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD); - bf.getData().setScale(1); Group labelGroup = new Group(); - labelGroup.addActor(new Label(String.valueOf(threeStarsCount), new Label.LabelStyle(bf, Color.BLACK))); + labelGroup.addActor(new Label(String.valueOf(threeStarsCount), new Label.LabelStyle(getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_20), Color.BLACK))); labelGroup.setPosition(heapX + 280, heapY + 135); labelGroup.addAction(Actions.rotateBy(-15)); @@ -290,18 +286,12 @@ public class HallOfFameScreen extends AbstractTablexiaScreen<Map<ITrophyDefiniti TextureRegion mousePressedTexture = getScreenTextureRegion(HallOfFameAssets.HALL_OF_FAME_MOUSE_PRESSED); mouseImage.setDrawable(new SpriteDrawable(new Sprite(mousePressedTexture))); mouseImage.setTouchable(Touchable.disabled); - // dialog position - float dialogX = MOUSE_DIALOG_DEFAULT_OFFSET_X - scrollPane.getScrollX(); - if (dialogX < MOUSE_DIALOG_SCREEN_BORDER_PADDING) { - dialogX = MOUSE_DIALOG_SCREEN_BORDER_PADDING; - } - // bottom dialog arrow position - float bottomOffsetX = mouseImage.getX() - scrollPane.getScrollX() - MOUSE_DIALOG_SCREEN_BORDER_PADDING; - if (bottomOffsetX < MOUSE_DIALOG_SCREEN_BORDER_PADDING * 2) { - bottomOffsetX = MOUSE_DIALOG_SCREEN_BORDER_PADDING * 2; - } - final DynamicBubbleDialog mouseDialog = DialogFactory.createDynamicBubbleDialog(getText(TrophyHelper.MouseTexts.getMouseText(threeStarsCount)), dialogX, MOUSE_DIALOG_Y, MOUSE_DIALOG_WIDTH, MOUSE_DIALOG_HEIGHT, bottomOffsetX); + // dialog position related to mouse image + float dialogX = mouseImage.getX() - scrollPane.getScrollX(); + float dialogY = mouseImage.getY() + (mouseImage.getImageHeight() * MOUSE_POSITION_PROPERTIES.getThird() * MOUSE_IMAGE_DIALOG_POINT_HEIGHT); + + final DynamicBubbleDialog mouseDialog = new MouseDialog(getText(TrophyHelper.MouseTexts.getMouseText(threeStarsCount)), dialogX, dialogY, MOUSE_DIALOG_WIDTH, MOUSE_DIALOG_HEIGHT); mouseDialog.addClickListener(new DynamicBubbleDialog.ClickCallback() { @Override public void doClick() { diff --git a/core/src/cz/nic/tablexia/screen/halloffame/MouseDialog.java b/core/src/cz/nic/tablexia/screen/halloffame/MouseDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..928d87f5ced36021b1bcb56bbed1f2e55dbd5292 --- /dev/null +++ b/core/src/cz/nic/tablexia/screen/halloffame/MouseDialog.java @@ -0,0 +1,34 @@ +package cz.nic.tablexia.screen.halloffame; + +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +import cz.nic.tablexia.util.ui.dialog.DynamicBubbleDialog; +import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent; + +/** + * Created by frantisek on 1.12.15. + */ +public class MouseDialog extends DynamicBubbleDialog { + + public MouseDialog(String text, float x, float y, float width, float height) { + super(x, y, width, height, new DialogTextContent(text), BackGroundType.BUBBLE_CLASSIC_ROUND, ArrowType.BUBBLE_CLASSIC_BOTTOM); + } + + @Override + protected void transformArrowBeforeRender(TextureRegion arrowTexture) { + super.transformArrowBeforeRender(arrowTexture); + // target of bubble arrow is on edge of screen -> flip arrow image to point to that direction + if (getX() < 0) { + arrowTexture.flip(true, false); + } + } + + @Override + public void refreshDialogPosition() { + super.refreshDialogPosition(); + + if (getDialogArrowImage().getX() < getDialogArrow().getArrowOffsetX(getBackGroundType())) { + getDialogArrowImage().setX(getDialogArrow().getArrowOffsetX(getBackGroundType())); + } + } +} diff --git a/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyDialog.java b/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyDialog.java index 525b6f25677484267cd34b99326c3c8e6d69479b..8883c2ba3ddaa19a8c24ebea490d7549de4972db 100644 --- a/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyDialog.java +++ b/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyDialog.java @@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.utils.Align; -import cz.nic.tablexia.TablexiaSettings; import cz.nic.tablexia.loader.application.ApplicationFontManager; import cz.nic.tablexia.util.ui.dialog.ImageDialog; import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent; @@ -17,8 +16,6 @@ public class TrophyDialog extends ImageDialog { private static final float BANNER_SIZE_RATIO_TO_ORIGINAL_SIZE = 0.8f; private static final float IMAGE_SIZE_RATIO_TO_ORIGINAL_SIZE = 0.5f; - private static final float TITLE_FONT_SCALE = 0.7f; - private static final float CONTENT_FONT_SCALE = 0.5f; private TextureRegion bannerTexture; private TextureRegion trophyTexture; @@ -39,8 +36,8 @@ public class TrophyDialog extends ImageDialog { addImage(trophyTexture, IMAGE_SIZE_RATIO_TO_ORIGINAL_SIZE); getContentTable().row(); getContentTable().setDebug(true); - addLabel(dialogTextContent.getTitle(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD), Color.BLACK), Align.center, TITLE_FONT_SCALE); + addLabel(dialogTextContent.getTitle(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_14), Color.BLACK), Align.center); getContentTable().row(); - addLabel(dialogTextContent.getContent(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR), Color.BLACK), Align.center, CONTENT_FONT_SCALE).fillX(); + addLabel(dialogTextContent.getContent(), new Label.LabelStyle(ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_12), Color.BLACK), Align.center).fillX(); } } diff --git a/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyThreeStarsGamesDialog.java b/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyThreeStarsGamesDialog.java index 695016984f610a0073d6f8b2fe2f721d106f032e..2bca6bff628811105e03045847d42f9f51668583 100644 --- a/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyThreeStarsGamesDialog.java +++ b/core/src/cz/nic/tablexia/screen/halloffame/trophy/TrophyThreeStarsGamesDialog.java @@ -22,7 +22,8 @@ import cz.nic.tablexia.util.ui.dialog.TablexiaDialog; */ public class TrophyThreeStarsGamesDialog extends TablexiaDialog { - private static final float TITLE_FONT_SCALE = 0.7f; + private final ApplicationFontManager.FontType LABELS_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_REGULAR_14; + private final ApplicationFontManager.FontType VALUES_TEXT_FONT = ApplicationFontManager.FontType.ROBOTO_BOLD_14; public TrophyThreeStarsGamesDialog(float x, float y, float width, float height, BackGroundType backgroundTypeDrawable, String sumText, Map<GameDefinition, Integer> starResults) { super(x, y, width, height, backgroundTypeDrawable); @@ -39,8 +40,8 @@ public class TrophyThreeStarsGamesDialog extends TablexiaDialog { sum += numOfStars; } // add line for each game - addLabel(GameMenuDefinition.getGameMenuDefinitionForGameDefinition(gameDef).getTitle(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR), Align.left).expand().left().top(); - addLabel(String.valueOf(numOfStars), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD), Align.right).expand().right().top(); + addLabel(GameMenuDefinition.getGameMenuDefinitionForGameDefinition(gameDef).getTitle(), ApplicationFontManager.getInstance().getFont(LABELS_TEXT_FONT), Align.left).expand().left().top(); + addLabel(String.valueOf(numOfStars), ApplicationFontManager.getInstance().getFont(VALUES_TEXT_FONT), Align.right).expand().right().top(); getContentTable().row(); } @@ -49,8 +50,8 @@ public class TrophyThreeStarsGamesDialog extends TablexiaDialog { getContentTable().row(); // add sum line - addLabel(sumText, ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD), Align.left).expand().left().top(); - addLabel(String.valueOf(sum), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD), Align.right).expand().right().top(); + addLabel(sumText, ApplicationFontManager.getInstance().getFont(VALUES_TEXT_FONT), Align.left).expand().left().top(); + addLabel(String.valueOf(sum), ApplicationFontManager.getInstance().getFont(VALUES_TEXT_FONT), Align.right).expand().right().top(); getContentTable().row(); } @@ -68,7 +69,6 @@ public class TrophyThreeStarsGamesDialog extends TablexiaDialog { protected Cell<Label> addLabel(String text, BitmapFont font, int align) { Label.LabelStyle labelStyle = new Label.LabelStyle(font, Color.BLACK); - labelStyle.font.getData().setScale(TITLE_FONT_SCALE); Label label = new Label(text, labelStyle); label.setWrap(true); label.setAlignment(align); diff --git a/core/src/cz/nic/tablexia/util/ScaleUtil.java b/core/src/cz/nic/tablexia/util/ScaleUtil.java index 5daed5c58de3d034fbf3ef3e957716808f871c80..4d2d3aef3afd8118288c424642e8aa06796564ba 100644 --- a/core/src/cz/nic/tablexia/util/ScaleUtil.java +++ b/core/src/cz/nic/tablexia/util/ScaleUtil.java @@ -1,5 +1,6 @@ package cz.nic.tablexia.util; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.Actor; diff --git a/core/src/cz/nic/tablexia/util/ui/ClickListenerWithSound.java b/core/src/cz/nic/tablexia/util/ui/ClickListenerWithSound.java index 961e68f8f20f907a359027f19d4c198887ff6cda..44aab2ace08e6ff3078a16bfd8768b081ce7d10e 100644 --- a/core/src/cz/nic/tablexia/util/ui/ClickListenerWithSound.java +++ b/core/src/cz/nic/tablexia/util/ui/ClickListenerWithSound.java @@ -11,7 +11,7 @@ import cz.nic.tablexia.loader.application.ApplicationSoundManager; public class ClickListenerWithSound extends ClickListener { @Override - public final void clicked (InputEvent event, float x, float y) { + public void clicked (InputEvent event, float x, float y) { playButtonSound(); super.clicked(event, x, y); onClick(event, x, y); diff --git a/core/src/cz/nic/tablexia/util/ui/PagedScrollPane.java b/core/src/cz/nic/tablexia/util/ui/PagedScrollPane.java new file mode 100644 index 0000000000000000000000000000000000000000..4f6d3cf2bcbecf99cf323e35d3861c15aaf29396 --- /dev/null +++ b/core/src/cz/nic/tablexia/util/ui/PagedScrollPane.java @@ -0,0 +1,210 @@ +package cz.nic.tablexia.util.ui; + +import com.badlogic.gdx.Input; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.InputListener; +import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; +import com.badlogic.gdx.scenes.scene2d.ui.Table; + +import cz.nic.tablexia.TablexiaSettings; +import cz.nic.tablexia.screen.gamemenu.pages.MenuPage; + +/** + * Represents Horizontal Paged Scroll Pane + * Previous one (ViewPager) was a bit glitchy + * + * Created by Drahomir Karchnak on 01/12/15. + */ +public class PagedScrollPane extends ScrollPane { + + private Table contentTable; + + private int indexCurrentPage; + private float distanceToChangePage = 120; + + private float lastScrollX = -1; + private float lastTouchX = -1; + + public PagedScrollPane() { + super(null); + prepareScrollPane(); + prepareInput(); + + setSmoothScrolling(true); + } + + /** + * Prepares ScrollPane and it's content + */ + private void prepareScrollPane() { + contentTable = new Table(); + contentTable.setDebug(TablexiaSettings.getInstance().isShowBoundingBoxes()); + super.setWidget(contentTable); + + setFlingTime(0); + setScrollingDisabled(false, true); + setCancelTouchFocus(false); + } + + /** + * Prepares InputListener + */ + private void prepareInput() { + this.addListener(new InputListener() { + @Override + public boolean keyDown(InputEvent event, int keycode) { + //TODO - Use TablexiaSettings for Key Bindings, and enable keydown events + switch (keycode) { + case Input.Keys.LEFT: + scrollToPage(indexCurrentPage - 1, true); + break; + + case Input.Keys.RIGHT: + scrollToPage(indexCurrentPage + 1, true); + break; + } + + return super.keyDown(event, keycode); + } + + @Override + public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { + lastTouchX = x; + return true; + } + + @Override + public void touchUp(InputEvent event, float x, float y, int pointer, int button) { + super.touchUp(event, x, y, pointer, button); + onScroll(lastTouchX, x); + } + }); + } + + /** + * Determinates if PagedScrollPane should change page or not + * according to swipes X coordinate + * @param touchDownX X coordinate of last touch down event + * @param touchUpX X coordinate of last touch up event + */ + private void onScroll(float touchDownX, float touchUpX) { + setVelocityX(0); + + if(Math.abs(touchDownX - touchUpX) <= distanceToChangePage) { + scrollToPage(indexCurrentPage, true); + return; + } + else { + if(touchDownX - touchUpX > 0) { //swiped right + //scroll to next valid page + scrollToPage(indexCurrentPage + 1, true); + } + else { //swiped left + //scroll to previous valid page + scrollToPage(indexCurrentPage - 1, true); + } + } + } + + /** + * Adds a page to PagedScrollPane's content + * @param a + */ + public void addPage(MenuPage a) { + if(a != null) { + contentTable.add(a); + } + } + + /** + * Updates PagedScrollPane + * Had to override this method to add custom behaviour + * @param delta + */ + @Override + public void act(float delta) { + super.act(delta); + + //if scrollpane changed since the last frame + if (lastScrollX != getVisualScrollX()) { + if(contentTable == null) + return; + + float scrollX = getVisualScrollX(); + float pageX = 0; + float pageWidth = 0; + + for (Actor a : contentTable.getChildren()) { + MenuPage menuPage = (MenuPage) a; + + pageX = menuPage.getX(); + pageWidth = menuPage.getWidth(); + + //Calls children's onScoll method + if (scrollX > pageX && scrollX < (pageX + pageWidth)) { + menuPage.onScroll(-(scrollX - pageX)); + } + else if (scrollX < (pageX) && (scrollX + pageWidth) > pageX) { + menuPage.onScroll(pageX - scrollX); + } + if (pageX == scrollX) { //Scrolled to the page + menuPage.onScrolledToPage(); + menuPage.onScroll(0); + } + } + } + lastScrollX = getVisualScrollX(); + } + + /** + * Tells PagedScrollPane to scroll to the page + * page number isn't index in contents children list + * but rather order from the left (includes only valid pages) + * @param pageNumber + * @param smooth + */ + public void scrollToPage(int pageNumber, boolean smooth) { + if(contentTable == null) return; + + int validPagesCount = 0; + //iterates through all children of contentTable + for (Actor a : contentTable.getChildren()) { + MenuPage page = (MenuPage) a; + + //tells if pagedScrollPane can snap to this child + if (page.isSnapToAllowed()) { + //have we reached the page we want to scroll to + if (validPagesCount == pageNumber) { + setSmoothScrolling(smooth); + setScrollX(page.getX()); + + //in case smooth scrolling is set to false, we need to update visual scroll + if (!smooth) { + updateVisualScroll(); + } + + //Saves index of current page, index doesnt include invalid pages + indexCurrentPage = validPagesCount; + break; + } + validPagesCount++; + } + } + + setSmoothScrolling(true); + } + + /** + * How much you have to scroll to change the page + * Everyscroll above the distance value will be consider as a page changing scroll + * @param distance + */ + public void setDistanceToChangePage(float distance) { + distanceToChangePage = Math.abs(distance); + } + + public int getIndexCurrentPage() { + return indexCurrentPage; + } +} diff --git a/core/src/cz/nic/tablexia/util/ui/ViewPager.java b/core/src/cz/nic/tablexia/util/ui/ViewPager.java deleted file mode 100644 index c65d43d55adfd58e7824dd52cee4141b2e03e93a..0000000000000000000000000000000000000000 --- a/core/src/cz/nic/tablexia/util/ui/ViewPager.java +++ /dev/null @@ -1,202 +0,0 @@ -package cz.nic.tablexia.util.ui; - -import com.badlogic.gdx.math.MathUtils; -import com.badlogic.gdx.scenes.scene2d.Actor; -import com.badlogic.gdx.scenes.scene2d.ui.Cell; -import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; -import com.badlogic.gdx.scenes.scene2d.ui.Table; -import com.badlogic.gdx.utils.Array; - -/** - * Created by lhoracek on 3/4/15. - */ -public class ViewPager extends ScrollPane { - - private boolean wasPanDragFling = false; - private float lastX; - private Table content; - - public ViewPager() { - super(null); - setup(); - } - - public ViewPager(Skin skin) { - super(null, skin); - setup(); - } - - public ViewPager(Skin skin, String styleName) { - super(null, skin, styleName); - setup(); - } - - public ViewPager(Actor widget, ScrollPane.ScrollPaneStyle style) { - super(null, style); - setup(); - } - - private void setup() { - content = new Table(); - super.setWidget(content); - content.setSize(100, 100); - content.defaults().space(0); - //setClamp(false); - setScrollingDisabled(false, true); - setFlingTime(0.1f); - } - - private void fixChildrenSizes() { - if (content != null) { - for (Actor a : content.getChildren()) { - a.setSize(getWidth(), getHeight()); - } - } - } - - @Override - public void setSize(float width, float height) { - super.setSize(width, height); - fixChildrenSizes(); - } - - - @Override - public void setBounds(float x, float y, float width, float height) { - super.setBounds(x, y, width, height); - fixChildrenSizes(); - } - - public void addPages(Actor... pages) { - for (Actor page : pages) { - content.add(page).expandY().fillY(); - } - } - - public void addPage(Actor page) { - content.add(page).expandY().fillY(); - } - - @Override - public void act(float delta) { - if (wasPanDragFling && !isPanning() && !isDragging() && !isFlinging()) { - wasPanDragFling = false; - smoothScrollToCurrentPage(); - } else { - if (isPanning() || isDragging() || isFlinging()) { - wasPanDragFling = true; - } - } - - - if (lastX != getWidget().getX()) { - float scrollX = -getWidget().getX(); - Array<Actor> pages = content.getChildren(); - float pageX = 0; - float pageWidth = 0; - - if (pages.size > 0) { - for (Actor a : pages) { - pageX = a.getX(); - pageWidth = a.getWidth(); - if (scrollX > pageX && scrollX < (pageX + pageWidth)) { - if (a instanceof ScrollListener) { - ScrollListener sl = (ScrollListener) a; - sl.onScroll(-(scrollX - pageX)); - } - } else if (scrollX < (pageX) && (scrollX + pageWidth) > pageX) { - if (a instanceof ScrollListener) { - ScrollListener sl = (ScrollListener) a; - sl.onScroll(pageX - scrollX); - } - } - if (pageX == scrollX) { - if (a instanceof ScrollListener) { - ScrollListener sl = (ScrollListener) a; - sl.onScrolledToPage(); - } - } - } - } - } - lastX = getWidget().getX(); - super.act(delta); - } - - - @Override - @Deprecated - public void setWidget(Actor widget) { - super.setWidget(widget); - } - - @Override - public void setWidth(float width) { - super.setWidth(width); - if (content != null) { - for (Cell cell : content.getCells()) { - cell.width(width); - } - content.invalidate(); - } - } - - /** - * Smooth scroll to child with given index - * - * @param page - * @param smoothScroll - */ - public void scrollToPage(int page, boolean smoothScroll) { - if (content.getChildren().size <= page) { - throw new IllegalArgumentException("Page index " + page + " out of bounds"); - } - layout(); - final float width = getWidth(); - final float maxX = getMaxX(); - - float pageX = 0; - float pageWidth = 0; - if (content.getChildren().size > 0) { - for (int i = 0; i <= page; i++) { - Actor a = content.getChildren().get(i); - pageX = a.getX(); - pageWidth = a.getWidth(); - } - setSmoothScrolling(smoothScroll); - setScrollX(MathUtils.clamp(pageX - (width - pageWidth) / 2, 0, maxX)); - if (!smoothScroll) { - updateVisualScroll(); - setSmoothScrolling(true); - } - } - } - - private void smoothScrollToCurrentPage() { - final float width = getWidth(); - final float scrollX = getScrollX(); - final float maxX = getMaxX(); - - if (scrollX >= maxX || scrollX <= 0) return; - - Array<Actor> pages = content.getChildren(); - float pageX = 0; - float pageWidth = 0; - if (pages.size > 0) { - for (Actor a : pages) { - pageX = a.getX(); - pageWidth = a.getWidth(); - if (scrollX < (pageX + pageWidth * 0.5)) { - break; - } - } - setScrollX(MathUtils.clamp(pageX - (width - pageWidth) / 2, 0, maxX)); - } - } - - public interface ScrollListener { - void onScroll(float offset); - void onScrolledToPage(); - } -} diff --git a/core/src/cz/nic/tablexia/util/ui/dialog/DialogFactory.java b/core/src/cz/nic/tablexia/util/ui/dialog/DialogFactory.java index 5f1dddbe9725c50cf72ec7ed29032fa9c5b79e94..59cca234ee03b5c2135c694910b28f79b958a441 100644 --- a/core/src/cz/nic/tablexia/util/ui/dialog/DialogFactory.java +++ b/core/src/cz/nic/tablexia/util/ui/dialog/DialogFactory.java @@ -75,8 +75,13 @@ public class DialogFactory { return dialog; } - public static DynamicBubbleDialog createDynamicBubbleDialog(String text, float x, float y, float width, float height, float bubbleArrowOffsetX) { - DynamicBubbleDialog dialog = new DynamicBubbleDialog(x, y, width, height, TablexiaDialog.BackGroundType.BUBBLE_CLASSIC_PURE, new DialogTextContent(text), bubbleArrowOffsetX); + public static DynamicBubbleDialog createDynamicBubbleDialog(String text, float x, float y, float width, float height) { + DynamicBubbleDialog dialog = new DynamicBubbleDialog(x, y, width, height, new DialogTextContent(text)); + return dialog; + } + + public static DynamicBubbleDialog createDynamicBubbleDialog(String text, float x, float y, float width, float height, TablexiaDialog.BackGroundType backGroundType, DynamicBubbleDialog.ArrowType arrowType) { + DynamicBubbleDialog dialog = new DynamicBubbleDialog(x, y, width, height, new DialogTextContent(text), backGroundType, arrowType); return dialog; } diff --git a/core/src/cz/nic/tablexia/util/ui/dialog/DynamicBubbleDialog.java b/core/src/cz/nic/tablexia/util/ui/dialog/DynamicBubbleDialog.java index 59b394ac31d269b80f7940c23ab8e71ec480e9d6..ebe79a598ccaa486add85491085a534f03256e0e 100644 --- a/core/src/cz/nic/tablexia/util/ui/dialog/DynamicBubbleDialog.java +++ b/core/src/cz/nic/tablexia/util/ui/dialog/DynamicBubbleDialog.java @@ -7,9 +7,11 @@ import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.actions.Actions; import com.badlogic.gdx.scenes.scene2d.ui.Dialog; import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import cz.nic.tablexia.loader.application.ApplicationAtlasManager; +import cz.nic.tablexia.util.Point; import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent; import static com.badlogic.gdx.scenes.scene2d.actions.Actions.fadeOut; @@ -20,37 +22,186 @@ import static com.badlogic.gdx.scenes.scene2d.actions.Actions.sequence; */ public class DynamicBubbleDialog extends TextDialog { - private static final int DIALOG_BOTTOM_ARROW_Y_OFFSET = 15; + public enum ArrowType { + BUBBLE_CLASSIC_BOTTOM (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_BOTTOM, new Point(20, 0), 4, ArrowPosition.BOTTOM), + BUBBLE_CLASSIC_TOP (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_TOP, new Point(20, 20), 4, ArrowPosition.TOP), + BUBBLE_CLASSIC_LEFT (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_LEFT, new Point(0, 0), 14, ArrowPosition.LEFT), + BUBBLE_CLASSIC_RIGHT (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_RIGHT, new Point(20, 0), 14, ArrowPosition.RIGHT), + + BUBBLE_ARROW_BOTTOM (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_BOTTOM, new Point(15, 0), 15, ArrowPosition.BOTTOM), + BUBBLE_ARROW_TOP (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_TOP, new Point(15, 51), 15, ArrowPosition.TOP), + BUBBLE_ARROW_LEFT (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_LEFT, new Point(0, 15), 15, ArrowPosition.LEFT), + BUBBLE_ARROW_RIGHT (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_RIGHT, new Point(51, 15), 15, ArrowPosition.RIGHT), + + BUBBLE_ARROW_BEND_LEFT_BOTTOM (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_BEND_LEFT_BOTTOM, new Point(0, 13), 36, ArrowPosition.BOTTOM), + BUBBLE_ARROW_BEND_LEFT_TOP (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_BEND_LEFT_TOP, new Point(0, 38), 36, ArrowPosition.TOP), + BUBBLE_ARROW_BEND_LEFT_LEFT (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_BEND_LEFT_LEFT, new Point(13, 44), 8, ArrowPosition.LEFT), + BUBBLE_ARROW_BEND_LEFT_RIGHT (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_BEND_LEFT_RIGHT, new Point(37, 44), 8, ArrowPosition.RIGHT); + + private static final int DIALOG_ARROW_ROUND_BOTTOM_OFFSET_Y = 6; + private static final int DIALOG_ARROW_SQUARE_BOTTOM_OFFSET_Y = 5; + + private static final int DIALOG_ARROW_ROUND_LEFT_OFFSET_X = 5; + private static final int DIALOG_ARROW_SQUARE_LEFT_OFFSET_X = 4; + + private static final int DIALOG_ARROW_ROUND_RIGHT_OFFSET_X = 5; + private static final int DIALOG_ARROW_SQUARE_RIGHT_OFFSET_X = 5; + + private static final int DIALOG_ARROW_ROUND_TOP_OFFSET_Y = 5; + private static final int DIALOG_ARROW_SQUARE_TOP_OFFSET_Y = 6; + + private static final int DIALOG_ROUND_ARROW_OFFSET_X = 15; + private static final int DIALOG_SQUARE_ARROW_OFFSET_X = 10; + + private String arrowTextureName; + private ArrowPosition position; + // point on arrow image where its apex is + private Point point; + // point on arrow image where dialog centering will be related to + private float centringPoint; + + ArrowType(String arrowTextureName, Point point, float centringPoint, ArrowPosition position) { + this.arrowTextureName = arrowTextureName; + this.point = point; + this.position = position; + this.centringPoint = centringPoint; + } + + public TextureRegion getTextureRegion() { + return ApplicationAtlasManager.getInstance().getTextureRegion(arrowTextureName); + } + + public float getArrowPositionY(DynamicBubbleDialog dialog) { + return dialog.getActorY() - getPoint().y; + } + + public float getArrowPositionX(DynamicBubbleDialog dialog) { + return dialog.getActorX() - getPoint().x; + } + + public float getCenteringPoint() { + return centringPoint; + } + + public Point getPoint() { + return point; + } + + public int getArrowOffsetBottomY(BackGroundType backGroundType) { + switch (backGroundType) { + case BUBBLE_CLASSIC_ROUND: + return DIALOG_ARROW_ROUND_BOTTOM_OFFSET_Y; + case BUBBLE_CLASSIC_SQUARE: + return DIALOG_ARROW_SQUARE_BOTTOM_OFFSET_Y; + } + + return 0; + } + + public int getArrowOffsetTopY(BackGroundType backGroundType) { + switch (backGroundType) { + case BUBBLE_CLASSIC_ROUND: + return DIALOG_ARROW_ROUND_TOP_OFFSET_Y; + case BUBBLE_CLASSIC_SQUARE: + return DIALOG_ARROW_SQUARE_TOP_OFFSET_Y; + } + + return 0; + } + + public int getArrowOffsetX(BackGroundType backGroundType) { + switch (backGroundType) { + case BUBBLE_CLASSIC_ROUND: + return DIALOG_ROUND_ARROW_OFFSET_X; + case BUBBLE_CLASSIC_SQUARE: + return DIALOG_SQUARE_ARROW_OFFSET_X; + } + + return 0; + } + + public int getArrowLeftOffsetX(BackGroundType backGroundType) { + switch (backGroundType) { + case BUBBLE_CLASSIC_ROUND: + return DIALOG_ARROW_ROUND_LEFT_OFFSET_X; + case BUBBLE_CLASSIC_SQUARE: + return DIALOG_ARROW_SQUARE_LEFT_OFFSET_X; + } + + return 0; + } + + public int getArrowRightOffsetX(BackGroundType backGroundType) { + switch (backGroundType) { + case BUBBLE_CLASSIC_ROUND: + return DIALOG_ARROW_ROUND_RIGHT_OFFSET_X; + case BUBBLE_CLASSIC_SQUARE: + return DIALOG_ARROW_SQUARE_RIGHT_OFFSET_X; + } + + return 0; + } + } + + public enum ArrowPosition { + TOP, + BOTTOM, + LEFT, + RIGHT, + } + private static final float FADE_EFFECT_DURATION = 0.4f; - final Image dialogBottomImage; + // position on screen where bubble dialog arrow will be related to + private float actorY; + private float actorX; + + final private Image dialogArrowImage; + final private ArrowType dialogArrow; + final private BackGroundType backGroundType; - public DynamicBubbleDialog(float x, float y, float width, float height, BackGroundType backGroundType, DialogTextContent dialogTextContent, float bubbleArrowOffsetX) { + public DynamicBubbleDialog(float x, float y, float width, float height, DialogTextContent dialogTextContent, BackGroundType backGroundType, ArrowType arrowType) { super(x, y, width, height, backGroundType, dialogTextContent); - TextureRegion dialogBottom = ApplicationAtlasManager.getInstance().getTextureRegion(ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_BOTTOM); - dialogBottomImage = new Image(dialogBottom); - dialogBottomImage.setPosition(bubbleArrowOffsetX, y - DIALOG_BOTTOM_ARROW_Y_OFFSET); + TextureRegion dialogArrowTexture = arrowType.getTextureRegion(); + + this.dialogArrow = arrowType; + this.backGroundType = backGroundType; + // if point on which dialog points is out of screen and arrow offset we move it to screen + this.actorX = x < arrowType.getArrowOffsetX(backGroundType) ? arrowType.getArrowOffsetX(backGroundType) : x; + this.actorY = y; + + transformArrowBeforeRender(dialogArrowTexture); + + dialogArrowImage = new Image(dialogArrowTexture); + dialogArrowImage.setPosition(x, y); getStyle().stageBackground = null; } + public DynamicBubbleDialog(float x, float y, float width, float height, DialogTextContent dialogTextContent) { + this(x, y, width, height, dialogTextContent, BackGroundType.BUBBLE_CLASSIC_ROUND, ArrowType.BUBBLE_CLASSIC_BOTTOM); + } + @Override public Dialog show(Stage stage) { super.show(stage); - dialogBottomImage.addAction(sequence(Actions.alpha(0), Actions.fadeIn(FADE_EFFECT_DURATION, Interpolation.fade))); - stage.addActor(dialogBottomImage); + getDialogArrowImage().addAction(sequence(Actions.alpha(0), Actions.fadeIn(FADE_EFFECT_DURATION, Interpolation.fade))); + stage.addActor(getDialogArrowImage()); + + refreshDialogPosition(); + return this; } @Override public void hide() { super.hide(); - dialogBottomImage.addAction(sequence(fadeOut(FADE_EFFECT_DURATION, Interpolation.fade), Actions.removeActor())); + getDialogArrowImage().addAction(sequence(fadeOut(FADE_EFFECT_DURATION, Interpolation.fade), Actions.removeActor())); } @Override public void toFront() { super.toFront(); - dialogBottomImage.toFront(); + getDialogArrowImage().toFront(); } public void addClickListener(final ClickCallback callback) { @@ -64,6 +215,77 @@ public class DynamicBubbleDialog extends TextDialog { }); } + protected void transformArrowBeforeRender(TextureRegion arrowTexture) { + } + + /** + * Set bubble arrow position to default position given in constructor and position + * of bubble itself to be related to arrow + */ + public void refreshDialogPosition() { + getDialogArrowImage().setPosition(getDialogArrow().getArrowPositionX(this), getDialogArrow().getArrowPositionY(this)); + + float dialogY; + if (getDialogArrow().position == ArrowPosition.TOP) { + dialogY = getDialogArrowImage().getY() - getHeight() + getDialogArrow().getArrowOffsetTopY(getBackGroundType()); + } else if (getDialogArrow().position == ArrowPosition.BOTTOM) { + dialogY = getDialogArrowImage().getY() + getDialogArrowImage().getHeight() - getDialogArrow().getArrowOffsetBottomY(getBackGroundType()); + } else { + dialogY = getDialogArrowImage().getY() - getHeight() / 2 + getDialogArrow().getCenteringPoint(); + } + + float dialogX; + + if (getDialogArrow().position.equals(ArrowPosition.RIGHT)) { + dialogX = getDialogArrowImage().getX() - getWidth() + getDialogArrow().getArrowRightOffsetX(getBackGroundType()); + } else if (getDialogArrow().position.equals(ArrowPosition.LEFT)) { + dialogX = getDialogArrowImage().getX() - getDialogArrow().getArrowLeftOffsetX(getBackGroundType()) + getDialogArrowImage().getWidth(); + } else { + dialogX = getDialogArrowImage().getX() - getWidth() + getDialogArrow().getArrowOffsetX(getBackGroundType()) + getDialogArrowImage().getWidth(); + } + + if (dialogX < 0) { + dialogX = 0; + } + + setPosition(dialogX, dialogY); + } + + @Override + public Table debug() { + super.debug(); + getDialogArrowImage().debug(); + return this; + } + + protected void centerDialogToArrowX() { + setX(getDialogArrowImage().getX() - getWidth() / 2 + getDialogArrow().getCenteringPoint()); + } + + protected void centerDialogToArrowY() { + setY(getDialogArrowImage().getY() - getHeight() / 2 + getDialogArrow().getCenteringPoint()); + } + + protected Image getDialogArrowImage() { + return dialogArrowImage; + } + + protected ArrowType getDialogArrow() { + return dialogArrow; + } + + protected BackGroundType getBackGroundType() { + return backGroundType; + } + + public float getActorY() { + return actorY; + } + + public float getActorX() { + return actorX; + } + public interface ClickCallback { void doClick(); } diff --git a/core/src/cz/nic/tablexia/util/ui/dialog/TablexiaDialog.java b/core/src/cz/nic/tablexia/util/ui/dialog/TablexiaDialog.java index 43340ebe7b64e90dcc7efe52a0d384d44f31dc6a..8dad68ef9848024b7b9566088cb6e7dfdba5aea5 100644 --- a/core/src/cz/nic/tablexia/util/ui/dialog/TablexiaDialog.java +++ b/core/src/cz/nic/tablexia/util/ui/dialog/TablexiaDialog.java @@ -38,10 +38,10 @@ public class TablexiaDialog extends Dialog { public enum BackGroundType { BUBBLE_CLASSIC (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC), - BUBBLE_CLASSIC_PURE (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_PURE), - BUBBLE_CLASSIC_BOTTOM (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_BOTTOM), + BUBBLE_CLASSIC_ROUND (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_ROUND), + BUBBLE_CLASSIC_SQUARE (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_SQUARE), BUBBLE_ARROW_DOWN (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_DOWN), - BUBBLE_ARROW_LEFT (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_LEFT), + BUBBLE_ARROW_LEFT (ApplicationAtlasManager.DIALOG_BUBBLE_ARROW_BEND_LEFT), BUBBLE_CLASSIC_CONTINUE_BUTTON (ApplicationAtlasManager.DIALOG_BUBBLE_CLASSIC_CONTINUE_BUTTON), DIALOG_RECTANGLE (ApplicationAtlasManager.DIALOG_RECTANGLE), DIALOG_SQUARE (ApplicationAtlasManager.DIALOG_SQUARE), @@ -165,8 +165,10 @@ public class TablexiaDialog extends Dialog { float imageMaxWidth = getWidth() - 20; //20 is approx the padding from both sides float imageMeasureRatio = image.getHeight() / image.getWidth(); + float imageNewWidth = image.getWidth() * sizeRatioToOriginalSize; - float imageNewHeight = imageNewWidth * imageMeasureRatio; + float imageNewHeight = image.getHeight() * sizeRatioToOriginalSize; + if (imageNewHeight > imageMaxHeight) { imageNewHeight = imageMaxHeight; imageNewWidth = (1 / imageMeasureRatio) * imageNewHeight; @@ -176,6 +178,11 @@ public class TablexiaDialog extends Dialog { } } + if (imageNewWidth > imageMaxWidth) { + imageNewWidth = imageMaxWidth; + imageNewHeight = imageMeasureRatio * imageNewWidth; + } + image.getDrawable().setMinHeight(imageNewHeight); image.getDrawable().setMinWidth(imageNewWidth); return getContentTable().add(image); diff --git a/core/src/cz/nic/tablexia/util/ui/dialog/TextDialog.java b/core/src/cz/nic/tablexia/util/ui/dialog/TextDialog.java index c8eddcf00cef8d3d98777435fd7bd793090398a0..103284c3a3d812a37586db40aa6ad2dbbff0c45e 100644 --- a/core/src/cz/nic/tablexia/util/ui/dialog/TextDialog.java +++ b/core/src/cz/nic/tablexia/util/ui/dialog/TextDialog.java @@ -15,9 +15,6 @@ import cz.nic.tablexia.util.ui.dialog.text.DialogTextContent; */ public class TextDialog extends TablexiaDialog { - private static final float TITLE_FONT_SCALE = 0.7f; - private static final float CONTENT_FONT_SCALE = 0.5f; - private DialogTextContent dialogTextContent; public TextDialog(float x, float y, float width, float height, BackGroundType backGroundType, DialogTextContent dialogTextContent) { @@ -33,15 +30,14 @@ public class TextDialog extends TablexiaDialog { protected void prepareContent() { if (dialogTextContent != null) { if (dialogTextContent.getTitle() != null && !dialogTextContent.getTitle().equals("")) { - addLabel(dialogTextContent.getTitle(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_BOLD)); + addLabel(dialogTextContent.getTitle(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_BOLD_16)); getContentTable().row(); } - addLabel(dialogTextContent.getContent(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.APPLICATION_DEFAULT_FONT_REGULAR)).center().expand().top().fillX(); + addLabel(dialogTextContent.getContent(), ApplicationFontManager.getInstance().getFont(ApplicationFontManager.FontType.ROBOTO_REGULAR_14)).center().expand().top().fillX(); } } protected Cell<Label> addLabel(String text, BitmapFont font) { - font.getData().setScale(TITLE_FONT_SCALE); return super.addLabel(text, new Label.LabelStyle(font, Color.BLACK), getTextAlignment()); }